mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-05 20:36:09 +08:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7852ab643 | |||
| 1378f6e397 | |||
| ec2c15c153 | |||
| beec26367f | |||
| b366b31afb | |||
| 4f3a6ac0a3 | |||
| e967bfc1fe | |||
| a9c54e1dc5 | |||
| d941e35a61 | |||
| 3c063ed21e | |||
| c0b0d2d0be | |||
| 2d310a3891 | |||
| 9fe76efa93 | |||
| 24ed18e439 | |||
| 6b98318504 | |||
| 27c79b9012 | |||
| 861674352b | |||
| fc53aee8a7 | |||
| da0109b07a | |||
| 7e5c06225c | |||
| 3c7ff95331 | |||
| d774558f3e | |||
| 5d23006866 | |||
| 443eaa0367 | |||
| 16f3f4b419 |
25
.eslintrc.js
25
.eslintrc.js
@ -1,25 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
env: {
|
|
||||||
node: true
|
|
||||||
},
|
|
||||||
extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"],
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
parser: "@typescript-eslint/parser"
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
||||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
|
||||||
"vue/multi-word-component-names": "off"
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ["*.ts"],
|
|
||||||
extends: [
|
|
||||||
"@vue/typescript/recommended",
|
|
||||||
"@vue/prettier/@typescript-eslint"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
20
.eslintrc.json
Normal file
20
.eslintrc.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"env": {
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"plugin:vue/vue3-essential",
|
||||||
|
"eslint:recommended",
|
||||||
|
"@vue/eslint-config-typescript",
|
||||||
|
"@vue/eslint-config-prettier/skip-formatting"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
"parser": "@typescript-eslint/parser"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-console": "off",
|
||||||
|
"vue/multi-word-component-names": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
CHANGELOG.md
38
CHANGELOG.md
@ -1,3 +1,41 @@
|
|||||||
|
## 7.0.3
|
||||||
|
|
||||||
|
* Fixed type for `autoresize` (again).
|
||||||
|
|
||||||
|
## 7.0.2
|
||||||
|
|
||||||
|
* Fixed style injection regression (#805).
|
||||||
|
|
||||||
|
## 7.0.1
|
||||||
|
|
||||||
|
* Fixed type for `autoresize`.
|
||||||
|
|
||||||
|
## 7.0.0
|
||||||
|
|
||||||
|
> Other prerelease changes:
|
||||||
|
> * [7.0.0-beta.0](#700-beta0)
|
||||||
|
|
||||||
|
* Fixed types for events.
|
||||||
|
|
||||||
|
## 7.0.0-beta.0
|
||||||
|
|
||||||
|
* Upgraded to ESM.
|
||||||
|
* Removed the `postinstall` script.
|
||||||
|
* API remains the same.
|
||||||
|
|
||||||
|
### Breaking changes
|
||||||
|
|
||||||
|
* Peer deps for `echarts` is upgraded to `^5.5.1`.
|
||||||
|
* Dropped support for browsers without `ResizeObserver`. Can work with [resize-observer-polyfill](https://www.npmjs.com/package/resize-observer-polyfill).
|
||||||
|
* Dropped support for Vue < 2.7.
|
||||||
|
* Dropped CJS outputs.
|
||||||
|
* Dropped extra wrapper element so that you should no longer set `padding` on the component root.
|
||||||
|
* For strict CSP usage, `vue-echarts/csp` should now be used as the entry point and `vue-echarts/csp/style.css` should be included manually.
|
||||||
|
|
||||||
|
## 6.7.3
|
||||||
|
|
||||||
|
* Fixed that `padding` on the component root doesn't work.
|
||||||
|
|
||||||
## 6.7.2
|
## 6.7.2
|
||||||
|
|
||||||
* Fixed that charts inside `<keep-alive>` failed to display after activation.
|
* Fixed that charts inside `<keep-alive>` failed to display after activation.
|
||||||
|
|||||||
85
README.md
85
README.md
@ -1,47 +1,21 @@
|
|||||||
<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 component for Apache ECharts™.</p>
|
||||||
<p align="center"><a href="https://vue-echarts.dev/">View Demo →</a></p>
|
<p align="center"><a href="https://npmjs.com/package/vue-echarts"><img alt="npm version" src="https://img.shields.io/npm/v/vue-echarts"></a> <a href="https://vue-echarts.dev/"><img src="https://img.shields.io/badge/Demo%20%C2%BB-20c3aa" alt="View demo"></a> <a href="./README.zh-Hans.md"><img src="https://img.shields.io/badge/%E4%B8%AD%E6%96%87%E7%89%88%20%C2%BB-000" alt="前往中文版"></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>
|
||||||
|
|
||||||
> [!IMPORTANT]
|
|
||||||
> We have released an [import code generator](https://vue-echarts.dev/#codegen) that can generate precise import code by pasting the `option` code.
|
|
||||||
>
|
|
||||||
> 
|
|
||||||
>
|
|
||||||
> [Try it →](https://vue-echarts.dev/#codegen)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<h2>💡 Heads up 💡 <a href="./README.zh-Hans.md"><img src="https://img.shields.io/badge/%F0%9F%87%A8%F0%9F%87%B3-%E4%B8%AD%E6%96%87%E7%89%88-white?labelColor=white" alt="前往中文版" align="right" height="24"/></a></h2>
|
> Still using v6? Read v6 docs [here →](https://github.com/ecomfe/vue-echarts/tree/6.x)
|
||||||
|
|
||||||
If you are migrating from `vue-echarts` ≤ 5, you should read the _[Migration to v6](#migration-to-v6)_ section before you update to v6.
|
|
||||||
|
|
||||||
Not ready yet? Read documentation for older versions [here →](https://github.com/ecomfe/vue-echarts/tree/5.x)
|
|
||||||
|
|
||||||
## Installation & Usage
|
## Installation & Usage
|
||||||
|
|
||||||
### npm & ESM
|
### npm
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i echarts vue-echarts
|
npm add echarts vue-echarts
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
|
||||||
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 need `@nuxtjs/composition-api`:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm i @nuxtjs/composition-api
|
|
||||||
```
|
|
||||||
|
|
||||||
And then add `'@nuxtjs/composition-api/module'` in the `buildModules` option in your `nuxt.config.js`.
|
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -219,6 +193,8 @@ export default {
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> 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.
|
> 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.
|
||||||
>
|
>
|
||||||
|
> 
|
||||||
|
>
|
||||||
> [Try it →](https://vue-echarts.dev/#codegen)
|
> [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:
|
||||||
@ -227,7 +203,7 @@ But if you really want to import the whole ECharts bundle without having to impo
|
|||||||
import "echarts";
|
import "echarts";
|
||||||
```
|
```
|
||||||
|
|
||||||
### CDN & Global variable
|
### CDN
|
||||||
|
|
||||||
Drop `<script>` inside your HTML file and access the component via `window.VueECharts`.
|
Drop `<script>` inside your HTML file and access the component via `window.VueECharts`.
|
||||||
|
|
||||||
@ -236,9 +212,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.4.23"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.33"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -257,8 +233,8 @@ app.component('v-chart', VueECharts)
|
|||||||
<!-- vue2Scripts:start -->
|
<!-- vue2Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></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.5.1"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -476,38 +452,11 @@ Static methods can be accessed from [`echarts` itself](https://echarts.apache.or
|
|||||||
|
|
||||||
## 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 `vue-echarts/csp` instead of `vue-echarts` and include `vue-echarts/csp/style.css` manually.
|
||||||
|
|
||||||
## Migration to v6
|
## Migration to v7
|
||||||
|
|
||||||
> 💡 Please make sure to read the [migration guide](https://echarts.apache.org/en/tutorial.html#ECharts%205%20Upgrade%20Guide) for ECharts 5 as well.
|
Read the breaking changes document in the [release log](https://github.com/ecomfe/vue-echarts/releases/tag/v7.0.0-beta.0) and the migration shoud be straightforward.
|
||||||
|
|
||||||
The following breaking changes are introduced in `vue-echarts@6`:
|
|
||||||
|
|
||||||
### 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 (and also `@vue/runtime-core` for TypeScript support).
|
|
||||||
|
|
||||||
### Props
|
|
||||||
|
|
||||||
- `options` is renamed to **`option`** to align with ECharts itself.
|
|
||||||
- Updating `option` will respect **`update-options`** configs instead of checking reference change.
|
|
||||||
- `watch-shallow` is removed. Use **`manual-update`** for performance critical scenarios.
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
|
|
||||||
- `mergeOptions` is renamed to **`setOption`** to align with ECharts itself.
|
|
||||||
- `showLoading` and `hideLoading` is removed. Use the **`loading` and `loading-options`** props instead.
|
|
||||||
- `appendData` is removed. (Due to ECharts 5's breaking change.)
|
|
||||||
- All static methods are removed from `vue-echarts`. Use those methods from `echarts` directly.
|
|
||||||
|
|
||||||
### Computed getters
|
|
||||||
|
|
||||||
- Computed getters (`width`, `height`, `isDisposed` and `computedOptions`) are removed. Use the **`getWidth`, `getHeight`, `isDisposed` and `getOption`** methods instead.
|
|
||||||
|
|
||||||
### Styles
|
|
||||||
|
|
||||||
- Now the root element of the component have **`100%×100%`** size by default, instead of `600×400`.
|
|
||||||
|
|
||||||
## Local development
|
## Local development
|
||||||
|
|
||||||
|
|||||||
@ -1,47 +1,21 @@
|
|||||||
<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™ 的 Vue.js 组件。</p>
|
||||||
<p align="center"><a href="https://vue-echarts.dev/">查看 Demo →</a></p>
|
<p align="center"><a href="https://npmjs.com/package/vue-echarts"><img alt="npm 版本" src="https://img.shields.io/npm/v/vue-echarts"></a> <a href="https://vue-echarts.dev/"><img src="https://img.shields.io/badge/%E6%BC%94%E7%A4%BA%20%C2%BB-20c3aa" alt="查看演示"></a> <a href="./README.zh-Hans.md"></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>
|
||||||
|
|
||||||
> [!IMPORTANT]
|
|
||||||
> 我们新发布了一个[导入代码生成器](https://vue-echarts.dev/#codegen),只需要把`option` 代码粘贴进去,就可以得到精确的导入代码。
|
|
||||||
>
|
|
||||||
> 
|
|
||||||
>
|
|
||||||
> [试一试 →](https://vue-echarts.dev/#codegen)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 💡 注意 💡
|
> 还在使用 v6?可以继续阅读老版本的文档。[前往 →](https://github.com/ecomfe/vue-echarts/blob/6.x/README.zh_CN.md)
|
||||||
|
|
||||||
若您准备从 `vue-echarts` ≤ 5 的版本迁移到新版本,请在升级 v6 前阅读 _[迁移到 v6](#迁移到-v6)_ 部分文档。
|
|
||||||
|
|
||||||
没准备好的话,可以继续阅读老版本的文档。[前往 →](https://github.com/ecomfe/vue-echarts/blob/5.x/README.zh_CN.md)
|
|
||||||
|
|
||||||
## 安装 & 使用
|
## 安装 & 使用
|
||||||
|
|
||||||
### npm & ESM
|
### npm
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm i echarts vue-echarts
|
npm add echarts vue-echarts
|
||||||
```
|
```
|
||||||
|
|
||||||
要在 _Vue 2_(<2.7.0)下使用 `vue-echarts`,需要确保 `@vue/composition-api` 已经安装(TypeScript 支持还需要 `@vue/runtime-core`):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm i @vue/composition-api
|
|
||||||
npm i @vue/runtime-core # TypeScript 支持
|
|
||||||
```
|
|
||||||
|
|
||||||
如果你在使用基于 _Vue 2_ 的 _NuxtJS_,则需要安装 `@nuxtjs/composition-api`:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm i @nuxtjs/composition-api
|
|
||||||
```
|
|
||||||
|
|
||||||
然后在 `nuxt.config.js` 的 `buildModules` 选项中添加 `'@nuxtjs/composition-api/module'`。
|
|
||||||
|
|
||||||
#### 示例
|
#### 示例
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -219,6 +193,8 @@ export default {
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> 我们鼓励手动从 ECharts 中引入组件和图表,以减小打包体积。我们已经为此构建了一个[导入代码生成器](https://vue-echarts.dev/#codegen)。你只需要把`option` 代码粘贴进去,就可以得到精确的导入代码。
|
> 我们鼓励手动从 ECharts 中引入组件和图表,以减小打包体积。我们已经为此构建了一个[导入代码生成器](https://vue-echarts.dev/#codegen)。你只需要把`option` 代码粘贴进去,就可以得到精确的导入代码。
|
||||||
>
|
>
|
||||||
|
> 
|
||||||
|
>
|
||||||
> [试一试 →](https://vue-echarts.dev/#codegen)
|
> [试一试 →](https://vue-echarts.dev/#codegen)
|
||||||
|
|
||||||
但如果你实在需要全量引入 ECharts 从而无需手动引入模块,只需要在代码中添加:
|
但如果你实在需要全量引入 ECharts 从而无需手动引入模块,只需要在代码中添加:
|
||||||
@ -227,7 +203,7 @@ export default {
|
|||||||
import "echarts";
|
import "echarts";
|
||||||
```
|
```
|
||||||
|
|
||||||
### CDN & 全局变量
|
### CDN
|
||||||
|
|
||||||
用如下方式在 HTML 中插入 `<script>` 标签,并且通过 `window.VueECharts` 来访问组件接口:
|
用如下方式在 HTML 中插入 `<script>` 标签,并且通过 `window.VueECharts` 来访问组件接口:
|
||||||
|
|
||||||
@ -236,9 +212,9 @@ import "echarts";
|
|||||||
|
|
||||||
<!-- vue3Scripts:start -->
|
<!-- vue3Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.23"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.33"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -257,8 +233,8 @@ app.component('v-chart', VueECharts)
|
|||||||
<!-- vue2Scripts:start -->
|
<!-- vue2Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></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.5.1"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.7.2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -478,38 +454,14 @@ import { THEME_KEY } from 'vue-echarts'
|
|||||||
|
|
||||||
## CSP: `style-src` 或 `style-src-elem`
|
## CSP: `style-src` 或 `style-src-elem`
|
||||||
|
|
||||||
如果你正在应用 CSP 来防止内联 `<style>` 注入,则需要使用 `dist/csp` 目录中的文件,并手动引入 `dist/csp/style.css`。
|
如果你正在应用 CSP 来防止内联 `<style>` 注入,则需要使用 `vue-echarts/csp` 代替 `vue-echarts`,并手动引入 `vue-echarts/csp/style.css`。
|
||||||
|
|
||||||
## 迁移到 v6
|
## 迁移到 v7
|
||||||
|
|
||||||
> 💡 请确保同时查阅 ECharts 5 的[升级指南](https://echarts.apache.org/zh/tutorial.html#ECharts%205%20%E5%8D%87%E7%BA%A7%E6%8C%87%E5%8D%97)。
|
Translate:
|
||||||
|
Read the breaking changes document in the [release log](https://github.com/ecomfe/vue-echarts/releases/tag/v7.0.0-beta.0) and the migration shoud be straightforward.
|
||||||
|
|
||||||
`vue-echarts@6` 引入了如下破坏性变更:
|
请阅读[发布日志](https://github.com/ecomfe/vue-echarts/releases/tag/v7.0.0-beta.0)中的变更记录,之后迁移过程应该会相对简单。
|
||||||
|
|
||||||
### Vue 2 支持
|
|
||||||
|
|
||||||
- 要在 `vue@2.7.0` 之前的版本中使用 Vue-ECharts,必须安装 `@vue/composition-api`(还需要安装 `@vue/runtime-core` 来支持 TypeScript)。
|
|
||||||
|
|
||||||
### Prop
|
|
||||||
|
|
||||||
- `options` 重命名为 **`option`**,以和 ECharts 本身保持一致。
|
|
||||||
- 更新 `option` 将采用 **`update-options`** 中的配置,不再检查是否发生引用变化。
|
|
||||||
- `watch-shallow` 被移除。在性能关键场景请使用 **`manual-update`**。
|
|
||||||
|
|
||||||
### 方法
|
|
||||||
|
|
||||||
- `mergeOptions` 重命名为 **`setOption`**,以和 ECharts 本身保持一致。
|
|
||||||
- `showLoading` 与 `hideLoading` 被移除。请使用 **`loading` 与 `loading-options`** prop。
|
|
||||||
- `appendData` 被移除。(由于 ECharts 5 引入的破坏性变更。)
|
|
||||||
- 所有静态方法被从 `vue-echarts` 移除。可以直接使用 `echarts` 本身的这些方法。
|
|
||||||
|
|
||||||
### 计算 Getter
|
|
||||||
|
|
||||||
- 计算 getter(`width`、`height`、`isDisposed` 和 `computedOptions`)被移除。请分别使用 **`getWidth`、`getHeight`、`isDisposed` 和 `getOption`** 方法代替。
|
|
||||||
|
|
||||||
### 样式
|
|
||||||
|
|
||||||
- 现在组件根元素尺寸默认为 **`100%×100%`**,而非原来的 `600×400`。
|
|
||||||
|
|
||||||
## 本地开发
|
## 本地开发
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
presets: ["@vue/cli-plugin-babel/preset"]
|
|
||||||
};
|
|
||||||
3
babel.config.json
Normal file
3
babel.config.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"presets": ["@vue/cli-plugin-babel/preset"]
|
||||||
|
}
|
||||||
132
package.json
132
package.json
@ -1,92 +1,90 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-echarts",
|
"name": "vue-echarts",
|
||||||
"version": "6.7.2",
|
"version": "7.0.3",
|
||||||
"description": "Vue.js component for Apache ECharts™.",
|
"description": "Vue.js component for Apache ECharts™.",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
||||||
"author": "GU Yiling <justice360@gmail.com>",
|
"author": "GU Yiling <justice360@gmail.com>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "pnpm run docs && rimraf dist && pnpm run build:2 && pnpm run build:3 && vue-demi-switch 3",
|
"build": "pnpm run docs && rimraf dist && pnpm run build:rollup",
|
||||||
"build:2": "vue-demi-switch 2 vue2 && rollup -c rollup.vue2.config.js",
|
"build:rollup": "vue-demi-switch 3 && rollup -c rollup.config.js",
|
||||||
"build:3": "vue-demi-switch 3 && rollup -c rollup.config.js",
|
|
||||||
"lint": "vue-cli-service lint",
|
"lint": "vue-cli-service lint",
|
||||||
|
"publint": "publint",
|
||||||
"build:demo": "vue-cli-service build",
|
"build:demo": "vue-cli-service build",
|
||||||
"docs": "node ./scripts/docs.js",
|
"docs": "node ./scripts/docs.mjs",
|
||||||
"postinstall": "node ./scripts/postinstall.js",
|
"prepublishOnly": "pnpm run build && publint"
|
||||||
"prepublishOnly": "pnpm run build"
|
},
|
||||||
|
"type": "module",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"unpkg": "dist/index.min.js",
|
||||||
|
"jsdelivr": "dist/index.min.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js",
|
||||||
|
"./csp": "./dist/csp/index.js",
|
||||||
|
"./csp/style.css": "./dist/csp/style.css"
|
||||||
},
|
},
|
||||||
"main": "dist/index.cjs.min.js",
|
|
||||||
"module": "dist/index.esm.min.js",
|
|
||||||
"unpkg": "dist/index.umd.min.js",
|
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"scripts/postinstall.js"
|
"scripts/postinstall.js"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"resize-detector": "^0.3.0",
|
|
||||||
"vue-demi": "^0.13.11"
|
"vue-demi": "^0.13.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
|
||||||
"@babel/core": "^7.24.4",
|
|
||||||
"@highlightjs/vue-plugin": "^2.1.0",
|
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
||||||
"@rollup/plugin-replace": "^5.0.5",
|
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
||||||
"@typescript-eslint/parser": "^4.33.0",
|
|
||||||
"@vercel/analytics": "^1.2.2",
|
|
||||||
"@vue/cli-plugin-babel": "^5.0.8",
|
|
||||||
"@vue/cli-plugin-eslint": "^5.0.8",
|
|
||||||
"@vue/cli-plugin-typescript": "^5.0.8",
|
|
||||||
"@vue/cli-service": "^5.0.8",
|
|
||||||
"@vue/compiler-sfc": "^3.4.24",
|
|
||||||
"@vue/composition-api": "^1.7.2",
|
|
||||||
"@vue/eslint-config-prettier": "^6.0.0",
|
|
||||||
"@vue/eslint-config-typescript": "^10.0.0",
|
|
||||||
"@vueuse/core": "^10.9.0",
|
|
||||||
"comment-mark": "^1.1.1",
|
|
||||||
"core-js": "^3.37.0",
|
|
||||||
"echarts": "^5.5.0",
|
|
||||||
"echarts-gl": "^2.0.9",
|
|
||||||
"echarts-liquidfill": "^3.1.0",
|
|
||||||
"esbuild-wasm": "^0.19.12",
|
|
||||||
"eslint": "^7.32.0",
|
|
||||||
"eslint-plugin-prettier": "^3.4.1",
|
|
||||||
"eslint-plugin-vue": "^8.7.1",
|
|
||||||
"highlight.js": "^11.9.0",
|
|
||||||
"pinia": "^2.1.7",
|
|
||||||
"postcss": "^8.4.38",
|
|
||||||
"postcss-loader": "^5.3.0",
|
|
||||||
"postcss-nested": "^5.0.6",
|
|
||||||
"prettier": "^2.8.8",
|
|
||||||
"raw-loader": "^4.0.2",
|
|
||||||
"resize-detector": "^0.3.0",
|
|
||||||
"rimraf": "^3.0.2",
|
|
||||||
"rollup": "^2.79.1",
|
|
||||||
"rollup-plugin-dts": "^4.2.3",
|
|
||||||
"rollup-plugin-styles": "^4.0.0",
|
|
||||||
"rollup-plugin-ts": "^2.0.7",
|
|
||||||
"tslib": "^2.6.2",
|
|
||||||
"typescript": "4.6.4",
|
|
||||||
"vue": "^3.4.24",
|
|
||||||
"vue2": "npm:vue@^2.7.16",
|
|
||||||
"webpack": "^5.91.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@vue/composition-api": "^1.0.5",
|
|
||||||
"@vue/runtime-core": "^3.0.0",
|
"@vue/runtime-core": "^3.0.0",
|
||||||
"echarts": "^5.4.1",
|
"echarts": "^5.5.1",
|
||||||
"vue": "^2.6.12 || ^3.1.1"
|
"vue": "^2.7.0 || ^3.1.1"
|
||||||
},
|
},
|
||||||
"jsdelivr": "dist/index.umd.min.js",
|
|
||||||
"license": "MIT",
|
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@vue/composition-api": {
|
|
||||||
"optional": true
|
|
||||||
},
|
|
||||||
"@vue/runtime-core": {
|
"@vue/runtime-core": {
|
||||||
"optional": true
|
"optional": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/ecomfe/vue-echarts.git",
|
"devDependencies": {
|
||||||
"types": "dist/index.d.ts"
|
"@babel/core": "^7.24.9",
|
||||||
|
"@highlightjs/vue-plugin": "^2.1.0",
|
||||||
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||||
|
"@rollup/plugin-replace": "^5.0.7",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
||||||
|
"@typescript-eslint/parser": "^7.17.0",
|
||||||
|
"@vercel/analytics": "^1.3.1",
|
||||||
|
"@vue/cli-plugin-babel": "^5.0.8",
|
||||||
|
"@vue/cli-plugin-eslint": "^5.0.8",
|
||||||
|
"@vue/cli-plugin-typescript": "^5.0.8",
|
||||||
|
"@vue/cli-service": "^5.0.8",
|
||||||
|
"@vue/compiler-sfc": "^3.4.33",
|
||||||
|
"@vue/eslint-config-prettier": "^9.0.0",
|
||||||
|
"@vue/eslint-config-typescript": "^13.0.0",
|
||||||
|
"@vueuse/core": "^10.11.0",
|
||||||
|
"comment-mark": "^1.1.1",
|
||||||
|
"core-js": "^3.37.1",
|
||||||
|
"echarts": "^5.5.1",
|
||||||
|
"echarts-gl": "^2.0.9",
|
||||||
|
"echarts-liquidfill": "^3.1.0",
|
||||||
|
"esbuild-wasm": "^0.23.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
|
"eslint-plugin-vue": "^9.27.0",
|
||||||
|
"highlight.js": "^11.10.0",
|
||||||
|
"pinia": "^2.1.7",
|
||||||
|
"postcss": "^8.4.39",
|
||||||
|
"postcss-loader": "^8.1.1",
|
||||||
|
"postcss-nested": "^6.2.0",
|
||||||
|
"prettier": "^3.3.3",
|
||||||
|
"publint": "^0.2.9",
|
||||||
|
"raw-loader": "^4.0.2",
|
||||||
|
"resize-detector": "^0.3.0",
|
||||||
|
"rimraf": "^6.0.1",
|
||||||
|
"rollup": "^4.19.0",
|
||||||
|
"rollup-plugin-dts": "^6.1.0",
|
||||||
|
"rollup-plugin-esbuild": "^6.1.1",
|
||||||
|
"rollup-plugin-import-css": "^3.5.1",
|
||||||
|
"tslib": "^2.6.3",
|
||||||
|
"typescript": "5.5.4",
|
||||||
|
"vue": "^3.4.33",
|
||||||
|
"vue2": "npm:vue@^2.7.16",
|
||||||
|
"webpack": "^5.93.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3710
pnpm-lock.yaml
generated
3710
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
103
rollup.config.js
103
rollup.config.js
@ -1,9 +1,8 @@
|
|||||||
import typescript from "rollup-plugin-ts";
|
|
||||||
import terser from "@rollup/plugin-terser";
|
|
||||||
import resolve from "@rollup/plugin-node-resolve";
|
|
||||||
import replace from "@rollup/plugin-replace";
|
import replace from "@rollup/plugin-replace";
|
||||||
import styles from "rollup-plugin-styles";
|
import esbuild from "rollup-plugin-esbuild";
|
||||||
import { injectVueDemi } from "./scripts/rollup";
|
import { dts } from "rollup-plugin-dts";
|
||||||
|
import css from "rollup-plugin-import-css";
|
||||||
|
import { injectVueDemi } from "./scripts/rollup.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the Rollup options for a build to support strict CSP
|
* Modifies the Rollup options for a build to support strict CSP
|
||||||
@ -18,7 +17,7 @@ function configBuild(options, csp) {
|
|||||||
result.plugins = [
|
result.plugins = [
|
||||||
...(csp ? [replace({ __CSP__: `${csp}`, preventAssignment: true })] : []),
|
...(csp ? [replace({ __CSP__: `${csp}`, preventAssignment: true })] : []),
|
||||||
...plugins,
|
...plugins,
|
||||||
csp ? styles({ mode: ["extract", "style.css"] }) : styles()
|
csp ? css({ output: "style.css" }) : css({ inject: true })
|
||||||
];
|
];
|
||||||
|
|
||||||
// modify output file names
|
// modify output file names
|
||||||
@ -39,67 +38,23 @@ function configBuild(options, csp) {
|
|||||||
const builds = [
|
const builds = [
|
||||||
{
|
{
|
||||||
input: "src/index.ts",
|
input: "src/index.ts",
|
||||||
plugins: [
|
plugins: [esbuild()],
|
||||||
typescript({
|
external: ["vue-demi", /^echarts/],
|
||||||
tsconfig: resolvedConfig => ({ ...resolvedConfig, declaration: true }),
|
|
||||||
hook: {
|
|
||||||
outputPath: (path, kind) =>
|
|
||||||
kind === "declaration" ? "dist/index.d.ts" : path
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
external: ["vue-demi", "echarts/core", "resize-detector"],
|
|
||||||
output: {
|
|
||||||
file: "dist/index.esm.js",
|
|
||||||
format: "esm",
|
|
||||||
sourcemap: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "src/index.ts",
|
|
||||||
plugins: [typescript()],
|
|
||||||
external: ["vue-demi", "echarts/core", "resize-detector"],
|
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: "dist/index.esm.min.js",
|
file: "dist/index.js",
|
||||||
format: "esm",
|
format: "esm",
|
||||||
sourcemap: true,
|
|
||||||
plugins: [
|
|
||||||
terser({
|
|
||||||
format: {
|
|
||||||
comments: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
file: "dist/index.cjs.js",
|
|
||||||
format: "cjs",
|
|
||||||
exports: "named",
|
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
},
|
|
||||||
{
|
|
||||||
file: "dist/index.cjs.min.js",
|
|
||||||
format: "cjs",
|
|
||||||
exports: "named",
|
|
||||||
sourcemap: true,
|
|
||||||
plugins: [
|
|
||||||
terser({
|
|
||||||
format: {
|
|
||||||
comments: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "src/global.ts",
|
input: "src/global.ts",
|
||||||
plugins: [resolve(), typescript()],
|
plugins: [esbuild({ minify: true })],
|
||||||
external: ["vue-demi", "echarts", "echarts/core"],
|
external: ["vue-demi", /^echarts/],
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: "dist/index.umd.js",
|
file: "dist/index.min.js", // for unpkg/jsdelivr
|
||||||
format: "umd",
|
format: "umd",
|
||||||
name: "VueECharts",
|
name: "VueECharts",
|
||||||
exports: "default",
|
exports: "default",
|
||||||
@ -110,26 +65,6 @@ const builds = [
|
|||||||
"echarts/core": "echarts"
|
"echarts/core": "echarts"
|
||||||
},
|
},
|
||||||
plugins: [injectVueDemi]
|
plugins: [injectVueDemi]
|
||||||
},
|
|
||||||
{
|
|
||||||
file: "dist/index.umd.min.js",
|
|
||||||
format: "umd",
|
|
||||||
name: "VueECharts",
|
|
||||||
exports: "default",
|
|
||||||
sourcemap: true,
|
|
||||||
globals: {
|
|
||||||
"vue-demi": "VueDemi",
|
|
||||||
echarts: "echarts",
|
|
||||||
"echarts/core": "echarts"
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
injectVueDemi,
|
|
||||||
terser({
|
|
||||||
format: {
|
|
||||||
comments: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -137,5 +72,19 @@ const builds = [
|
|||||||
|
|
||||||
export default [
|
export default [
|
||||||
...builds.map(options => configBuild(options, false)),
|
...builds.map(options => configBuild(options, false)),
|
||||||
...builds.map(options => configBuild(options, true))
|
...builds.map(options => configBuild(options, true)),
|
||||||
|
{
|
||||||
|
input: "src/index.d.ts",
|
||||||
|
plugins: [dts()],
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: "dist/index.d.ts",
|
||||||
|
format: "esm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: "dist/csp/index.d.ts",
|
||||||
|
format: "esm"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
import dts from "rollup-plugin-dts";
|
|
||||||
|
|
||||||
/** @type {import('rollup').RollupOptions[]} */
|
|
||||||
const options = [
|
|
||||||
{
|
|
||||||
input: "src/index.vue2.d.ts",
|
|
||||||
plugins: [dts()],
|
|
||||||
output: {
|
|
||||||
file: "dist/index.vue2.d.ts",
|
|
||||||
format: "esm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "src/index.vue2_7.d.ts",
|
|
||||||
plugins: [dts()],
|
|
||||||
output: {
|
|
||||||
file: "dist/index.vue2_7.d.ts",
|
|
||||||
format: "esm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
export default options;
|
|
||||||
@ -1,18 +1,15 @@
|
|||||||
const { readFileSync, writeFileSync } = require("fs");
|
import { readFileSync, writeFileSync } from "node:fs";
|
||||||
const { resolve } = require("path");
|
import commentMark from "comment-mark";
|
||||||
const commentMark = require("comment-mark");
|
import { getPackageMeta, resolvePath } from "./utils.mjs";
|
||||||
const { name, version } = require("../package.json");
|
|
||||||
|
|
||||||
function resolvePath(...parts) {
|
const { name, version } = getPackageMeta();
|
||||||
return resolve(__dirname, ...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.4.23",
|
"vue@3": "3.4.33",
|
||||||
"vue@2": "2.7.16",
|
"vue@2": "2.7.16",
|
||||||
echarts: "5.4.3",
|
echarts: "5.5.1",
|
||||||
[name]: version
|
[name]: version
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,7 +38,7 @@ const scripts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const README_FILES = ["README.md", "README.zh-Hans.md"].map(name =>
|
const README_FILES = ["README.md", "README.zh-Hans.md"].map(name =>
|
||||||
resolvePath("..", name)
|
resolvePath(import.meta.url, "..", name)
|
||||||
);
|
);
|
||||||
|
|
||||||
README_FILES.forEach(file => {
|
README_FILES.forEach(file => {
|
||||||
@ -1,46 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
||||||
const path = require("path");
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
const packageFile = path.resolve(__dirname, "../package.json");
|
|
||||||
|
|
||||||
const typesPaths = {
|
|
||||||
3: "dist/index.d.ts",
|
|
||||||
2.7: "dist/index.vue2_7.d.ts",
|
|
||||||
2: "dist/index.vue2.d.ts"
|
|
||||||
};
|
|
||||||
|
|
||||||
function switchVersion(version) {
|
|
||||||
const typesPath = typesPaths[version];
|
|
||||||
const package = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
|
||||||
if (typesPath !== package.types) {
|
|
||||||
package.types = typesPath;
|
|
||||||
fs.writeFileSync(packageFile, JSON.stringify(package, null, " "), "utf8");
|
|
||||||
}
|
|
||||||
console.log(`[vue-echarts] Switched to Vue ${version} environment.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadVue() {
|
|
||||||
try {
|
|
||||||
return require("vue");
|
|
||||||
} catch (e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const Vue = loadVue();
|
|
||||||
|
|
||||||
// Align the process with vue-demi
|
|
||||||
if (!Vue || typeof Vue.version !== "string") {
|
|
||||||
console.warn(
|
|
||||||
'[vue-echarts] Vue is not found. Please run "npm install vue" to install.'
|
|
||||||
);
|
|
||||||
} else if (Vue.version.startsWith("3.")) {
|
|
||||||
switchVersion(3);
|
|
||||||
} else if (Vue.version.startsWith("2.7.")) {
|
|
||||||
switchVersion(2.7);
|
|
||||||
} else if (Vue.version.startsWith("2.")) {
|
|
||||||
switchVersion(2);
|
|
||||||
} else {
|
|
||||||
console.warn(`[vue-echarts] Vue version v${Vue.version} is not supported.`);
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
import { readFileSync } from "fs";
|
|
||||||
|
|
||||||
const VUE_DEMI_IIFE = readFileSync(
|
|
||||||
require.resolve("vue-demi/lib/index.iife.js"),
|
|
||||||
"utf8"
|
|
||||||
);
|
|
||||||
|
|
||||||
/** @type {import('rollup').Plugin} */
|
|
||||||
export const injectVueDemi = {
|
|
||||||
name: "inject-vue-demi",
|
|
||||||
banner() {
|
|
||||||
return `${VUE_DEMI_IIFE};\n;`;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const EMPTY_FILE_ID = "__rollup_empty__";
|
|
||||||
|
|
||||||
/** @type {import('rollup').Plugin} */
|
|
||||||
export const ingoreCss = {
|
|
||||||
name: "ignore-css",
|
|
||||||
resolveId(source) {
|
|
||||||
if (source.endsWith(".css")) {
|
|
||||||
return EMPTY_FILE_ID;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
load(id) {
|
|
||||||
return id === EMPTY_FILE_ID ? "" : null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
17
scripts/rollup.mjs
Normal file
17
scripts/rollup.mjs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { createRequire } from "node:module";
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
|
||||||
|
const VUE_DEMI_IIFE = readFileSync(
|
||||||
|
require.resolve("vue-demi/lib/index.iife.js"),
|
||||||
|
"utf8"
|
||||||
|
);
|
||||||
|
|
||||||
|
/** @type {import('rollup').Plugin} */
|
||||||
|
export const injectVueDemi = {
|
||||||
|
name: "inject-vue-demi",
|
||||||
|
banner() {
|
||||||
|
return `${VUE_DEMI_IIFE};\n;`;
|
||||||
|
}
|
||||||
|
};
|
||||||
13
scripts/utils.mjs
Normal file
13
scripts/utils.mjs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { resolve, dirname } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
export function resolvePath(url, ...parts) {
|
||||||
|
return resolve(dirname(fileURLToPath(url)), ...parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getPackageMeta() {
|
||||||
|
return JSON.parse(
|
||||||
|
readFileSync(resolvePath(import.meta.url, "../package.json"), "utf8")
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -13,11 +13,21 @@ import {
|
|||||||
nextTick,
|
nextTick,
|
||||||
watchEffect,
|
watchEffect,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
Vue2,
|
Vue2
|
||||||
type PropType,
|
|
||||||
type InjectionKey
|
|
||||||
} from "vue-demi";
|
} from "vue-demi";
|
||||||
import { init as initChart } from "echarts/core";
|
import { init as initChart } from "echarts/core";
|
||||||
|
|
||||||
|
import {
|
||||||
|
usePublicAPI,
|
||||||
|
useAutoresize,
|
||||||
|
autoresizeProps,
|
||||||
|
useLoading,
|
||||||
|
loadingProps
|
||||||
|
} from "./composables";
|
||||||
|
import { isOn, omitOn, unwrapInjected } from "./utils";
|
||||||
|
import { register, TAG_NAME } from "./wc";
|
||||||
|
|
||||||
|
import type { PropType, InjectionKey } from "vue-demi";
|
||||||
import type {
|
import type {
|
||||||
EChartsType,
|
EChartsType,
|
||||||
EventTarget,
|
EventTarget,
|
||||||
@ -30,15 +40,8 @@ import type {
|
|||||||
UpdateOptionsInjection,
|
UpdateOptionsInjection,
|
||||||
Emits
|
Emits
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import {
|
import type { EChartsElement } from "./wc";
|
||||||
usePublicAPI,
|
|
||||||
useAutoresize,
|
|
||||||
autoresizeProps,
|
|
||||||
useLoading,
|
|
||||||
loadingProps
|
|
||||||
} from "./composables";
|
|
||||||
import { isOn, omitOn, unwrapInjected } from "./utils";
|
|
||||||
import { register, TAG_NAME, type EChartsElement } from "./wc";
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
const __CSP__ = false;
|
const __CSP__ = false;
|
||||||
@ -75,7 +78,6 @@ export default defineComponent({
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
setup(props, { attrs }) {
|
setup(props, { attrs }) {
|
||||||
const root = shallowRef<EChartsElement>();
|
const root = shallowRef<EChartsElement>();
|
||||||
const inner = shallowRef<HTMLElement>();
|
|
||||||
const chart = shallowRef<EChartsType>();
|
const chart = shallowRef<EChartsType>();
|
||||||
const manualOption = shallowRef<Option>();
|
const manualOption = shallowRef<Option>();
|
||||||
const defaultTheme = inject(THEME_KEY, null);
|
const defaultTheme = inject(THEME_KEY, null);
|
||||||
@ -155,12 +157,12 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(option?: Option) {
|
function init(option?: Option) {
|
||||||
if (!inner.value) {
|
if (!root.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = (chart.value = initChart(
|
const instance = (chart.value = initChart(
|
||||||
inner.value,
|
root.value,
|
||||||
realTheme.value,
|
realTheme.value,
|
||||||
realInitOptions.value
|
realInitOptions.value
|
||||||
));
|
));
|
||||||
@ -306,7 +308,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
useLoading(chart, loading, loadingOptions);
|
useLoading(chart, loading, loadingOptions);
|
||||||
|
|
||||||
useAutoresize(chart, autoresize, inner);
|
useAutoresize(chart, autoresize, root);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init();
|
init();
|
||||||
@ -327,7 +329,6 @@ export default defineComponent({
|
|||||||
return {
|
return {
|
||||||
chart,
|
chart,
|
||||||
root,
|
root,
|
||||||
inner,
|
|
||||||
setOption,
|
setOption,
|
||||||
nonEventAttrs,
|
nonEventAttrs,
|
||||||
nativeListeners,
|
nativeListeners,
|
||||||
@ -344,8 +345,6 @@ export default defineComponent({
|
|||||||
) 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: "vue-echarts-inner" })
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { Ref } from "vue-demi";
|
import type { Ref } from "vue-demi";
|
||||||
import { EChartsType } from "../types";
|
import type { EChartsType } from "../types";
|
||||||
|
|
||||||
const METHOD_NAMES = [
|
const METHOD_NAMES = [
|
||||||
"getWidth",
|
"getWidth",
|
||||||
|
|||||||
@ -1,48 +1,60 @@
|
|||||||
import { watch, type Ref, type PropType } from "vue-demi";
|
import { watch } from "vue-demi";
|
||||||
import { throttle } from "echarts/core";
|
import { throttle } from "echarts/core";
|
||||||
import {
|
|
||||||
addListener,
|
|
||||||
removeListener,
|
|
||||||
type ResizeCallback
|
|
||||||
} from "resize-detector";
|
|
||||||
import { type EChartsType } from "../types";
|
|
||||||
|
|
||||||
type AutoresizeProp =
|
import type { Ref, PropType } from "vue-demi";
|
||||||
| boolean
|
import type { EChartsType, AutoResize } from "../types";
|
||||||
| {
|
|
||||||
throttle?: number;
|
|
||||||
onResize?: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function useAutoresize(
|
export function useAutoresize(
|
||||||
chart: Ref<EChartsType | undefined>,
|
chart: Ref<EChartsType | undefined>,
|
||||||
autoresize: Ref<AutoresizeProp | undefined>,
|
autoresize: Ref<AutoResize | undefined>,
|
||||||
root: Ref<HTMLElement | undefined>
|
root: Ref<HTMLElement | undefined>
|
||||||
): void {
|
): void {
|
||||||
let resizeListener: ResizeCallback | null = null;
|
watch(
|
||||||
|
[root, chart, autoresize],
|
||||||
|
([root, chart, autoresize], _, onCleanup) => {
|
||||||
|
let ro: ResizeObserver | null = null;
|
||||||
|
|
||||||
watch([root, chart, autoresize], ([root, chart, autoresize], _, cleanup) => {
|
if (root && chart && autoresize) {
|
||||||
if (root && chart && autoresize) {
|
const { offsetWidth, offsetHeight } = root;
|
||||||
const autoresizeOptions = autoresize === true ? {} : autoresize;
|
const autoresizeOptions = autoresize === true ? {} : autoresize;
|
||||||
const { throttle: wait = 100, onResize } = autoresizeOptions;
|
const { throttle: wait = 100, onResize } = autoresizeOptions;
|
||||||
|
|
||||||
const callback = () => {
|
let initialResizeTriggered = false;
|
||||||
chart.resize();
|
|
||||||
onResize?.();
|
|
||||||
};
|
|
||||||
|
|
||||||
resizeListener = wait ? throttle(callback, wait) : callback;
|
const callback = () => {
|
||||||
addListener(root, resizeListener);
|
chart.resize();
|
||||||
}
|
onResize?.();
|
||||||
|
};
|
||||||
|
|
||||||
cleanup(() => {
|
const resizeCallback = wait ? throttle(callback, wait) : callback;
|
||||||
if (root && resizeListener) {
|
|
||||||
removeListener(root, resizeListener);
|
ro = new ResizeObserver(() => {
|
||||||
|
// We just skip ResizeObserver's initial resize callback if the
|
||||||
|
// size has not changed since the chart is rendered.
|
||||||
|
if (!initialResizeTriggered) {
|
||||||
|
initialResizeTriggered = true;
|
||||||
|
if (
|
||||||
|
root.offsetWidth === offsetWidth &&
|
||||||
|
root.offsetHeight === offsetHeight
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resizeCallback();
|
||||||
|
});
|
||||||
|
ro.observe(root);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
onCleanup(() => {
|
||||||
|
if (ro) {
|
||||||
|
ro.disconnect();
|
||||||
|
ro = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const autoresizeProps = {
|
export const autoresizeProps = {
|
||||||
autoresize: [Boolean, Object] as PropType<AutoresizeProp>
|
autoresize: [Boolean, Object] as PropType<AutoResize>
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
import { unwrapInjected } from "../utils";
|
import { unwrapInjected } from "../utils";
|
||||||
import {
|
import { inject, computed, watchEffect } from "vue-demi";
|
||||||
inject,
|
|
||||||
computed,
|
import type { Ref, InjectionKey, PropType } from "vue-demi";
|
||||||
watchEffect,
|
|
||||||
type Ref,
|
|
||||||
type InjectionKey,
|
|
||||||
type PropType
|
|
||||||
} from "vue-demi";
|
|
||||||
import type { EChartsType, LoadingOptions } from "../types";
|
import type { EChartsType, LoadingOptions } from "../types";
|
||||||
|
|
||||||
export const LOADING_OPTIONS_KEY =
|
export const LOADING_OPTIONS_KEY =
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import javascript from "highlight.js/lib/languages/javascript";
|
|||||||
import typescript from "highlight.js/lib/languages/typescript";
|
import typescript from "highlight.js/lib/languages/typescript";
|
||||||
import hljsVuePlugin from "@highlightjs/vue-plugin";
|
import hljsVuePlugin from "@highlightjs/vue-plugin";
|
||||||
import { initialize, transform } from "esbuild-wasm";
|
import { initialize, transform } from "esbuild-wasm";
|
||||||
|
import wasmURL from "esbuild-wasm/esbuild.wasm";
|
||||||
import { track } from "@vercel/analytics";
|
import { track } from "@vercel/analytics";
|
||||||
|
|
||||||
import { getImportsFromOption } from "./utils/codegen";
|
import { getImportsFromOption } from "./utils/codegen";
|
||||||
@ -75,9 +76,7 @@ const transformedCode = ref("");
|
|||||||
const transformErrors = ref([]);
|
const transformErrors = ref([]);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await initialize({
|
await initialize({ wasmURL });
|
||||||
wasmURL: "https://cdn.jsdelivr.net/npm/esbuild-wasm@0.19.12/esbuild.wasm"
|
|
||||||
});
|
|
||||||
|
|
||||||
initializing.value = false;
|
initializing.value = false;
|
||||||
|
|
||||||
@ -414,7 +413,9 @@ input[type="number"] {
|
|||||||
transform: translate(-50%, 200%);
|
transform: translate(-50%, 200%);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: transform 0.2s, opacity 0.2s;
|
transition:
|
||||||
|
transform 0.2s,
|
||||||
|
opacity 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message.open {
|
.message.open {
|
||||||
|
|||||||
@ -111,9 +111,7 @@ watch(codeOpen, open => {
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<aside class="codegen">
|
<aside class="codegen">
|
||||||
<button @click="openCodegen">
|
<button @click="openCodegen">✨ <code>import</code> Codegen</button>
|
||||||
✨ <code>import</code> Codegen <span class="badge">beta</span>
|
|
||||||
</button>
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<code-gen v-model:open="codeOpen" :renderer="initOptions.renderer" />
|
<code-gen v-model:open="codeOpen" :renderer="initOptions.renderer" />
|
||||||
@ -297,7 +295,7 @@ input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
label {
|
label {
|
||||||
display: flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
@ -311,7 +309,7 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#logo {
|
#logo {
|
||||||
display: inline-block;
|
display: inline-flex;
|
||||||
width: 128px;
|
width: 128px;
|
||||||
height: 128px;
|
height: 128px;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
@ -381,11 +379,13 @@ select {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.renderer,
|
.renderer,
|
||||||
@ -445,15 +445,6 @@ select {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
|
||||||
.badge {
|
|
||||||
display: block;
|
|
||||||
padding: 2px 3px;
|
|
||||||
font-size: 10px;
|
|
||||||
background: #36485e54;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,15 +15,16 @@ const c1 = {
|
|||||||
fontWeight: 300
|
fontWeight: 300
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
top: 20,
|
top: "3%",
|
||||||
data: ["scatter"]
|
data: ["scatter"]
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: "{c}"
|
formatter: "{c}"
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: "26%",
|
top: "30%",
|
||||||
bottom: "26%"
|
right: "18%",
|
||||||
|
bottom: "20%"
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: "value",
|
type: "value",
|
||||||
@ -40,7 +41,8 @@ const c1 = {
|
|||||||
visualMap: [
|
visualMap: [
|
||||||
{
|
{
|
||||||
realtime: false,
|
realtime: false,
|
||||||
left: "right",
|
right: "2%",
|
||||||
|
bottom: "3%",
|
||||||
selectedMode: "multiple",
|
selectedMode: "multiple",
|
||||||
dimension: 2,
|
dimension: 2,
|
||||||
selected: [],
|
selected: [],
|
||||||
@ -67,15 +69,16 @@ const c2 = {
|
|||||||
fontWeight: 300
|
fontWeight: 300
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
top: 20,
|
top: "3%",
|
||||||
data: ["scatter"]
|
data: ["scatter"]
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: "{c}"
|
formatter: "{c}"
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: "26%",
|
top: "30%",
|
||||||
bottom: "26%"
|
right: "18%",
|
||||||
|
bottom: "20%"
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: "value",
|
type: "value",
|
||||||
@ -91,7 +94,8 @@ const c2 = {
|
|||||||
},
|
},
|
||||||
visualMap: [
|
visualMap: [
|
||||||
{
|
{
|
||||||
left: "right",
|
right: "2%",
|
||||||
|
bottom: "3%",
|
||||||
selectedMode: "multiple",
|
selectedMode: "multiple",
|
||||||
dimension: 2,
|
dimension: 2,
|
||||||
selected: [],
|
selected: [],
|
||||||
|
|||||||
@ -408,6 +408,7 @@ export default function getData() {
|
|||||||
text: "Air quality of major cities in China",
|
text: "Air quality of major cities in China",
|
||||||
subtext: "data from PM25.in",
|
subtext: "data from PM25.in",
|
||||||
sublink: "http://www.pm25.in",
|
sublink: "http://www.pm25.in",
|
||||||
|
top: "5%",
|
||||||
left: "center",
|
left: "center",
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: "#fff"
|
color: "#fff"
|
||||||
@ -418,9 +419,9 @@ export default function getData() {
|
|||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
orient: "vertical",
|
orient: "vertical",
|
||||||
y: "bottom",
|
right: "5%",
|
||||||
x: "right",
|
bottom: "5%",
|
||||||
data: ["pm2.5"],
|
data: ["PM2.5"],
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: "#fff"
|
color: "#fff"
|
||||||
}
|
}
|
||||||
@ -438,11 +439,13 @@ export default function getData() {
|
|||||||
itemStyle: {
|
itemStyle: {
|
||||||
areaColor: "#323c48",
|
areaColor: "#323c48",
|
||||||
borderColor: "#111"
|
borderColor: "#111"
|
||||||
}
|
},
|
||||||
|
top: "20%",
|
||||||
|
bottom: "7%"
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name: "pm2.5",
|
name: "PM2.5",
|
||||||
type: "scatter",
|
type: "scatter",
|
||||||
coordinateSystem: "geo",
|
coordinateSystem: "geo",
|
||||||
data: convertData(data),
|
data: convertData(data),
|
||||||
|
|||||||
@ -6,6 +6,7 @@ export default function getData() {
|
|||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: "Traffic Sources",
|
text: "Traffic Sources",
|
||||||
|
top: "5%",
|
||||||
left: "center"
|
left: "center"
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
@ -14,7 +15,8 @@ export default function getData() {
|
|||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
orient: "vertical",
|
orient: "vertical",
|
||||||
left: "left",
|
top: "5%",
|
||||||
|
left: "5%",
|
||||||
data: ["Direct", "Email", "Ad Networks", "Video Ads", "Search Engines"]
|
data: ["Direct", "Email", "Ad Networks", "Video Ads", "Search Engines"]
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
|
|||||||
@ -13,13 +13,17 @@ export default function getData() {
|
|||||||
fontWeight: 300
|
fontWeight: 300
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: "Dual Numeric Axis"
|
text: "Dual Numeric Axis",
|
||||||
|
top: "5%",
|
||||||
|
left: "5%"
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ["line"]
|
data: ["line"],
|
||||||
|
top: "6%"
|
||||||
},
|
},
|
||||||
polar: {
|
polar: {
|
||||||
center: ["50%", "54%"]
|
radius: "65%",
|
||||||
|
center: ["50%", "56%"]
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: "axis",
|
trigger: "axis",
|
||||||
|
|||||||
@ -15,37 +15,17 @@ export const useScoreStore = defineStore("store", () => {
|
|||||||
return scores.value.map(({ name }) => name);
|
return scores.value.map(({ name }) => name);
|
||||||
});
|
});
|
||||||
|
|
||||||
const scoreRadar = computed(() => {
|
function getRadarData(activeIndex: number) {
|
||||||
return {
|
return {
|
||||||
title: {
|
title: {
|
||||||
text: "Player Ability"
|
text: "Player Ability",
|
||||||
|
top: "5%",
|
||||||
|
left: "5%"
|
||||||
},
|
},
|
||||||
textStyle: {
|
textStyle: {
|
||||||
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif',
|
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif',
|
||||||
fontWeight: 300
|
fontWeight: 300
|
||||||
},
|
},
|
||||||
radar: {
|
|
||||||
indicator: scores.value.map(({ name, max }) => {
|
|
||||||
return { name, max };
|
|
||||||
})
|
|
||||||
},
|
|
||||||
series: [
|
|
||||||
{
|
|
||||||
name: "Value",
|
|
||||||
type: "radar",
|
|
||||||
data: [{ value: scores.value.map(({ value }) => value) }]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function getRadarData(activeIndex: number) {
|
|
||||||
return {
|
|
||||||
animation: false,
|
|
||||||
title: {
|
|
||||||
text: "Player Ability"
|
|
||||||
},
|
|
||||||
tooltip: {},
|
|
||||||
radar: {
|
radar: {
|
||||||
indicator: scores.value.map(({ name, max }, index) => {
|
indicator: scores.value.map(({ name, max }, index) => {
|
||||||
if (index === activeIndex) {
|
if (index === activeIndex) {
|
||||||
@ -81,7 +61,6 @@ export const useScoreStore = defineStore("store", () => {
|
|||||||
return {
|
return {
|
||||||
scores,
|
scores,
|
||||||
metrics,
|
metrics,
|
||||||
scoreRadar,
|
|
||||||
getRadarData,
|
getRadarData,
|
||||||
increase,
|
increase,
|
||||||
isMax,
|
isMax,
|
||||||
|
|||||||
@ -47,15 +47,21 @@ const data = [
|
|||||||
|
|
||||||
export default function getData() {
|
export default function getData() {
|
||||||
return {
|
return {
|
||||||
|
grid: {
|
||||||
|
top: "25%"
|
||||||
|
},
|
||||||
textStyle: {
|
textStyle: {
|
||||||
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif',
|
fontFamily: 'Inter, "Helvetica Neue", Arial, sans-serif',
|
||||||
fontWeight: 300
|
fontWeight: 300
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: "Life Expectancy vs. GDP by country"
|
text: "Life Expectancy vs. GDP by country",
|
||||||
|
top: "5%",
|
||||||
|
left: "5%"
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
right: 10,
|
top: "6%",
|
||||||
|
right: "5%",
|
||||||
data: ["1990", "2015"]
|
data: ["1990", "2015"]
|
||||||
},
|
},
|
||||||
xAxis: {
|
xAxis: {
|
||||||
|
|||||||
@ -46,10 +46,8 @@ watch(
|
|||||||
</template>
|
</template>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
<label>
|
<input id="connected-check" type="checkbox" v-model="connected" />
|
||||||
<input type="checkbox" v-model="connected" />
|
<label for="connected-check">Connected</label>
|
||||||
Connected
|
|
||||||
</label>
|
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</v-example>
|
</v-example>
|
||||||
|
|||||||
@ -49,7 +49,6 @@ defineProps({
|
|||||||
width: calc(60vw + 4em);
|
width: calc(60vw + 4em);
|
||||||
height: 360px;
|
height: 360px;
|
||||||
max-width: 720px;
|
max-width: 720px;
|
||||||
padding: 1.5em 2em;
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 0 45px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 0 45px rgba(0, 0, 0, 0.2);
|
||||||
@ -75,7 +74,6 @@ defineProps({
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
height: 60vw;
|
height: 60vw;
|
||||||
padding: 1em 0;
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
@ -88,7 +86,6 @@ defineProps({
|
|||||||
.echarts {
|
.echarts {
|
||||||
width: 28vw;
|
width: 28vw;
|
||||||
min-width: 240px;
|
min-width: 240px;
|
||||||
padding: 1em 1.5em;
|
|
||||||
height: 180px;
|
height: 180px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,8 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
visualMap: {
|
visualMap: {
|
||||||
|
bottom: "3%",
|
||||||
|
left: "3%",
|
||||||
max: 40,
|
max: 40,
|
||||||
calculable: true,
|
calculable: true,
|
||||||
realtime: false,
|
realtime: false,
|
||||||
|
|||||||
@ -46,6 +46,7 @@ function load() {
|
|||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
text: "World Flights",
|
text: "World Flights",
|
||||||
|
top: "5%",
|
||||||
left: "center",
|
left: "center",
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: "#eee"
|
color: "#eee"
|
||||||
@ -62,8 +63,10 @@ function load() {
|
|||||||
},
|
},
|
||||||
geo: {
|
geo: {
|
||||||
map: "world",
|
map: "world",
|
||||||
left: 0,
|
top: "15%",
|
||||||
right: 0,
|
right: "5%",
|
||||||
|
bottom: "5%",
|
||||||
|
left: "5%",
|
||||||
silent: true,
|
silent: true,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
borderColor: "#003",
|
borderColor: "#003",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
LegendComponent,
|
LegendComponent,
|
||||||
TooltipComponent
|
TooltipComponent
|
||||||
} from "echarts/components";
|
} from "echarts/components";
|
||||||
import { shallowRef } from "vue";
|
import { computed, shallowRef } from "vue";
|
||||||
import VChart from "../../ECharts";
|
import VChart from "../../ECharts";
|
||||||
import VExample from "./Example";
|
import VExample from "./Example";
|
||||||
import getData from "../data/polar";
|
import getData from "../data/polar";
|
||||||
@ -22,6 +22,23 @@ use([
|
|||||||
|
|
||||||
const option = shallowRef(getData());
|
const option = shallowRef(getData());
|
||||||
const theme = shallowRef("dark");
|
const theme = shallowRef("dark");
|
||||||
|
const loading = shallowRef(false);
|
||||||
|
const loadingOptions = computed(() =>
|
||||||
|
theme.value === "dark"
|
||||||
|
? {
|
||||||
|
color: "#fff",
|
||||||
|
textColor: "#fff",
|
||||||
|
maskColor: "rgba(0, 0, 0, 0.7)"
|
||||||
|
}
|
||||||
|
: null
|
||||||
|
);
|
||||||
|
const style = computed(() => {
|
||||||
|
return theme.value === "dark"
|
||||||
|
? loading.value
|
||||||
|
? "background-color: #05040d"
|
||||||
|
: "background-color: #100c2a"
|
||||||
|
: "";
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -29,8 +46,10 @@ const theme = shallowRef("dark");
|
|||||||
<v-chart
|
<v-chart
|
||||||
:option="option"
|
:option="option"
|
||||||
autoresize
|
autoresize
|
||||||
|
:loading="loading"
|
||||||
|
:loading-options="loadingOptions"
|
||||||
:theme="theme"
|
:theme="theme"
|
||||||
:style="theme === 'dark' ? 'background-color: #100c2a' : ''"
|
:style="style"
|
||||||
/>
|
/>
|
||||||
<template #extra>
|
<template #extra>
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
@ -39,6 +58,8 @@ const theme = shallowRef("dark");
|
|||||||
<option :value="null">Default</option>
|
<option :value="null">Default</option>
|
||||||
<option value="dark">Dark</option>
|
<option value="dark">Dark</option>
|
||||||
</select>
|
</select>
|
||||||
|
<input id="loading-check" type="checkbox" v-model="loading" />
|
||||||
|
<label for="loading-check">Loading</label>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</v-example>
|
</v-example>
|
||||||
|
|||||||
75
src/index.d.ts
vendored
Normal file
75
src/index.d.ts
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/ban-types */
|
||||||
|
import type { Ref, DefineComponent, InjectionKey } from "vue-demi";
|
||||||
|
import type {
|
||||||
|
Option,
|
||||||
|
Theme,
|
||||||
|
InitOptions,
|
||||||
|
UpdateOptions,
|
||||||
|
LoadingOptions,
|
||||||
|
AutoResize,
|
||||||
|
EChartsType,
|
||||||
|
Emits,
|
||||||
|
ThemeInjection,
|
||||||
|
InitOptionsInjection,
|
||||||
|
UpdateOptionsInjection,
|
||||||
|
LoadingOptionsInjection
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
|
declare const THEME_KEY: InjectionKey<ThemeInjection>;
|
||||||
|
declare const INIT_OPTIONS_KEY: InjectionKey<InitOptionsInjection>;
|
||||||
|
declare const UPDATE_OPTIONS_KEY: InjectionKey<UpdateOptionsInjection>;
|
||||||
|
declare const LOADING_OPTIONS_KEY: InjectionKey<LoadingOptionsInjection>;
|
||||||
|
|
||||||
|
declare type ChartProps = {
|
||||||
|
theme?: Theme;
|
||||||
|
initOptions?: InitOptions;
|
||||||
|
updateOptions?: UpdateOptions;
|
||||||
|
loadingOptions?: LoadingOptions;
|
||||||
|
option?: Option;
|
||||||
|
autoresize?: AutoResize;
|
||||||
|
loading?: boolean;
|
||||||
|
group?: string;
|
||||||
|
manualUpdate?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
// convert Emits to Props
|
||||||
|
// click => onClick
|
||||||
|
declare type ChartEventProps = {
|
||||||
|
[key in keyof Emits as key extends string
|
||||||
|
? `on${Capitalize<key>}`
|
||||||
|
: never]?: Emits[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
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 & ChartEventProps,
|
||||||
|
{
|
||||||
|
root: Ref<HTMLElement | undefined>;
|
||||||
|
chart: Ref<EChartsType | undefined>;
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
ChartMethods
|
||||||
|
>;
|
||||||
|
|
||||||
|
export default Chart;
|
||||||
|
export { THEME_KEY, INIT_OPTIONS_KEY, UPDATE_OPTIONS_KEY, LOADING_OPTIONS_KEY };
|
||||||
64
src/index.vue2.d.ts
vendored
64
src/index.vue2.d.ts
vendored
@ -1,64 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-types */
|
|
||||||
import type { DefineComponent } from "@vue/runtime-core";
|
|
||||||
import type { Ref } 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 };
|
|
||||||
63
src/index.vue2_7.d.ts
vendored
63
src/index.vue2_7.d.ts
vendored
@ -1,63 +0,0 @@
|
|||||||
/* 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,2 +1 @@
|
|||||||
x-vue-echarts{display:block;position:relative;width:100%;height:100%;min-width:0}
|
x-vue-echarts{display:block;width:100%;height:100%;min-width:0}
|
||||||
.vue-echarts-inner{position:absolute!important;top:0;right:0;bottom:0;left:0}
|
|
||||||
|
|||||||
23
src/types.ts
23
src/types.ts
@ -1,6 +1,7 @@
|
|||||||
import { init } from "echarts/core";
|
import { init } from "echarts/core";
|
||||||
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts";
|
|
||||||
import type { Ref } from "vue";
|
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts/core";
|
||||||
|
import type { Ref } from "vue-demi";
|
||||||
|
|
||||||
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
|
export type Injection<T> = T | null | Ref<T | null> | { value: T | null };
|
||||||
|
|
||||||
@ -22,6 +23,13 @@ export type EventTarget = EChartsType | ZRenderType;
|
|||||||
type SetOptionType = EChartsType["setOption"];
|
type SetOptionType = EChartsType["setOption"];
|
||||||
export type Option = Parameters<SetOptionType>[0];
|
export type Option = Parameters<SetOptionType>[0];
|
||||||
|
|
||||||
|
export type AutoResize =
|
||||||
|
| boolean
|
||||||
|
| {
|
||||||
|
throttle?: number;
|
||||||
|
onResize?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
export type LoadingOptions = {
|
export type LoadingOptions = {
|
||||||
text?: string;
|
text?: string;
|
||||||
textColor?: string;
|
textColor?: string;
|
||||||
@ -36,6 +44,7 @@ export type LoadingOptions = {
|
|||||||
lineWidth?: number;
|
lineWidth?: number;
|
||||||
zlevel?: number;
|
zlevel?: number;
|
||||||
};
|
};
|
||||||
|
export type LoadingOptionsInjection = Injection<LoadingOptions>;
|
||||||
|
|
||||||
type MouseEventName =
|
type MouseEventName =
|
||||||
| "click"
|
| "click"
|
||||||
@ -91,19 +100,19 @@ type OtherEventName =
|
|||||||
| "globalcursortaken";
|
| "globalcursortaken";
|
||||||
|
|
||||||
type MouseEmits = {
|
type MouseEmits = {
|
||||||
[key in MouseEventName]: (params: ECElementEvent) => boolean;
|
[key in MouseEventName]: (params: ECElementEvent) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ZRenderEmits = {
|
type ZRenderEmits = {
|
||||||
[key in ZRenderEventName]: (params: ElementEvent) => boolean;
|
[key in ZRenderEventName]: (params: ElementEvent) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
type OtherEmits = {
|
type OtherEmits = {
|
||||||
[key in OtherEventName]: null;
|
[key in OtherEventName]: (params: any) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Emits = MouseEmits &
|
export type Emits = MouseEmits &
|
||||||
OtherEmits & {
|
OtherEmits & {
|
||||||
rendered: (params: { elapsedTime: number }) => boolean;
|
rendered: (params: { elapsedTime: number }) => void;
|
||||||
finished: () => boolean;
|
finished: () => void;
|
||||||
} & ZRenderEmits;
|
} & ZRenderEmits;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { unref, isRef } from "vue-demi";
|
import { unref, isRef } from "vue-demi";
|
||||||
|
|
||||||
import type { Injection } from "./types";
|
import type { Injection } from "./types";
|
||||||
|
|
||||||
type Attrs = {
|
type Attrs = {
|
||||||
|
|||||||
18
src/wc.ts
18
src/wc.ts
@ -26,21 +26,9 @@ export function register(): boolean {
|
|||||||
// if the browser doesn't support native classes.
|
// if the browser doesn't support native classes.
|
||||||
const reg = new Function(
|
const reg = new Function(
|
||||||
"tag",
|
"tag",
|
||||||
`class EChartsElement extends HTMLElement {
|
// Use esbuild repl to keep build process simple
|
||||||
__dispose = null;
|
// https://esbuild.github.io/try/#dAAwLjIzLjAALS1taW5pZnkAY2xhc3MgRUNoYXJ0c0VsZW1lbnQgZXh0ZW5kcyBIVE1MRWxlbWVudCB7CiAgX19kaXNwb3NlID0gbnVsbDsKCiAgZGlzY29ubmVjdGVkQ2FsbGJhY2soKSB7CiAgICBpZiAodGhpcy5fX2Rpc3Bvc2UpIHsKICAgICAgdGhpcy5fX2Rpc3Bvc2UoKTsKICAgICAgdGhpcy5fX2Rpc3Bvc2UgPSBudWxsOwogICAgfQogIH0KfQoKaWYgKGN1c3RvbUVsZW1lbnRzLmdldCh0YWcpID09IG51bGwpIHsKICBjdXN0b21FbGVtZW50cy5kZWZpbmUodGFnLCBFQ2hhcnRzRWxlbWVudCk7Cn0K
|
||||||
|
"class EChartsElement extends HTMLElement{__dispose=null;disconnectedCallback(){this.__dispose&&(this.__dispose(),this.__dispose=null)}}customElements.get(tag)==null&&customElements.define(tag,EChartsElement);"
|
||||||
disconnectedCallback() {
|
|
||||||
if (this.__dispose) {
|
|
||||||
this.__dispose();
|
|
||||||
this.__dispose = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customElements.get(tag) == null) {
|
|
||||||
customElements.define(tag, EChartsElement);
|
|
||||||
}
|
|
||||||
`
|
|
||||||
);
|
);
|
||||||
reg(TAG_NAME);
|
reg(TAG_NAME);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
import nested from "postcss-nested";
|
||||||
const nested = require("postcss-nested");
|
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
outputDir: "demo",
|
outputDir: "demo",
|
||||||
css: {
|
css: {
|
||||||
loaderOptions: {
|
loaderOptions: {
|
||||||
@ -21,6 +20,14 @@ module.exports = {
|
|||||||
.test(/\.svg$/)
|
.test(/\.svg$/)
|
||||||
.type("asset/source");
|
.type("asset/source");
|
||||||
|
|
||||||
|
config.module
|
||||||
|
.rule("wasm")
|
||||||
|
.test(/\.wasm$/)
|
||||||
|
.type("asset/resource")
|
||||||
|
.set("generator", {
|
||||||
|
filename: "[name].[hash:8][ext]"
|
||||||
|
});
|
||||||
|
|
||||||
config.plugin("define").tap(([options]) => [
|
config.plugin("define").tap(([options]) => [
|
||||||
{
|
{
|
||||||
...options,
|
...options,
|
||||||
|
|||||||
Reference in New Issue
Block a user