mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-06 04:46:53 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e651d32334 | |||
| a8e30b137a | |||
| 09808a47d2 | |||
| 898195c770 | |||
| 07e0d067d5 | |||
| 185940aecb | |||
| def674bc6c | |||
| feb4f03587 | |||
| 5cdff0b4f9 | |||
| 29ff9bc52a | |||
| 54d196c9d5 | |||
| 34defec669 | |||
| e189abd9c2 | |||
| f07855df08 | |||
| ae3102a86c | |||
| 48a2507ef8 | |||
| 311d588850 | |||
| 2f1910ec87 | |||
| 48a0664c2b | |||
| 05ec40a956 | |||
| dc9dccbf05 | |||
| 476efa4209 | |||
| 7bcf57e77b | |||
| ce3ba29209 | |||
| cb95ece9c6 | |||
| 2a0db561b4 | |||
| 2b30334b82 | |||
| dbd6699a4f | |||
| 2130bd6444 |
40
CHANGELOG.md
40
CHANGELOG.md
@ -1,3 +1,43 @@
|
|||||||
|
## 6.7.2
|
||||||
|
|
||||||
|
* Fixed that charts inside `<keep-alive>` failed to display after activation.
|
||||||
|
|
||||||
|
## 6.7.1
|
||||||
|
|
||||||
|
* Fixed that native events won't actually trigger.
|
||||||
|
|
||||||
|
## 6.7.0
|
||||||
|
|
||||||
|
* Added supports for native DOM events binding with the `native:` prefix.
|
||||||
|
|
||||||
|
## 6.6.10
|
||||||
|
|
||||||
|
* Fixed that `autoresize` doesn't work when reducing the height or the root element.
|
||||||
|
|
||||||
|
## 6.6.9
|
||||||
|
|
||||||
|
* Fixed that the chart may not be the same size as the component root element ([#761](https://github.com/ecomfe/vue-echarts/issues/761)).
|
||||||
|
|
||||||
|
## 6.6.8
|
||||||
|
|
||||||
|
* Fixed the postinstall script to patch the correct `types` entry for Vue 2.7.
|
||||||
|
|
||||||
|
## 6.6.7
|
||||||
|
|
||||||
|
* Added missing type file for Vue 2.7.
|
||||||
|
|
||||||
|
## 6.6.6
|
||||||
|
|
||||||
|
* Fixed types for Vue < 2.7.
|
||||||
|
|
||||||
|
## 6.6.5
|
||||||
|
|
||||||
|
* Fixed type for `option` regressed in v6.6.2.
|
||||||
|
|
||||||
|
## 6.6.4
|
||||||
|
|
||||||
|
* Fixed style regression introduced by v6.6.3.
|
||||||
|
|
||||||
## 6.6.3
|
## 6.6.3
|
||||||
|
|
||||||
* Fixed inner wrapper styles.
|
* Fixed inner wrapper styles.
|
||||||
|
|||||||
161
README.md
161
README.md
@ -1,6 +1,6 @@
|
|||||||
<h1 align="center">Vue-ECharts</h1>
|
<h1 align="center">Vue-ECharts</h1>
|
||||||
|
|
||||||
<p align="center">Vue.js <sup>(v2/v3)</sup> component for Apache ECharts <sup>(v5)</sup>.</p>
|
<p align="center">Vue.js <sup>(v2/v3)</sup> component for Apache ECharts™ <sup>(v5)</sup>.</p>
|
||||||
<p align="center"><a href="https://vue-echarts.dev/">View Demo →</a></p>
|
<p align="center"><a href="https://vue-echarts.dev/">View Demo →</a></p>
|
||||||
<p align="center"><a href="https:///pr.new/ecomfe/vue-echarts"><img alt="Open in Codeflow" src="https://developer.stackblitz.com/img/open_in_codeflow.svg" height="28"/></a> <a href="https://codesandbox.io/p/github/ecomfe/vue-echarts"><img alt="Edit in CodeSandbox" src="https://assets.codesandbox.io/github/button-edit-lime.svg" height="28"/></a></p>
|
<p align="center"><a href="https:///pr.new/ecomfe/vue-echarts"><img alt="Open in Codeflow" src="https://developer.stackblitz.com/img/open_in_codeflow.svg" height="28"/></a> <a href="https://codesandbox.io/p/github/ecomfe/vue-echarts"><img alt="Edit in CodeSandbox" src="https://assets.codesandbox.io/github/button-edit-lime.svg" height="28"/></a></p>
|
||||||
|
|
||||||
@ -23,17 +23,18 @@ Not ready yet? Read documentation for older versions [here →](https://github.c
|
|||||||
|
|
||||||
### npm & ESM
|
### npm & ESM
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
npm install echarts vue-echarts
|
npm i echarts vue-echarts
|
||||||
```
|
```
|
||||||
|
|
||||||
To make `vue-echarts` work for _Vue 2_ (<2.7.0), you need to have `@vue/composition-api` installed:
|
To make `vue-echarts` work for _Vue 2_ (<2.7.0), you need to have `@vue/composition-api` installed (`@vue/runtime-core` for TypeScript support):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i @vue/composition-api
|
npm i @vue/composition-api
|
||||||
|
npm i @vue/runtime-core # for TypeScript support
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using _NuxtJS_ on top of _Vue 2_, you'll also need `@nuxtjs/composition-api`:
|
If you are using _NuxtJS_ on top of _Vue 2_, you'll need `@nuxtjs/composition-api`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i @nuxtjs/composition-api
|
npm i @nuxtjs/composition-api
|
||||||
@ -235,9 +236,9 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
|
|||||||
|
|
||||||
<!-- vue3Scripts:start -->
|
<!-- vue3Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.7"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.23"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -255,9 +256,9 @@ app.component('v-chart', VueECharts)
|
|||||||
|
|
||||||
<!-- vue2Scripts:start -->
|
<!-- vue2Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.15"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -318,6 +319,78 @@ See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/src/dem
|
|||||||
|
|
||||||
For performance critical scenarios (having a large dataset) we'd better bypass Vue's reactivity system for `option` prop. By specifying `manual-update` prop with `true` and not providing `option` prop, the dataset won't be watched any more. After doing so, you need to retrieve the component instance with `ref` and manually call `setOption` method to update the chart.
|
For performance critical scenarios (having a large dataset) we'd better bypass Vue's reactivity system for `option` prop. By specifying `manual-update` prop with `true` and not providing `option` prop, the dataset won't be watched any more. After doing so, you need to retrieve the component instance with `ref` and manually call `setOption` method to update the chart.
|
||||||
|
|
||||||
|
### Events
|
||||||
|
|
||||||
|
You can bind events with Vue's `v-on` directive.
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<v-chart :option="option" @highlight="handleHighlight" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
>
|
||||||
|
> Only the `.once` event modifier is supported as other modifiers are tightly coupled with the DOM event system.
|
||||||
|
|
||||||
|
Vue-ECharts support the following events:
|
||||||
|
|
||||||
|
- `highlight` [→](https://echarts.apache.org/en/api.html#events.highlight)
|
||||||
|
- `downplay` [→](https://echarts.apache.org/en/api.html#events.downplay)
|
||||||
|
- `selectchanged` [→](https://echarts.apache.org/en/api.html#events.selectchanged)
|
||||||
|
- `legendselectchanged` [→](https://echarts.apache.org/en/api.html#events.legendselectchanged)
|
||||||
|
- `legendselected` [→](https://echarts.apache.org/en/api.html#events.legendselected)
|
||||||
|
- `legendunselected` [→](https://echarts.apache.org/en/api.html#events.legendunselected)
|
||||||
|
- `legendselectall` [→](https://echarts.apache.org/en/api.html#events.legendselectall)
|
||||||
|
- `legendinverseselect` [→](https://echarts.apache.org/en/api.html#events.legendinverseselect)
|
||||||
|
- `legendscroll` [→](https://echarts.apache.org/en/api.html#events.legendscroll)
|
||||||
|
- `datazoom` [→](https://echarts.apache.org/en/api.html#events.datazoom)
|
||||||
|
- `datarangeselected` [→](https://echarts.apache.org/en/api.html#events.datarangeselected)
|
||||||
|
- `timelinechanged` [→](https://echarts.apache.org/en/api.html#events.timelinechanged)
|
||||||
|
- `timelineplaychanged` [→](https://echarts.apache.org/en/api.html#events.timelineplaychanged)
|
||||||
|
- `restore` [→](https://echarts.apache.org/en/api.html#events.restore)
|
||||||
|
- `dataviewchanged` [→](https://echarts.apache.org/en/api.html#events.dataviewchanged)
|
||||||
|
- `magictypechanged` [→](https://echarts.apache.org/en/api.html#events.magictypechanged)
|
||||||
|
- `geoselectchanged` [→](https://echarts.apache.org/en/api.html#events.geoselectchanged)
|
||||||
|
- `geoselected` [→](https://echarts.apache.org/en/api.html#events.geoselected)
|
||||||
|
- `geounselected` [→](https://echarts.apache.org/en/api.html#events.geounselected)
|
||||||
|
- `axisareaselected` [→](https://echarts.apache.org/en/api.html#events.axisareaselected)
|
||||||
|
- `brush` [→](https://echarts.apache.org/en/api.html#events.brush)
|
||||||
|
- `brushEnd` [→](https://echarts.apache.org/en/api.html#events.brushEnd)
|
||||||
|
- `brushselected` [→](https://echarts.apache.org/en/api.html#events.brushselected)
|
||||||
|
- `globalcursortaken` [→](https://echarts.apache.org/en/api.html#events.globalcursortaken)
|
||||||
|
- `rendered` [→](https://echarts.apache.org/en/api.html#events.rendered)
|
||||||
|
- `finished` [→](https://echarts.apache.org/en/api.html#events.finished)
|
||||||
|
- Mouse events
|
||||||
|
- `click` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.click)
|
||||||
|
- `dblclick` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.dblclick)
|
||||||
|
- `mouseover` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseover)
|
||||||
|
- `mouseout` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseout)
|
||||||
|
- `mousemove` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mousemove)
|
||||||
|
- `mousedown` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mousedown)
|
||||||
|
- `mouseup` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseup)
|
||||||
|
- `globalout` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.globalout)
|
||||||
|
- `contextmenu` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.contextmenu)
|
||||||
|
- ZRender events
|
||||||
|
- `zr:click`
|
||||||
|
- `zr:mousedown`
|
||||||
|
- `zr:mouseup`
|
||||||
|
- `zr:mousewheel`
|
||||||
|
- `zr:dblclick`
|
||||||
|
- `zr:contextmenu`
|
||||||
|
|
||||||
|
See supported events [here →](https://echarts.apache.org/en/api.html#events)
|
||||||
|
|
||||||
|
#### Native DOM Events
|
||||||
|
|
||||||
|
As Vue-ECharts binds events to the ECharts instance by default, there is some caveat when using native DOM events. You need to prefix the event name with `native:` to bind native DOM events (or you can use the `.native` modifier in Vue 2, which is dropped in Vue 3).
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<v-chart @native:click="handleClick" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
### Provide / Inject
|
### Provide / Inject
|
||||||
|
|
||||||
Vue-ECharts provides provide/inject API for `theme`, `init-options`, `update-options` and `loading-options` to help configuring contextual options. eg. for `init-options` you can use the provide API like this:
|
Vue-ECharts provides provide/inject API for `theme`, `init-options`, `update-options` and `loading-options` to help configuring contextual options. eg. for `init-options` you can use the provide API like this:
|
||||||
@ -401,68 +474,6 @@ import { THEME_KEY } from 'vue-echarts'
|
|||||||
|
|
||||||
Static methods can be accessed from [`echarts` itself](https://echarts.apache.org/en/api.html#echarts).
|
Static methods can be accessed from [`echarts` itself](https://echarts.apache.org/en/api.html#echarts).
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
You can bind events with Vue's `v-on` directive.
|
|
||||||
|
|
||||||
```vue
|
|
||||||
<template>
|
|
||||||
<v-chart :option="option" @highlight="handleHighlight" />
|
|
||||||
</template>
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
>
|
|
||||||
> Only the `.once` event modifier is supported as other modifiers are tightly coupled with the DOM event system.
|
|
||||||
|
|
||||||
Vue-ECharts support the following events:
|
|
||||||
|
|
||||||
- `highlight` [→](https://echarts.apache.org/en/api.html#events.highlight)
|
|
||||||
- `downplay` [→](https://echarts.apache.org/en/api.html#events.downplay)
|
|
||||||
- `selectchanged` [→](https://echarts.apache.org/en/api.html#events.selectchanged)
|
|
||||||
- `legendselectchanged` [→](https://echarts.apache.org/en/api.html#events.legendselectchanged)
|
|
||||||
- `legendselected` [→](https://echarts.apache.org/en/api.html#events.legendselected)
|
|
||||||
- `legendunselected` [→](https://echarts.apache.org/en/api.html#events.legendunselected)
|
|
||||||
- `legendselectall` [→](https://echarts.apache.org/en/api.html#events.legendselectall)
|
|
||||||
- `legendinverseselect` [→](https://echarts.apache.org/en/api.html#events.legendinverseselect)
|
|
||||||
- `legendscroll` [→](https://echarts.apache.org/en/api.html#events.legendscroll)
|
|
||||||
- `datazoom` [→](https://echarts.apache.org/en/api.html#events.datazoom)
|
|
||||||
- `datarangeselected` [→](https://echarts.apache.org/en/api.html#events.datarangeselected)
|
|
||||||
- `timelinechanged` [→](https://echarts.apache.org/en/api.html#events.timelinechanged)
|
|
||||||
- `timelineplaychanged` [→](https://echarts.apache.org/en/api.html#events.timelineplaychanged)
|
|
||||||
- `restore` [→](https://echarts.apache.org/en/api.html#events.restore)
|
|
||||||
- `dataviewchanged` [→](https://echarts.apache.org/en/api.html#events.dataviewchanged)
|
|
||||||
- `magictypechanged` [→](https://echarts.apache.org/en/api.html#events.magictypechanged)
|
|
||||||
- `geoselectchanged` [→](https://echarts.apache.org/en/api.html#events.geoselectchanged)
|
|
||||||
- `geoselected` [→](https://echarts.apache.org/en/api.html#events.geoselected)
|
|
||||||
- `geounselected` [→](https://echarts.apache.org/en/api.html#events.geounselected)
|
|
||||||
- `axisareaselected` [→](https://echarts.apache.org/en/api.html#events.axisareaselected)
|
|
||||||
- `brush` [→](https://echarts.apache.org/en/api.html#events.brush)
|
|
||||||
- `brushEnd` [→](https://echarts.apache.org/en/api.html#events.brushEnd)
|
|
||||||
- `brushselected` [→](https://echarts.apache.org/en/api.html#events.brushselected)
|
|
||||||
- `globalcursortaken` [→](https://echarts.apache.org/en/api.html#events.globalcursortaken)
|
|
||||||
- `rendered` [→](https://echarts.apache.org/en/api.html#events.rendered)
|
|
||||||
- `finished` [→](https://echarts.apache.org/en/api.html#events.finished)
|
|
||||||
- Mouse events
|
|
||||||
- `click` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.click)
|
|
||||||
- `dblclick` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.dblclick)
|
|
||||||
- `mouseover` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseover)
|
|
||||||
- `mouseout` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseout)
|
|
||||||
- `mousemove` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mousemove)
|
|
||||||
- `mousedown` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mousedown)
|
|
||||||
- `mouseup` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseup)
|
|
||||||
- `globalout` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.globalout)
|
|
||||||
- `contextmenu` [→](https://echarts.apache.org/en/api.html#events.Mouse%20events.contextmenu)
|
|
||||||
- ZRender events
|
|
||||||
- `zr:click`
|
|
||||||
- `zr:mousedown`
|
|
||||||
- `zr:mouseup`
|
|
||||||
- `zr:mousewheel`
|
|
||||||
- `zr:dblclick`
|
|
||||||
- `zr:contextmenu`
|
|
||||||
|
|
||||||
See supported events [here →](https://echarts.apache.org/en/api.html#events)
|
|
||||||
|
|
||||||
## CSP: `style-src` or `style-src-elem`
|
## CSP: `style-src` or `style-src-elem`
|
||||||
|
|
||||||
If you are applying a CSP to prevent inline `<style>` injection, you need to use files from `dist/csp` directory and include `dist/csp/style.css` into your app manually.
|
If you are applying a CSP to prevent inline `<style>` injection, you need to use files from `dist/csp` directory and include `dist/csp/style.css` into your app manually.
|
||||||
@ -475,7 +486,7 @@ The following breaking changes are introduced in `vue-echarts@6`:
|
|||||||
|
|
||||||
### Vue 2 support
|
### Vue 2 support
|
||||||
|
|
||||||
- If you are using version prior to `vue@2.7.0`, `@vue/composition-api` is required to be installed to use Vue-ECharts with Vue 2.
|
- If you are using version prior to `vue@2.7.0`, `@vue/composition-api` is required to be installed to use Vue-ECharts with Vue 2 (and also `@vue/runtime-core` for TypeScript support).
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
|
||||||
@ -500,9 +511,13 @@ The following breaking changes are introduced in `vue-echarts@6`:
|
|||||||
|
|
||||||
## Local development
|
## Local development
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm serve
|
pnpm serve
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:8080` to see the demo.
|
Open `http://localhost:8080` to see the demo.
|
||||||
|
|
||||||
|
## Notice
|
||||||
|
|
||||||
|
The Apache Software Foundation [Apache ECharts, ECharts](https://echarts.apache.org/), Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the [Apache Software Foundation](https://www.apache.org/).
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<h1 align="center">Vue-ECharts</h1>
|
<h1 align="center">Vue-ECharts</h1>
|
||||||
|
|
||||||
<p align="center">Apache ECharts <sup>(v5)</sup> 的 Vue.js <sup>(v2/v3)</sup> 组件。</p>
|
<p align="center">Apache ECharts™ <sup>(v5)</sup> 的 Vue.js <sup>(v2/v3)</sup> 组件。</p>
|
||||||
<p align="center"><a href="https://vue-echarts.dev/">查看 Demo →</a></p>
|
<p align="center"><a href="https://vue-echarts.dev/">查看 Demo →</a></p>
|
||||||
<p align="center"><a href="https:///pr.new/ecomfe/vue-echarts"><img alt="Open in Codeflow" src="https://developer.stackblitz.com/img/open_in_codeflow.svg" height="28"/></a> <a href="https://codesandbox.io/p/github/ecomfe/vue-echarts"><img alt="Edit in CodeSandbox" src="https://assets.codesandbox.io/github/button-edit-lime.svg" height="28"/></a></p>
|
<p align="center"><a href="https:///pr.new/ecomfe/vue-echarts"><img alt="Open in Codeflow" src="https://developer.stackblitz.com/img/open_in_codeflow.svg" height="28"/></a> <a href="https://codesandbox.io/p/github/ecomfe/vue-echarts"><img alt="Edit in CodeSandbox" src="https://assets.codesandbox.io/github/button-edit-lime.svg" height="28"/></a></p>
|
||||||
|
|
||||||
@ -23,17 +23,18 @@
|
|||||||
|
|
||||||
### npm & ESM
|
### npm & ESM
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
npm install echarts vue-echarts
|
npm i echarts vue-echarts
|
||||||
```
|
```
|
||||||
|
|
||||||
要在 _Vue 2_(<2.7.0)下使用 `vue-echarts`,需要确保 `@vue/composition-api` 已经安装:
|
要在 _Vue 2_(<2.7.0)下使用 `vue-echarts`,需要确保 `@vue/composition-api` 已经安装(TypeScript 支持还需要 `@vue/runtime-core`):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i @vue/composition-api
|
npm i @vue/composition-api
|
||||||
|
npm i @vue/runtime-core # TypeScript 支持
|
||||||
```
|
```
|
||||||
|
|
||||||
如果你在使用基于 _Vue 2_ 的 _NuxtJS_,那么还需要安装 `@nuxtjs/composition-api`:
|
如果你在使用基于 _Vue 2_ 的 _NuxtJS_,则需要安装 `@nuxtjs/composition-api`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i @nuxtjs/composition-api
|
npm i @nuxtjs/composition-api
|
||||||
@ -235,9 +236,9 @@ import "echarts";
|
|||||||
|
|
||||||
<!-- vue3Scripts:start -->
|
<!-- vue3Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.7"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.23"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -255,9 +256,9 @@ app.component('v-chart', VueECharts)
|
|||||||
|
|
||||||
<!-- vue2Scripts:start -->
|
<!-- vue2Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.15"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -380,6 +381,16 @@ Vue-ECharts 支持如下事件:
|
|||||||
|
|
||||||
请参考支持的事件列表。[前往 →](https://echarts.apache.org/zh/api.html#events)
|
请参考支持的事件列表。[前往 →](https://echarts.apache.org/zh/api.html#events)
|
||||||
|
|
||||||
|
#### 原生 DOM 事件
|
||||||
|
|
||||||
|
由于 Vue-ECharts 默认将事件绑定到 ECharts 实例,因此在使用原生 DOM 事件时需要做一些特殊处理。你需要在事件名称前加上 `native:` 前缀来绑定原生 DOM 事件(可以在 Vue 2 中也可以使用 `.native` 修饰符,但这在 Vue 3 中已被废弃)。
|
||||||
|
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<v-chart @native:click="handleClick" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
|
|
||||||
### Provide / Inject
|
### Provide / Inject
|
||||||
|
|
||||||
Vue-ECharts 为 `theme`、`init-options`、`update-options` 和 `loading-options` 提供了 provide/inject API,以通过上下文配置选项。例如:可以通过如下方式来使用 provide API 为 `init-options` 提供上下文配置:
|
Vue-ECharts 为 `theme`、`init-options`、`update-options` 和 `loading-options` 提供了 provide/inject API,以通过上下文配置选项。例如:可以通过如下方式来使用 provide API 为 `init-options` 提供上下文配置:
|
||||||
@ -463,6 +474,8 @@ import { THEME_KEY } from 'vue-echarts'
|
|||||||
|
|
||||||
静态方法请直接通过 [`echarts` 本身](https://echarts.apache.org/zh/api.html#echarts)进行调用。
|
静态方法请直接通过 [`echarts` 本身](https://echarts.apache.org/zh/api.html#echarts)进行调用。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## CSP: `style-src` 或 `style-src-elem`
|
## CSP: `style-src` 或 `style-src-elem`
|
||||||
|
|
||||||
如果你正在应用 CSP 来防止内联 `<style>` 注入,则需要使用 `dist/csp` 目录中的文件,并手动引入 `dist/csp/style.css`。
|
如果你正在应用 CSP 来防止内联 `<style>` 注入,则需要使用 `dist/csp` 目录中的文件,并手动引入 `dist/csp/style.css`。
|
||||||
@ -475,7 +488,7 @@ import { THEME_KEY } from 'vue-echarts'
|
|||||||
|
|
||||||
### Vue 2 支持
|
### Vue 2 支持
|
||||||
|
|
||||||
- 要在 `vue@2.7.0` 之前的版本中使用 Vue-ECharts,必须安装 `@vue/composition-api`。
|
- 要在 `vue@2.7.0` 之前的版本中使用 Vue-ECharts,必须安装 `@vue/composition-api`(还需要安装 `@vue/runtime-core` 来支持 TypeScript)。
|
||||||
|
|
||||||
### Prop
|
### Prop
|
||||||
|
|
||||||
@ -500,9 +513,13 @@ import { THEME_KEY } from 'vue-echarts'
|
|||||||
|
|
||||||
## 本地开发
|
## 本地开发
|
||||||
|
|
||||||
```bash
|
```sh
|
||||||
pnpm i
|
pnpm i
|
||||||
pnpm serve
|
pnpm serve
|
||||||
```
|
```
|
||||||
|
|
||||||
打开 `http://localhost:8080` 来查看 demo。
|
打开 `http://localhost:8080` 来查看 demo。
|
||||||
|
|
||||||
|
## 声明
|
||||||
|
|
||||||
|
The Apache Software Foundation [Apache ECharts, ECharts](https://echarts.apache.org/), Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the [Apache Software Foundation](https://www.apache.org/).
|
||||||
|
|||||||
30
package.json
30
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-echarts",
|
"name": "vue-echarts",
|
||||||
"version": "6.6.3",
|
"version": "6.7.2",
|
||||||
"description": "Vue.js component for Apache ECharts.",
|
"description": "Vue.js component for Apache ECharts™.",
|
||||||
"author": "GU Yiling <justice360@gmail.com>",
|
"author": "GU Yiling <justice360@gmail.com>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
@ -26,35 +26,35 @@
|
|||||||
"vue-demi": "^0.13.11"
|
"vue-demi": "^0.13.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.23.2",
|
"@babel/core": "^7.24.4",
|
||||||
"@highlightjs/vue-plugin": "^2.1.0",
|
"@highlightjs/vue-plugin": "^2.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
"@rollup/plugin-replace": "^5.0.5",
|
"@rollup/plugin-replace": "^5.0.5",
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||||
"@typescript-eslint/parser": "^4.33.0",
|
"@typescript-eslint/parser": "^4.33.0",
|
||||||
"@vercel/analytics": "^1.1.1",
|
"@vercel/analytics": "^1.2.2",
|
||||||
"@vue/cli-plugin-babel": "^5.0.8",
|
"@vue/cli-plugin-babel": "^5.0.8",
|
||||||
"@vue/cli-plugin-eslint": "^5.0.8",
|
"@vue/cli-plugin-eslint": "^5.0.8",
|
||||||
"@vue/cli-plugin-typescript": "^5.0.8",
|
"@vue/cli-plugin-typescript": "^5.0.8",
|
||||||
"@vue/cli-service": "^5.0.8",
|
"@vue/cli-service": "^5.0.8",
|
||||||
"@vue/compiler-sfc": "^3.3.7",
|
"@vue/compiler-sfc": "^3.4.24",
|
||||||
"@vue/composition-api": "^1.7.2",
|
"@vue/composition-api": "^1.7.2",
|
||||||
"@vue/eslint-config-prettier": "^6.0.0",
|
"@vue/eslint-config-prettier": "^6.0.0",
|
||||||
"@vue/eslint-config-typescript": "^10.0.0",
|
"@vue/eslint-config-typescript": "^10.0.0",
|
||||||
"@vueuse/core": "^10.5.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"comment-mark": "^1.1.1",
|
"comment-mark": "^1.1.1",
|
||||||
"core-js": "^3.33.2",
|
"core-js": "^3.37.0",
|
||||||
"echarts": "^5.4.3",
|
"echarts": "^5.5.0",
|
||||||
"echarts-gl": "^2.0.9",
|
"echarts-gl": "^2.0.9",
|
||||||
"echarts-liquidfill": "^3.1.0",
|
"echarts-liquidfill": "^3.1.0",
|
||||||
"esbuild-wasm": "^0.19.2",
|
"esbuild-wasm": "^0.19.12",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-plugin-prettier": "^3.4.1",
|
"eslint-plugin-prettier": "^3.4.1",
|
||||||
"eslint-plugin-vue": "^8.7.1",
|
"eslint-plugin-vue": "^8.7.1",
|
||||||
"highlight.js": "^11.9.0",
|
"highlight.js": "^11.9.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"postcss": "^8.4.31",
|
"postcss": "^8.4.38",
|
||||||
"postcss-loader": "^5.3.0",
|
"postcss-loader": "^5.3.0",
|
||||||
"postcss-nested": "^5.0.6",
|
"postcss-nested": "^5.0.6",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
@ -67,12 +67,13 @@
|
|||||||
"rollup-plugin-ts": "^2.0.7",
|
"rollup-plugin-ts": "^2.0.7",
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
"typescript": "4.6.4",
|
"typescript": "4.6.4",
|
||||||
"vue": "^3.3.7",
|
"vue": "^3.4.24",
|
||||||
"vue2": "npm:vue@^2.7.15",
|
"vue2": "npm:vue@^2.7.16",
|
||||||
"webpack": "^5.89.0"
|
"webpack": "^5.91.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@vue/composition-api": "^1.0.5",
|
"@vue/composition-api": "^1.0.5",
|
||||||
|
"@vue/runtime-core": "^3.0.0",
|
||||||
"echarts": "^5.4.1",
|
"echarts": "^5.4.1",
|
||||||
"vue": "^2.6.12 || ^3.1.1"
|
"vue": "^2.6.12 || ^3.1.1"
|
||||||
},
|
},
|
||||||
@ -81,6 +82,9 @@
|
|||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@vue/composition-api": {
|
"@vue/composition-api": {
|
||||||
"optional": true
|
"optional": true
|
||||||
|
},
|
||||||
|
"@vue/runtime-core": {
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
||||||
|
|||||||
11125
pnpm-lock.yaml
generated
11125
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="">
|
<html lang="en-US">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||||
<link href="https://fonts.googleapis.com/css?family=Inter:300,500;display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Inter:300,500;display=swap" rel="stylesheet">
|
||||||
<title>Vue-ECharts: Vue.js component for Apache ECharts.</title>
|
<title>Vue-ECharts: Vue.js component for Apache ECharts™.</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<noscript>
|
<noscript>
|
||||||
|
|||||||
@ -9,6 +9,14 @@ const options = [
|
|||||||
file: "dist/index.vue2.d.ts",
|
file: "dist/index.vue2.d.ts",
|
||||||
format: "esm"
|
format: "esm"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "src/index.vue2_7.d.ts",
|
||||||
|
plugins: [dts()],
|
||||||
|
output: {
|
||||||
|
file: "dist/index.vue2_7.d.ts",
|
||||||
|
format: "esm"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,8 @@ function resolvePath(...parts) {
|
|||||||
const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
|
const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
|
||||||
|
|
||||||
const DEP_VERSIONS = {
|
const DEP_VERSIONS = {
|
||||||
"vue@3": "3.3.7",
|
"vue@3": "3.4.23",
|
||||||
"vue@2": "2.7.15",
|
"vue@2": "2.7.16",
|
||||||
echarts: "5.4.3",
|
echarts: "5.4.3",
|
||||||
[name]: version
|
[name]: version
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,6 +6,7 @@ const packageFile = path.resolve(__dirname, "../package.json");
|
|||||||
|
|
||||||
const typesPaths = {
|
const typesPaths = {
|
||||||
3: "dist/index.d.ts",
|
3: "dist/index.d.ts",
|
||||||
|
2.7: "dist/index.vue2_7.d.ts",
|
||||||
2: "dist/index.vue2.d.ts"
|
2: "dist/index.vue2.d.ts"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ if (!Vue || typeof Vue.version !== "string") {
|
|||||||
);
|
);
|
||||||
} else if (Vue.version.startsWith("3.")) {
|
} else if (Vue.version.startsWith("3.")) {
|
||||||
switchVersion(3);
|
switchVersion(3);
|
||||||
|
} else if (Vue.version.startsWith("2.7.")) {
|
||||||
|
switchVersion(2.7);
|
||||||
} else if (Vue.version.startsWith("2.")) {
|
} else if (Vue.version.startsWith("2.")) {
|
||||||
switchVersion(2);
|
switchVersion(2);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import {
|
|||||||
useLoading,
|
useLoading,
|
||||||
loadingProps
|
loadingProps
|
||||||
} from "./composables";
|
} from "./composables";
|
||||||
import { omitOn, unwrapInjected } from "./utils";
|
import { isOn, omitOn, unwrapInjected } from "./utils";
|
||||||
import { register, TAG_NAME, type EChartsElement } from "./wc";
|
import { register, TAG_NAME, type EChartsElement } from "./wc";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
@ -55,6 +55,8 @@ export const UPDATE_OPTIONS_KEY =
|
|||||||
"ecUpdateOptions" as unknown as InjectionKey<UpdateOptionsInjection>;
|
"ecUpdateOptions" as unknown as InjectionKey<UpdateOptionsInjection>;
|
||||||
export { LOADING_OPTIONS_KEY } from "./composables";
|
export { LOADING_OPTIONS_KEY } from "./composables";
|
||||||
|
|
||||||
|
const NATIVE_EVENT_RE = /(^&?~?!?)native:/;
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "echarts",
|
name: "echarts",
|
||||||
props: {
|
props: {
|
||||||
@ -95,9 +97,62 @@ export default defineComponent({
|
|||||||
() => props.updateOptions || unwrapInjected(defaultUpdateOptions, {})
|
() => props.updateOptions || unwrapInjected(defaultUpdateOptions, {})
|
||||||
);
|
);
|
||||||
const nonEventAttrs = computed(() => omitOn(attrs));
|
const nonEventAttrs = computed(() => omitOn(attrs));
|
||||||
|
const nativeListeners: Record<string, unknown> = {};
|
||||||
|
|
||||||
// @ts-expect-error listeners for Vue 2 compatibility
|
// @ts-expect-error listeners for Vue 2 compatibility
|
||||||
const listeners = getCurrentInstance().proxy.$listeners;
|
const listeners = getCurrentInstance().proxy.$listeners;
|
||||||
|
const realListeners: Record<string, any> = {};
|
||||||
|
|
||||||
|
if (!listeners) {
|
||||||
|
// This is for Vue 3.
|
||||||
|
// We are converting all `on<Event>` props to event listeners compatible with Vue 2
|
||||||
|
// and collect them into `realListeners` so that we can bind them to the chart instance
|
||||||
|
// later in the same way.
|
||||||
|
// For `onNative:<event>` props, we just strip the `Native:` part and collect them into
|
||||||
|
// `nativeListeners` so that we can bind them to the root element directly.
|
||||||
|
Object.keys(attrs)
|
||||||
|
.filter(key => isOn(key))
|
||||||
|
.forEach(key => {
|
||||||
|
// onClick -> c + lick
|
||||||
|
// onZr:click -> z + r:click
|
||||||
|
let event = key.charAt(2).toLowerCase() + key.slice(3);
|
||||||
|
|
||||||
|
// Collect native DOM events
|
||||||
|
if (event.indexOf("native:") === 0) {
|
||||||
|
// native:click -> onClick
|
||||||
|
const nativeKey = `on${event.charAt(7).toUpperCase()}${event.slice(
|
||||||
|
8
|
||||||
|
)}`;
|
||||||
|
|
||||||
|
nativeListeners[nativeKey] = attrs[key];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clickOnce -> ~click
|
||||||
|
// zr:clickOnce -> ~zr:click
|
||||||
|
if (event.substring(event.length - 4) === "Once") {
|
||||||
|
event = `~${event.substring(0, event.length - 4)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
realListeners[event] = attrs[key];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// This is for Vue 2.
|
||||||
|
// We just need to distinguish normal events and `native:<event>` events and
|
||||||
|
// collect them into `realListeners` and `nativeListeners` respectively.
|
||||||
|
// For `native:<event>` events, we just strip the `native:` part and collect them
|
||||||
|
// into `nativeListeners` so that we can bind them to the root element directly.
|
||||||
|
// native:click -> click
|
||||||
|
// ~native:click -> ~click
|
||||||
|
// &~!native:click -> &~!click
|
||||||
|
Object.keys(listeners).forEach(key => {
|
||||||
|
if (NATIVE_EVENT_RE.test(key)) {
|
||||||
|
nativeListeners[key.replace(NATIVE_EVENT_RE, "$1")] = listeners[key];
|
||||||
|
} else {
|
||||||
|
realListeners[key] = listeners[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function init(option?: Option) {
|
function init(option?: Option) {
|
||||||
if (!inner.value) {
|
if (!inner.value) {
|
||||||
@ -114,27 +169,6 @@ export default defineComponent({
|
|||||||
instance.group = props.group;
|
instance.group = props.group;
|
||||||
}
|
}
|
||||||
|
|
||||||
let realListeners = listeners;
|
|
||||||
if (!realListeners) {
|
|
||||||
realListeners = {};
|
|
||||||
|
|
||||||
Object.keys(attrs)
|
|
||||||
.filter(key => key.indexOf("on") === 0 && key.length > 2)
|
|
||||||
.forEach(key => {
|
|
||||||
// onClick -> c + lick
|
|
||||||
// onZr:click -> z + r:click
|
|
||||||
let event = key.charAt(2).toLowerCase() + key.slice(3);
|
|
||||||
|
|
||||||
// clickOnce -> ~click
|
|
||||||
// zr:clickOnce -> ~zr:click
|
|
||||||
if (event.substring(event.length - 4) === "Once") {
|
|
||||||
event = `~${event.substring(0, event.length - 4)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
realListeners[event] = attrs[key];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys(realListeners).forEach(key => {
|
Object.keys(realListeners).forEach(key => {
|
||||||
let handler = realListeners[key];
|
let handler = realListeners[key];
|
||||||
|
|
||||||
@ -296,6 +330,7 @@ export default defineComponent({
|
|||||||
inner,
|
inner,
|
||||||
setOption,
|
setOption,
|
||||||
nonEventAttrs,
|
nonEventAttrs,
|
||||||
|
nativeListeners,
|
||||||
...publicApi
|
...publicApi
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -303,12 +338,14 @@ export default defineComponent({
|
|||||||
// Vue 3 and Vue 2 have different vnode props format:
|
// Vue 3 and Vue 2 have different vnode props format:
|
||||||
// See https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format
|
// See https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format
|
||||||
const attrs = (
|
const attrs = (
|
||||||
Vue2 ? { attrs: this.nonEventAttrs } : { ...this.nonEventAttrs }
|
Vue2
|
||||||
|
? { attrs: this.nonEventAttrs, on: this.nativeListeners }
|
||||||
|
: { ...this.nonEventAttrs, ...this.nativeListeners }
|
||||||
) as any;
|
) as any;
|
||||||
attrs.ref = "root";
|
attrs.ref = "root";
|
||||||
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
|
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
|
||||||
return h(TAG_NAME, attrs, [
|
return h(TAG_NAME, attrs, [
|
||||||
h("div", { ref: "inner", class: "echarts-inner" })
|
h("div", { ref: "inner", class: "vue-echarts-inner" })
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -76,7 +76,7 @@ const transformErrors = ref([]);
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await initialize({
|
await initialize({
|
||||||
wasmURL: "https://cdn.jsdelivr.net/npm/esbuild-wasm@0.19.2/esbuild.wasm"
|
wasmURL: "https://cdn.jsdelivr.net/npm/esbuild-wasm@0.19.12/esbuild.wasm"
|
||||||
});
|
});
|
||||||
|
|
||||||
initializing.value = false;
|
initializing.value = false;
|
||||||
@ -324,10 +324,6 @@ input[type="number"] {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 0 0 45px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 0 45px rgba(0, 0, 0, 0.2);
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.options {
|
.options {
|
||||||
|
|||||||
@ -56,12 +56,23 @@ watch(codeOpen, open => {
|
|||||||
<a href="https://github.com/ecomfe/vue-echarts">Vue-ECharts</a>
|
<a href="https://github.com/ecomfe/vue-echarts">Vue-ECharts</a>
|
||||||
</h1>
|
</h1>
|
||||||
<p class="desc">
|
<p class="desc">
|
||||||
Vue.js component for Apache ECharts. (<a
|
Vue.js component for Apache ECharts™. (<a
|
||||||
href="https://github.com/ecomfe/vue-echarts#readme"
|
href="https://github.com/ecomfe/vue-echarts#readme"
|
||||||
>docs</a
|
>docs</a
|
||||||
>)
|
>)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h2 class="sep">Examples</h2>
|
||||||
|
<p>
|
||||||
|
<small
|
||||||
|
>See
|
||||||
|
<a href="https://echarts.apache.org/examples/en/index.html"
|
||||||
|
>echarts.apache.org/examples</a
|
||||||
|
>
|
||||||
|
for all examples.</small
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
|
||||||
<bar-chart />
|
<bar-chart />
|
||||||
<pie-chart />
|
<pie-chart />
|
||||||
<polar-chart />
|
<polar-chart />
|
||||||
@ -132,6 +143,19 @@ body {
|
|||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
box-shadow: 0 1px 0 0 #42b983;
|
||||||
|
transition: box-shadow 0.2s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
box-shadow: 0 2px 0 0 #42b983;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3 {
|
||||||
|
color: #2c3e50;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
@ -139,13 +163,32 @@ h1 {
|
|||||||
font-family: Inter, "Helvetica Neue", Arial, sans-serif;
|
font-family: Inter, "Helvetica Neue", Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
|
||||||
h2 {
|
h2 {
|
||||||
color: #2c3e50;
|
margin-top: 1em;
|
||||||
font-weight: 400;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
.sep {
|
||||||
|
margin-top: 6em;
|
||||||
|
margin-bottom: 1.8em;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 1.25em;
|
||||||
|
color: #7f8c8d;
|
||||||
|
opacity: 0.6;
|
||||||
|
|
||||||
|
&::before,
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
width: 48px;
|
||||||
|
border-bottom: 1px dotted currentColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
margin-top: 2em;
|
margin-top: 2em;
|
||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
@ -208,15 +251,18 @@ footer {
|
|||||||
a {
|
a {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0 5px;
|
margin: 0 5px;
|
||||||
padding: 3px 0 6px;
|
|
||||||
color: #7f8c8d;
|
color: #7f8c8d;
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
text-decoration: none;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3 {
|
||||||
|
a,
|
||||||
a:hover {
|
a:hover {
|
||||||
padding-bottom: 3px;
|
text-decoration: none;
|
||||||
border-bottom: 3px solid #42b983;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,10 @@ export default {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
itemStyle: {
|
||||||
|
shadowBlur: 12,
|
||||||
|
shadowColor: "rgba(0, 0, 0, 0.25)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<h2 :id="id">
|
<h3 :id="id">
|
||||||
<a :href="`#${id}`">
|
<a :href="`#${id}`">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
<small v-if="desc">{{ desc }}</small>
|
<small v-if="desc">{{ desc }}</small>
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h3>
|
||||||
<section>
|
<section>
|
||||||
<figure class="fig hero" v-if="!split">
|
<figure class="fig hero" v-if="!split">
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
@ -3,7 +3,17 @@ import { createApp } from "vue";
|
|||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
import Demo from "./Demo.vue";
|
import Demo from "./Demo.vue";
|
||||||
|
|
||||||
inject();
|
const SAMPLE_RATE = 0.5;
|
||||||
|
|
||||||
|
inject({
|
||||||
|
beforeSend: event => {
|
||||||
|
if (Math.random() > SAMPLE_RATE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia();
|
||||||
const app = createApp(Demo);
|
const app = createApp(Demo);
|
||||||
|
|||||||
3
src/index.vue2.d.ts
vendored
3
src/index.vue2.d.ts
vendored
@ -1,5 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-types */
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
import type { Ref, DefineComponent } from "vue-demi";
|
import type { DefineComponent } from "@vue/runtime-core";
|
||||||
|
import type { Ref } from "vue-demi";
|
||||||
import type {
|
import type {
|
||||||
Option,
|
Option,
|
||||||
InitOptions,
|
InitOptions,
|
||||||
|
|||||||
63
src/index.vue2_7.d.ts
vendored
Normal file
63
src/index.vue2_7.d.ts
vendored
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
|
import type { Ref, DefineComponent } from "vue-demi";
|
||||||
|
import type {
|
||||||
|
Option,
|
||||||
|
InitOptions,
|
||||||
|
UpdateOptions,
|
||||||
|
EChartsType,
|
||||||
|
Emits
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
|
declare const LOADING_OPTIONS_KEY = "ecLoadingOptions";
|
||||||
|
declare const THEME_KEY = "ecTheme";
|
||||||
|
declare const INIT_OPTIONS_KEY = "ecInitOptions";
|
||||||
|
declare const UPDATE_OPTIONS_KEY = "ecUpdateOptions";
|
||||||
|
|
||||||
|
declare type ChartProps = {
|
||||||
|
loading?: boolean;
|
||||||
|
loadingOptions?: Record<string, unknown>;
|
||||||
|
autoresize?: boolean;
|
||||||
|
option?: Option;
|
||||||
|
theme?: string | Record<string, unknown>;
|
||||||
|
initOptions?: InitOptions;
|
||||||
|
updateOptions?: UpdateOptions;
|
||||||
|
group?: string;
|
||||||
|
manualUpdate?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type MethodNames =
|
||||||
|
| "getWidth"
|
||||||
|
| "getHeight"
|
||||||
|
| "getDom"
|
||||||
|
| "getOption"
|
||||||
|
| "resize"
|
||||||
|
| "dispatchAction"
|
||||||
|
| "convertToPixel"
|
||||||
|
| "convertFromPixel"
|
||||||
|
| "containPixel"
|
||||||
|
| "getDataURL"
|
||||||
|
| "getConnectedDataURL"
|
||||||
|
| "appendData"
|
||||||
|
| "clear"
|
||||||
|
| "isDisposed"
|
||||||
|
| "dispose"
|
||||||
|
| "setOption";
|
||||||
|
|
||||||
|
declare type ChartMethods = Pick<EChartsType, MethodNames>;
|
||||||
|
|
||||||
|
declare const Chart: DefineComponent<
|
||||||
|
ChartProps,
|
||||||
|
{
|
||||||
|
root: Ref<HTMLElement | undefined>;
|
||||||
|
chart: Ref<EChartsType | undefined>;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
ChartMethods,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
Emits
|
||||||
|
>;
|
||||||
|
|
||||||
|
export default Chart;
|
||||||
|
export { INIT_OPTIONS_KEY, LOADING_OPTIONS_KEY, THEME_KEY, UPDATE_OPTIONS_KEY };
|
||||||
@ -1 +1,2 @@
|
|||||||
x-vue-echart,.echarts-inner{display:block;width:100%;height:100%;min-width:0}
|
x-vue-echarts{display:block;position:relative;width:100%;height:100%;min-width:0}
|
||||||
|
.vue-echarts-inner{position:absolute!important;top:0;right:0;bottom:0;left:0}
|
||||||
|
|||||||
11
src/types.ts
11
src/types.ts
@ -1,10 +1,5 @@
|
|||||||
import { init } from "echarts/core";
|
import { init } from "echarts/core";
|
||||||
import type {
|
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts";
|
||||||
SetOptionOpts,
|
|
||||||
ECElementEvent,
|
|
||||||
ElementEvent,
|
|
||||||
EChartsOption
|
|
||||||
} from "echarts";
|
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
|
|
||||||
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
|
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
|
||||||
@ -23,7 +18,9 @@ export type UpdateOptionsInjection = Injection<UpdateOptions>;
|
|||||||
export type EChartsType = ReturnType<InitType>;
|
export type EChartsType = ReturnType<InitType>;
|
||||||
type ZRenderType = ReturnType<EChartsType["getZr"]>;
|
type ZRenderType = ReturnType<EChartsType["getZr"]>;
|
||||||
export type EventTarget = EChartsType | ZRenderType;
|
export type EventTarget = EChartsType | ZRenderType;
|
||||||
export type Option = EChartsOption;
|
|
||||||
|
type SetOptionType = EChartsType["setOption"];
|
||||||
|
export type Option = Parameters<SetOptionType>[0];
|
||||||
|
|
||||||
export type LoadingOptions = {
|
export type LoadingOptions = {
|
||||||
text?: string;
|
text?: string;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { unref } from "vue-demi";
|
import { unref, isRef } from "vue-demi";
|
||||||
import type { Injection } from "./types";
|
import type { Injection } from "./types";
|
||||||
|
|
||||||
type Attrs = {
|
type Attrs = {
|
||||||
@ -26,7 +26,7 @@ export function unwrapInjected<T, V>(
|
|||||||
injection: Injection<T>,
|
injection: Injection<T>,
|
||||||
defaultValue: V
|
defaultValue: V
|
||||||
): T | V {
|
): T | V {
|
||||||
const value = unref(injection);
|
const value = isRef(injection) ? unref(injection) : injection;
|
||||||
|
|
||||||
if (value && typeof value === "object" && "value" in value) {
|
if (value && typeof value === "object" && "value" in value) {
|
||||||
return value.value || defaultValue;
|
return value.value || defaultValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user