mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-06 21:18:32 +08:00
Compare commits
5 Commits
move-to-es
...
v6.6.10
| Author | SHA1 | Date | |
|---|---|---|---|
| 34defec669 | |||
| e189abd9c2 | |||
| f07855df08 | |||
| ae3102a86c | |||
| 48a2507ef8 |
25
.eslintrc.js
Normal file
25
.eslintrc.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
@ -1,24 +0,0 @@
|
|||||||
{
|
|
||||||
"root": true,
|
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/prettier"],
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 2020,
|
|
||||||
"parser": "@typescript-eslint/parser"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"no-console": "off",
|
|
||||||
"vue/multi-word-component-names": "off"
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["*.ts"],
|
|
||||||
"extends": [
|
|
||||||
"@vue/typescript/recommended",
|
|
||||||
"@vue/prettier/@typescript-eslint"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,3 +1,7 @@
|
|||||||
|
## 6.6.10
|
||||||
|
|
||||||
|
* Fixed that `autoresize` doesn't work when reducing the height or the root element.
|
||||||
|
|
||||||
## 6.6.9
|
## 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)).
|
* Fixed that the chart may not be the same size as the component root element ([#761](https://github.com/ecomfe/vue-echarts/issues/761)).
|
||||||
|
|||||||
10
README.md
10
README.md
@ -236,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.4.19"></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.9"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.10"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ app.component('v-chart', VueECharts)
|
|||||||
```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.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.9"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.10"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -507,3 +507,7 @@ 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/).
|
||||||
|
|||||||
@ -236,9 +236,9 @@ import "echarts";
|
|||||||
|
|
||||||
<!-- vue3Scripts:start -->
|
<!-- vue3Scripts:start -->
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.19"></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.9"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.10"></script>
|
||||||
```
|
```
|
||||||
<!-- vue3Scripts:end -->
|
<!-- vue3Scripts:end -->
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ app.component('v-chart', VueECharts)
|
|||||||
```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.4.3"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.9"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.10"></script>
|
||||||
```
|
```
|
||||||
<!-- vue2Scripts:end -->
|
<!-- vue2Scripts:end -->
|
||||||
|
|
||||||
@ -507,3 +507,7 @@ 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/).
|
||||||
|
|||||||
3
babel.config.js
Normal file
3
babel.config.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
presets: ["@vue/cli-plugin-babel/preset"]
|
||||||
|
};
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": ["@vue/cli-plugin-babel/preset"]
|
|
||||||
}
|
|
||||||
15
package.json
15
package.json
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-echarts",
|
"name": "vue-echarts",
|
||||||
"version": "6.6.9",
|
"version": "6.6.10",
|
||||||
"type": "module",
|
|
||||||
"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": {
|
||||||
@ -29,7 +28,9 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.23.2",
|
"@babel/core": "^7.23.2",
|
||||||
"@highlightjs/vue-plugin": "^2.1.0",
|
"@highlightjs/vue-plugin": "^2.1.0",
|
||||||
|
"@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",
|
||||||
"@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.1.1",
|
||||||
@ -44,7 +45,7 @@
|
|||||||
"@vueuse/core": "^10.5.0",
|
"@vueuse/core": "^10.5.0",
|
||||||
"comment-mark": "^1.1.1",
|
"comment-mark": "^1.1.1",
|
||||||
"core-js": "^3.33.2",
|
"core-js": "^3.33.2",
|
||||||
"echarts": "^5.5.0",
|
"echarts": "^5.4.3",
|
||||||
"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.2",
|
||||||
@ -60,10 +61,10 @@
|
|||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"resize-detector": "^0.3.0",
|
"resize-detector": "^0.3.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rollup": "^4.12.0",
|
"rollup": "^2.79.1",
|
||||||
"rollup-plugin-dts": "^6.1.0",
|
"rollup-plugin-dts": "^4.2.3",
|
||||||
"rollup-plugin-esbuild": "^6.1.1",
|
"rollup-plugin-styles": "^4.0.0",
|
||||||
"rollup-plugin-import-css": "^3.5.0",
|
"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.3.7",
|
||||||
|
|||||||
886
pnpm-lock.yaml
generated
886
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
124
rollup.config.js
124
rollup.config.js
@ -1,8 +1,9 @@
|
|||||||
import esbuild from "rollup-plugin-esbuild";
|
import typescript from "rollup-plugin-ts";
|
||||||
import { dts } from "rollup-plugin-dts";
|
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 css from "rollup-plugin-import-css";
|
import styles from "rollup-plugin-styles";
|
||||||
import { ignoreCss } from "./scripts/rollup.js";
|
import { injectVueDemi } from "./scripts/rollup";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies the Rollup options for a build to support strict CSP
|
* Modifies the Rollup options for a build to support strict CSP
|
||||||
@ -17,7 +18,7 @@ function configBuild(options, csp) {
|
|||||||
result.plugins = [
|
result.plugins = [
|
||||||
...(csp ? [replace({ __CSP__: `${csp}`, preventAssignment: true })] : []),
|
...(csp ? [replace({ __CSP__: `${csp}`, preventAssignment: true })] : []),
|
||||||
...plugins,
|
...plugins,
|
||||||
csp ? css({ output: "style.css" }) : css({ inject: true })
|
csp ? styles({ mode: ["extract", "style.css"] }) : styles()
|
||||||
];
|
];
|
||||||
|
|
||||||
// modify output file names
|
// modify output file names
|
||||||
@ -38,37 +39,97 @@ function configBuild(options, csp) {
|
|||||||
const builds = [
|
const builds = [
|
||||||
{
|
{
|
||||||
input: "src/index.ts",
|
input: "src/index.ts",
|
||||||
plugins: [esbuild()],
|
plugins: [
|
||||||
external: ["vue-demi", /^echarts/, "resize-detector"],
|
typescript({
|
||||||
output: [
|
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",
|
file: "dist/index.esm.js",
|
||||||
format: "esm",
|
format: "esm",
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "src/index.ts",
|
||||||
|
plugins: [typescript()],
|
||||||
|
external: ["vue-demi", "echarts/core", "resize-detector"],
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: "dist/index.esm.min.js",
|
||||||
|
format: "esm",
|
||||||
|
sourcemap: true,
|
||||||
|
plugins: [
|
||||||
|
terser({
|
||||||
|
format: {
|
||||||
|
comments: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "dist/index.cjs.js",
|
file: "dist/index.cjs.js",
|
||||||
format: "cjs",
|
format: "cjs",
|
||||||
exports: "named",
|
exports: "named",
|
||||||
sourcemap: true
|
sourcemap: true
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
input: "src/index.ts",
|
|
||||||
plugins: [esbuild({ minify: true })],
|
|
||||||
external: ["vue-demi", /^echarts/, "resize-detector"],
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
file: "dist/index.esm.min.js",
|
|
||||||
format: "esm",
|
|
||||||
sourcemap: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: "dist/index.cjs.min.js",
|
file: "dist/index.cjs.min.js",
|
||||||
format: "cjs",
|
format: "cjs",
|
||||||
exports: "named",
|
exports: "named",
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
|
plugins: [
|
||||||
|
terser({
|
||||||
|
format: {
|
||||||
|
comments: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: "src/global.ts",
|
||||||
|
plugins: [resolve(), typescript()],
|
||||||
|
external: ["vue-demi", "echarts", "echarts/core"],
|
||||||
|
output: [
|
||||||
|
{
|
||||||
|
file: "dist/index.umd.js",
|
||||||
|
format: "umd",
|
||||||
|
name: "VueECharts",
|
||||||
|
exports: "default",
|
||||||
|
sourcemap: true,
|
||||||
|
globals: {
|
||||||
|
"vue-demi": "VueDemi",
|
||||||
|
echarts: "echarts",
|
||||||
|
"echarts/core": "echarts"
|
||||||
|
},
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -76,22 +137,5 @@ 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.ts",
|
|
||||||
plugins: [
|
|
||||||
ignoreCss,
|
|
||||||
dts({
|
|
||||||
compilerOptions: {
|
|
||||||
// see https://github.com/unjs/unbuild/pull/57/files
|
|
||||||
preserveSymlinks: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
],
|
|
||||||
external: ["vue-demi", /^echarts/, "resize-detector"],
|
|
||||||
output: {
|
|
||||||
file: "dist/index.d.ts",
|
|
||||||
format: "esm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
import { readFileSync, writeFileSync } from "node:fs";
|
const { readFileSync, writeFileSync } = require("fs");
|
||||||
import commentMark from "comment-mark";
|
const { resolve } = require("path");
|
||||||
import { getPackageMeta, resolvePath } from "./utils";
|
const commentMark = require("comment-mark");
|
||||||
|
const { name, version } = require("../package.json");
|
||||||
|
|
||||||
const { name, version } = getPackageMeta();
|
function resolvePath(...parts) {
|
||||||
|
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.19",
|
"vue@3": "3.4.23",
|
||||||
"vue@2": "2.7.16",
|
"vue@2": "2.7.16",
|
||||||
echarts: "5.4.3",
|
echarts: "5.4.3",
|
||||||
[name]: version
|
[name]: version
|
||||||
@ -38,7 +41,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(import.meta.url, "..", name)
|
resolvePath("..", name)
|
||||||
);
|
);
|
||||||
|
|
||||||
README_FILES.forEach(file => {
|
README_FILES.forEach(file => {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
import fs from "node:fs";
|
const path = require("path");
|
||||||
import { resolvePath } from "./utils.js";
|
const fs = require("fs");
|
||||||
|
|
||||||
const packageFile = resolvePath(import.meta.url, "../package.json");
|
const packageFile = path.resolve(__dirname, "../package.json");
|
||||||
|
|
||||||
const typesPaths = {
|
const typesPaths = {
|
||||||
3: "dist/index.d.ts",
|
3: "dist/index.d.ts",
|
||||||
@ -12,40 +12,35 @@ const typesPaths = {
|
|||||||
|
|
||||||
function switchVersion(version) {
|
function switchVersion(version) {
|
||||||
const typesPath = typesPaths[version];
|
const typesPath = typesPaths[version];
|
||||||
const pkg = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
const package = JSON.parse(fs.readFileSync(packageFile, "utf8"));
|
||||||
if (typesPath !== pkg.types) {
|
if (typesPath !== package.types) {
|
||||||
pkg.types = typesPath;
|
package.types = typesPath;
|
||||||
fs.writeFileSync(packageFile, JSON.stringify(pkg, null, " "), "utf8");
|
fs.writeFileSync(packageFile, JSON.stringify(package, null, " "), "utf8");
|
||||||
}
|
}
|
||||||
console.log(`[vue-echarts] Switched to Vue ${version} environment.`);
|
console.log(`[vue-echarts] Switched to Vue ${version} environment.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadVue() {
|
function loadVue() {
|
||||||
try {
|
try {
|
||||||
const Vue = await import("vue");
|
return require("vue");
|
||||||
return Vue;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
const Vue = loadVue();
|
||||||
const Vue = await loadVue();
|
|
||||||
|
|
||||||
// Align the process with vue-demi
|
// Align the process with vue-demi
|
||||||
if (!Vue || typeof Vue.version !== "string") {
|
if (!Vue || typeof Vue.version !== "string") {
|
||||||
console.warn(
|
console.warn(
|
||||||
'[vue-echarts] Vue is not found. Please run "npm install vue" to install.'
|
'[vue-echarts] Vue is not found. Please run "npm install vue" to install.'
|
||||||
);
|
);
|
||||||
} else if (Vue.version.startsWith("3.")) {
|
} else if (Vue.version.startsWith("3.")) {
|
||||||
switchVersion(3);
|
switchVersion(3);
|
||||||
} else if (Vue.version.startsWith("2.7.")) {
|
} else if (Vue.version.startsWith("2.7.")) {
|
||||||
switchVersion(2.7);
|
switchVersion(2.7);
|
||||||
} else if (Vue.version.startsWith("2.")) {
|
} else if (Vue.version.startsWith("2.")) {
|
||||||
switchVersion(2);
|
switchVersion(2);
|
||||||
} else {
|
} else {
|
||||||
console.warn(`[vue-echarts] Vue version v${Vue.version} is not supported.`);
|
console.warn(`[vue-echarts] Vue version v${Vue.version} is not supported.`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
|
||||||
|
|||||||
@ -1,7 +1,22 @@
|
|||||||
|
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__";
|
const EMPTY_FILE_ID = "__rollup_empty__";
|
||||||
|
|
||||||
/** @type {import('rollup').Plugin} */
|
/** @type {import('rollup').Plugin} */
|
||||||
export const ignoreCss = {
|
export const ingoreCss = {
|
||||||
name: "ignore-css",
|
name: "ignore-css",
|
||||||
resolveId(source) {
|
resolveId(source) {
|
||||||
if (source.endsWith(".css")) {
|
if (source.endsWith(".css")) {
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
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,20 +13,11 @@ 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 { 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,
|
||||||
@ -39,8 +30,15 @@ import type {
|
|||||||
UpdateOptionsInjection,
|
UpdateOptionsInjection,
|
||||||
Emits
|
Emits
|
||||||
} from "./types";
|
} from "./types";
|
||||||
import type { EChartsElement } from "./wc";
|
import {
|
||||||
|
usePublicAPI,
|
||||||
|
useAutoresize,
|
||||||
|
autoresizeProps,
|
||||||
|
useLoading,
|
||||||
|
loadingProps
|
||||||
|
} from "./composables";
|
||||||
|
import { omitOn, unwrapInjected } from "./utils";
|
||||||
|
import { register, TAG_NAME, type EChartsElement } from "./wc";
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
const __CSP__ = false;
|
const __CSP__ = false;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import type { Ref } from "vue-demi";
|
import { Ref } from "vue-demi";
|
||||||
import type { EChartsType } from "../types";
|
import { EChartsType } from "../types";
|
||||||
|
|
||||||
const METHOD_NAMES = [
|
const METHOD_NAMES = [
|
||||||
"getWidth",
|
"getWidth",
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
import { watch } from "vue-demi";
|
import { watch, type Ref, type PropType } from "vue-demi";
|
||||||
import { throttle } from "echarts/core";
|
import { throttle } from "echarts/core";
|
||||||
import { addListener, removeListener } from "resize-detector";
|
import {
|
||||||
|
addListener,
|
||||||
import type { Ref, PropType } from "vue-demi";
|
removeListener,
|
||||||
import type { ResizeCallback } from "resize-detector";
|
type ResizeCallback
|
||||||
import type { EChartsType } from "../types";
|
} from "resize-detector";
|
||||||
|
import { type EChartsType } from "../types";
|
||||||
|
|
||||||
type AutoresizeProp =
|
type AutoresizeProp =
|
||||||
| boolean
|
| boolean
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
import { inject, computed, watchEffect } from "vue-demi";
|
|
||||||
import { unwrapInjected } from "../utils";
|
import { unwrapInjected } from "../utils";
|
||||||
|
import {
|
||||||
import type { Ref, InjectionKey, PropType } from "vue-demi";
|
inject,
|
||||||
|
computed,
|
||||||
|
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 =
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
7
src/global.ts
Normal file
7
src/global.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import "echarts";
|
||||||
|
import ECharts, * as exported from "./index";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
...ECharts,
|
||||||
|
...exported
|
||||||
|
};
|
||||||
@ -1,2 +1,2 @@
|
|||||||
x-vue-echarts{display:flex;flex-direction:column;width:100%;height:100%;min-width:0}
|
x-vue-echarts{display:block;position:relative;width:100%;height:100%;min-width:0}
|
||||||
.vue-echarts-inner{flex-grow:1;min-width:0}
|
.vue-echarts-inner{position:absolute;top:0;right:0;bottom:0;left:0}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { init } from "echarts/core";
|
import { init } from "echarts/core";
|
||||||
import type { Ref } from "vue-demi";
|
|
||||||
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts";
|
import type { SetOptionOpts, ECElementEvent, ElementEvent } from "echarts";
|
||||||
|
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 };
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { unref } from "vue-demi";
|
import { unref } from "vue-demi";
|
||||||
|
|
||||||
import type { Injection } from "./types";
|
import type { Injection } from "./types";
|
||||||
|
|
||||||
type Attrs = {
|
type Attrs = {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
import nested from "postcss-nested";
|
const nested = require("postcss-nested");
|
||||||
|
|
||||||
export default {
|
module.exports = {
|
||||||
outputDir: "demo",
|
outputDir: "demo",
|
||||||
css: {
|
css: {
|
||||||
loaderOptions: {
|
loaderOptions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user