mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-05 20:36:09 +08:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 712b4219f1 | |||
| ad2b40d750 | |||
| c2235a0084 | |||
| b44de6fc11 | |||
| b906cadca1 | |||
| fb76fb6762 | |||
| d3703840b0 | |||
| 7b9e467c6b | |||
| 1b0ab9b319 | |||
| dc0da13c1d | |||
| 0687dbf892 | |||
| ca8dda363d | |||
| 842e013663 | |||
| ad0e17ad9e |
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@ -20,9 +20,9 @@ jobs:
|
|||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 24
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@ -53,3 +53,6 @@ jobs:
|
|||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
files: coverage/browser/lcov.info
|
files: coverage/browser/lcov.info
|
||||||
disable_search: true
|
disable_search: true
|
||||||
|
|
||||||
|
- name: Publish the commit
|
||||||
|
run: pnpm dlx pkg-pr-new publish --compact
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -22,9 +22,9 @@ jobs:
|
|||||||
uses: pnpm/action-setup@v4
|
uses: pnpm/action-setup@v4
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 24
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
34
README.md
34
README.md
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
> Still using Vue 2? Read v7 docs [here →](https://github.com/ecomfe/vue-echarts/tree/7.x)
|
> Still using Vue 2? Read v7 docs [here →](https://github.com/ecomfe/vue-echarts/tree/7.x)
|
||||||
|
|
||||||
## Installation & Usage
|
## Installation & usage
|
||||||
|
|
||||||
### npm
|
### npm
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ npm install echarts vue-echarts
|
|||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
<details>
|
<details open>
|
||||||
<summary><a href="https://stackblitz.com/edit/vue-echarts-8?file=src%2FApp.vue">Demo →</a></summary>
|
<summary><a href="https://stackblitz.com/edit/vue-echarts-8?file=src%2FApp.vue">Demo →</a></summary>
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
@ -94,12 +94,17 @@ const option = ref({
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!IMPORTANT]
|
#### On-demand importing <sup><a href="#on-demand-importing"><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></a></sup>
|
||||||
> We encourage manually importing components and charts from ECharts for smaller bundle size. We've built an [import code generator](https://vue-echarts.dev/#codegen) to help you with that. You can just paste in your `option` code and we'll generate the precise import code for you.
|
|
||||||
>
|
To keep your bundle size small, we recommend manually importing the components and charts you need from ECharts. To make this easier, we’ve created an [import code generator](https://vue-echarts.dev/#codegen). Simply paste your `option` code into the tool, and it will generate the exact import statements for you.
|
||||||
> 
|
|
||||||
>
|
<picture>
|
||||||
> [Try it →](https://vue-echarts.dev/#codegen)
|
<source media="(prefers-color-scheme: dark)" srcset="assets/codegen-dark.webp">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="assets/codegen-light.webp">
|
||||||
|
<img alt="A modal for generating ECharts import code. The left panel shows a chart configuration in JSON, while the right panel displays TypeScript import statements for ECharts charts and components." src="assets/codegen-light.webp">
|
||||||
|
</picture>
|
||||||
|
|
||||||
|
[Try it →](https://vue-echarts.dev/#codegen)
|
||||||
|
|
||||||
But if you really want to import the whole ECharts bundle without having to import modules manually, just add this in your code:
|
But if you really want to import the whole ECharts bundle without having to import modules manually, just add this in your code:
|
||||||
|
|
||||||
@ -153,7 +158,8 @@ See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/demo).
|
|||||||
|
|
||||||
ECharts' universal interface. Modifying this prop triggers Vue ECharts to compute an update plan and call `setOption`. Read more [here →](https://echarts.apache.org/en/option.html)
|
ECharts' universal interface. Modifying this prop triggers Vue ECharts to compute an update plan and call `setOption`. Read more [here →](https://echarts.apache.org/en/option.html)
|
||||||
|
|
||||||
#### Smart Update
|
#### Smart update
|
||||||
|
|
||||||
- If you supply `update-options` (via prop or injection), Vue ECharts forwards it directly to `setOption` and skips the planner.
|
- If you supply `update-options` (via prop or injection), Vue ECharts forwards it directly to `setOption` and skips the planner.
|
||||||
- Manual `setOption` calls (only available when `manual-update` is `true`) behave like native ECharts, honouring only the per-call override you pass in and are not carried across re-initializations.
|
- Manual `setOption` calls (only available when `manual-update` is `true`) behave like native ECharts, honouring only the per-call override you pass in and are not carried across re-initializations.
|
||||||
- Otherwise, Vue ECharts analyses the change: removed objects become `null`, removed arrays become `[]` with `replaceMerge`, ID/anonymous deletions trigger `replaceMerge`, and risky changes fall back to `notMerge: true`.
|
- Otherwise, Vue ECharts analyses the change: removed objects become `null`, removed arrays become `[]` with `replaceMerge`, ID/anonymous deletions trigger `replaceMerge`, and risky changes fall back to `notMerge: true`.
|
||||||
@ -247,7 +253,7 @@ Vue ECharts support the following events:
|
|||||||
|
|
||||||
See supported events in the [ECharts API reference →](https://echarts.apache.org/en/api.html#events)
|
See supported events in the [ECharts API reference →](https://echarts.apache.org/en/api.html#events)
|
||||||
|
|
||||||
#### Native DOM 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.
|
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.
|
||||||
|
|
||||||
@ -257,7 +263,7 @@ As Vue ECharts binds events to the ECharts instance by default, there is some ca
|
|||||||
</template>
|
</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 `theme` 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 `theme` you can use the provide API like this:
|
||||||
|
|
||||||
@ -335,11 +341,11 @@ export default {
|
|||||||
> - [`showLoading`](https://echarts.apache.org/en/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/en/api.html#echartsInstance.hideLoading): use the `loading` and `loading-options` props instead.
|
> - [`showLoading`](https://echarts.apache.org/en/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/en/api.html#echartsInstance.hideLoading): use the `loading` and `loading-options` props instead.
|
||||||
> - [`setTheme`](https://echarts.apache.org/en/api.html#echartsInstance.setTheme): use the `theme` prop instead.
|
> - [`setTheme`](https://echarts.apache.org/en/api.html#echartsInstance.setTheme): use the `theme` prop instead.
|
||||||
|
|
||||||
### Slots
|
### Slots <sup><a href="#slots"><img src="https://img.shields.io/badge/new-A855F7" alt="new" align="middle" height="16"></a></sup>
|
||||||
|
|
||||||
Vue ECharts allows you to define ECharts option's [`tooltip.formatter`](https://echarts.apache.org/en/option.html#tooltip.formatter) and [`toolbox.feature.dataView.optionToContent`](https://echarts.apache.org/en/option.html#toolbox.feature.dataView.optionToContent) callbacks via Vue slots instead of defining them in your `option` object. This simplifies custom HTMLElement rendering using familiar Vue templating.
|
Vue ECharts allows you to define ECharts option's [`tooltip.formatter`](https://echarts.apache.org/en/option.html#tooltip.formatter) and [`toolbox.feature.dataView.optionToContent`](https://echarts.apache.org/en/option.html#toolbox.feature.dataView.optionToContent) callbacks via Vue slots instead of defining them in your `option` object. This simplifies custom HTMLElement rendering using familiar Vue templating.
|
||||||
|
|
||||||
#### Slot Naming Convention
|
#### Slot naming convention
|
||||||
|
|
||||||
- Slot names begin with `tooltip`/`dataView`, followed by hyphen-separated path segments to the target.
|
- Slot names begin with `tooltip`/`dataView`, followed by hyphen-separated path segments to the target.
|
||||||
- Each segment corresponds to an `option` property name or an array index (for arrays, use the numeric index).
|
- Each segment corresponds to an `option` property name or an array index (for arrays, use the numeric index).
|
||||||
@ -405,7 +411,7 @@ The slot props correspond to the first parameter of the callback function.
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Slots take precedence over the corresponding callback defined in `props.option`.
|
> Slots take precedence over the corresponding callback defined in `props.option`.
|
||||||
|
|
||||||
### Static Methods
|
### Static methods
|
||||||
|
|
||||||
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).
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ npm install echarts vue-echarts
|
|||||||
|
|
||||||
#### 示例
|
#### 示例
|
||||||
|
|
||||||
<details>
|
<details open>
|
||||||
<summary><a href="https://stackblitz.com/edit/vue-echarts-8?file=src%2FApp.vue">Demo →</a></summary>
|
<summary><a href="https://stackblitz.com/edit/vue-echarts-8?file=src%2FApp.vue">Demo →</a></summary>
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
@ -94,12 +94,17 @@ const option = ref({
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
> [!IMPORTANT]
|
#### 按需导入 <sup><a href="#按需导入"><img src="https://img.shields.io/badge/%E6%8E%A8%E8%8D%90-10B981" alt="推荐" align="middle" height="16"></a></sup>
|
||||||
> 我们鼓励手动从 ECharts 中引入组件和图表,以减小打包体积。我们已经为此构建了一个[导入代码生成器](https://vue-echarts.dev/#codegen)。你只需要把`option` 代码粘贴进去,就可以得到精确的导入代码。
|
|
||||||
>
|
为了减小打包体积,我们建议手动从 ECharts 中导入所需的组件和图表。我们提供了一个[导入代码生成器](https://vue-echarts.dev/#codegen),可以帮你自动生成导入语句。只需将你的 `option` 代码粘贴进去,工具就会为你生成精确的导入代码。
|
||||||
> 
|
|
||||||
>
|
<picture>
|
||||||
> [试一试 →](https://vue-echarts.dev/#codegen)
|
<source media="(prefers-color-scheme: dark)" srcset="assets/codegen-dark.webp">
|
||||||
|
<source media="(prefers-color-scheme: light)" srcset="assets/codegen-light.webp">
|
||||||
|
<img alt="一个用于生成 ECharts 导入代码的弹窗。左侧面板展示图表的 JSON 配置,右侧面板展示对应的 TypeScript 导入语句。" src="assets/codegen-light.webp">
|
||||||
|
</picture>
|
||||||
|
|
||||||
|
[试一试 →](https://vue-echarts.dev/#codegen)
|
||||||
|
|
||||||
但如果你实在需要全量引入 ECharts 从而无需手动引入模块,只需要在代码中添加:
|
但如果你实在需要全量引入 ECharts 从而无需手动引入模块,只需要在代码中添加:
|
||||||
|
|
||||||
@ -335,7 +340,7 @@ export default {
|
|||||||
> - [`showLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.hideLoading):请使用 `loading` 和 `loading-options` prop。
|
> - [`showLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.showLoading) / [`hideLoading`](https://echarts.apache.org/zh/api.html#echartsInstance.hideLoading):请使用 `loading` 和 `loading-options` prop。
|
||||||
> - [`setTheme`](https://echarts.apache.org/zh/api.html#echartsInstance.setTheme):请使用 `theme` prop。
|
> - [`setTheme`](https://echarts.apache.org/zh/api.html#echartsInstance.setTheme):请使用 `theme` prop。
|
||||||
|
|
||||||
### 插槽(Slots)
|
### 插槽 <sup><a href="#插槽"><img src="https://img.shields.io/badge/%E6%96%B0%E5%8A%9F%E8%83%BD-A855F7" alt="新功能" align="middle" height="16"></a></sup>
|
||||||
|
|
||||||
Vue ECharts 允许你通过 Vue 插槽来定义 ECharts 配置中的 [`tooltip.formatter`](https://echarts.apache.org/zh/option.html#tooltip.formatter) 和 [`toolbox.feature.dataView.optionToContent`](https://echarts.apache.org/zh/option.html#toolbox.feature.dataView.optionToContent) 回调,而无需在 `option` 对象中定义它们。你可以使用熟悉的 Vue 模板语法来编写自定义提示框或数据视图中的内容。
|
Vue ECharts 允许你通过 Vue 插槽来定义 ECharts 配置中的 [`tooltip.formatter`](https://echarts.apache.org/zh/option.html#tooltip.formatter) 和 [`toolbox.feature.dataView.optionToContent`](https://echarts.apache.org/zh/option.html#toolbox.feature.dataView.optionToContent) 回调,而无需在 `option` 对象中定义它们。你可以使用熟悉的 Vue 模板语法来编写自定义提示框或数据视图中的内容。
|
||||||
|
|
||||||
|
|||||||
BIN
assets/codegen-dark.webp
Normal file
BIN
assets/codegen-dark.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 139 KiB |
BIN
assets/codegen-light.webp
Normal file
BIN
assets/codegen-light.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
@ -26,7 +26,7 @@
|
|||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"test:watch": "vitest watch"
|
"test:watch": "vitest watch"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.18.0",
|
"packageManager": "pnpm@10.19.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"unpkg": "dist/index.min.js",
|
"unpkg": "dist/index.min.js",
|
||||||
@ -44,7 +44,7 @@
|
|||||||
"vue": "^3.3.0"
|
"vue": "^3.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.17.1",
|
"@types/node": "^24.0.0",
|
||||||
"@typescript-eslint/utils": "^8.39.1",
|
"@typescript-eslint/utils": "^8.39.1",
|
||||||
"@vercel/analytics": "^1.5.0",
|
"@vercel/analytics": "^1.5.0",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
@ -53,7 +53,7 @@
|
|||||||
"@vue/eslint-config-prettier": "^10.2.0",
|
"@vue/eslint-config-prettier": "^10.2.0",
|
||||||
"@vue/eslint-config-typescript": "^14.6.0",
|
"@vue/eslint-config-typescript": "^14.6.0",
|
||||||
"@vue/tsconfig": "^0.8.0",
|
"@vue/tsconfig": "^0.8.0",
|
||||||
"@vueuse/core": "^13.6.0",
|
"@vueuse/core": "^14.0.0",
|
||||||
"bumpp": "^10.2.3",
|
"bumpp": "^10.2.3",
|
||||||
"comment-mark": "^2.0.1",
|
"comment-mark": "^2.0.1",
|
||||||
"echarts": "^6.0.0",
|
"echarts": "^6.0.0",
|
||||||
@ -61,7 +61,7 @@
|
|||||||
"eslint": "^9.33.0",
|
"eslint": "^9.33.0",
|
||||||
"eslint-plugin-vue": "^10.4.0",
|
"eslint-plugin-vue": "^10.4.0",
|
||||||
"jiti": "^2.5.1",
|
"jiti": "^2.5.1",
|
||||||
"monaco-editor": "^0.53.0",
|
"monaco-editor": "^0.54.0",
|
||||||
"pinia": "^3.0.3",
|
"pinia": "^3.0.3",
|
||||||
"playwright": "^1.55.0",
|
"playwright": "^1.55.0",
|
||||||
"postcss-nested": "^7.0.2",
|
"postcss-nested": "^7.0.2",
|
||||||
|
|||||||
1002
pnpm-lock.yaml
generated
1002
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||||
"extends": ["config:recommended"],
|
"extends": ["config:recommended", "schedule:weekly"],
|
||||||
"timezone": "Asia/Shanghai",
|
|
||||||
"schedule": ["* 8 * * 1"],
|
|
||||||
"minimumReleaseAge": "7 days",
|
"minimumReleaseAge": "7 days",
|
||||||
"internalChecksFilter": "strict",
|
"internalChecksFilter": "strict",
|
||||||
"packageRules": [
|
"packageRules": [
|
||||||
|
|||||||
Reference in New Issue
Block a user