mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-11-05 20:36:09 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82a098c416 | |||
| 3da9f285ff | |||
| e48067c5d3 | |||
| 53ebc2941e | |||
| e8697382a1 | |||
| 47f7885f19 | |||
| 9c34d682c4 |
@ -1,3 +1,11 @@
|
||||
## 6.6.1
|
||||
|
||||
* Make `padding` work out-of-the-box.
|
||||
|
||||
## 6.6.0
|
||||
|
||||
* Added support for `autoresize` accepting an options object to specify custom throttle delay or resize callback.
|
||||
|
||||
## 6.5.5
|
||||
|
||||
* Removed the custom element registration enhancement for strict CSP builds so that they won't contain `new Function`.
|
||||
|
||||
14
README.md
14
README.md
@ -225,9 +225,9 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC
|
||||
|
||||
<!-- vue3Scripts:start -->
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.2.45"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.0"></script>
|
||||
```
|
||||
<!-- vue3Scripts:end -->
|
||||
|
||||
@ -246,8 +246,8 @@ app.component('v-chart', VueECharts)
|
||||
<!-- vue2Scripts:start -->
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.0"></script>
|
||||
```
|
||||
<!-- vue2Scripts:end -->
|
||||
|
||||
@ -290,9 +290,9 @@ See more examples [here](https://github.com/ecomfe/vue-echarts/tree/main/src/dem
|
||||
|
||||
Group name to be used in chart [connection](https://echarts.apache.org/en/api.html#echarts.connect). See `echartsInstance.group` [here →](https://echarts.apache.org/en/api.html#echartsInstance.group)
|
||||
|
||||
- `autoresize: boolean` (default: `false`)
|
||||
- `autoresize: boolean | { throttle?: number, onResize?: () => void }` (default: `false`)
|
||||
|
||||
Whether the chart should be resized automatically whenever its root is resized.
|
||||
Whether the chart should be resized automatically whenever its root is resized. Use the options object to specify a custom throttle delay (in milliseconds) and/or an extra resize callback function.
|
||||
|
||||
- `loading: boolean` (default: `false`)
|
||||
|
||||
|
||||
@ -225,9 +225,9 @@ import "echarts";
|
||||
|
||||
<!-- vue3Scripts:start -->
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.2.45"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3.3.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.0"></script>
|
||||
```
|
||||
<!-- vue3Scripts:end -->
|
||||
|
||||
@ -246,8 +246,8 @@ app.component('v-chart', VueECharts)
|
||||
<!-- vue2Scripts:start -->
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.1"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.5.4"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.6.0"></script>
|
||||
```
|
||||
<!-- vue2Scripts:end -->
|
||||
|
||||
@ -290,9 +290,9 @@ Vue.component("v-chart", VueECharts);
|
||||
|
||||
图表的分组,用于[联动](https://echarts.apache.org/zh/api.html#echarts.connect)。请参考 `echartsInstance.group`。[前往 →](https://echarts.apache.org/zh/api.html#echartsInstance.group)
|
||||
|
||||
- `autoresize: boolean`(默认值`false`)
|
||||
- `autoresize: boolean | { throttle?: number, onResize?: () => void }`(默认值`false`)
|
||||
|
||||
图表在组件根元素尺寸变化时是否需要自动进行重绘。
|
||||
图表在组件根元素尺寸变化时是否需要自动进行重绘。也可以传入一个选项对象来指定自定义的节流延迟和尺寸变化时的额外回调函数。
|
||||
|
||||
- `loading: boolean`(默认值:`false`)
|
||||
|
||||
|
||||
44
package.json
44
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-echarts",
|
||||
"version": "6.5.5",
|
||||
"version": "6.6.1",
|
||||
"description": "Vue.js component for Apache ECharts.",
|
||||
"author": "GU Yiling <justice360@gmail.com>",
|
||||
"scripts": {
|
||||
@ -23,47 +23,49 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"resize-detector": "^0.3.0",
|
||||
"vue-demi": "^0.13.2"
|
||||
"vue-demi": "^0.13.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@rollup/plugin-node-resolve": "^11.2.1",
|
||||
"@babel/core": "^7.22.9",
|
||||
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||
"@rollup/plugin-replace": "^5.0.2",
|
||||
"@rollup/plugin-terser": "^0.4.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@vue/cli-plugin-babel": "^5.0.7",
|
||||
"@vue/cli-plugin-eslint": "^5.0.7",
|
||||
"@vue/cli-plugin-typescript": "^5.0.7",
|
||||
"@vue/cli-service": "^5.0.7",
|
||||
"@vue/compiler-sfc": "^3.2.37",
|
||||
"@vue/composition-api": "^1.7.0",
|
||||
"@vercel/analytics": "^1.0.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.3.4",
|
||||
"@vue/composition-api": "^1.7.1",
|
||||
"@vue/eslint-config-prettier": "^6.0.0",
|
||||
"@vue/eslint-config-typescript": "^10.0.0",
|
||||
"comment-mark": "^1.1.1",
|
||||
"core-js": "^3.23.3",
|
||||
"echarts": "^5.4.1",
|
||||
"core-js": "^3.32.0",
|
||||
"echarts": "^5.4.3",
|
||||
"echarts-liquidfill": "^3.1.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-prettier": "^3.4.1",
|
||||
"eslint-plugin-vue": "^8.7.1",
|
||||
"postcss": "^8.4.14",
|
||||
"pinia": "^2.1.6",
|
||||
"postcss": "^8.4.27",
|
||||
"postcss-loader": "^5.3.0",
|
||||
"postcss-nested": "^5.0.6",
|
||||
"prettier": "^2.7.1",
|
||||
"qs": "^6.11.0",
|
||||
"prettier": "^2.8.8",
|
||||
"qs": "^6.11.2",
|
||||
"raw-loader": "^4.0.2",
|
||||
"resize-detector": "^0.3.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.75.7",
|
||||
"rollup-plugin-dts": "^4.2.2",
|
||||
"rollup": "^2.79.1",
|
||||
"rollup-plugin-dts": "^4.2.3",
|
||||
"rollup-plugin-styles": "^4.0.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-ts": "^2.0.7",
|
||||
"tslib": "^2.4.0",
|
||||
"tslib": "^2.6.1",
|
||||
"typescript": "4.6.4",
|
||||
"vue": "^3.2.37",
|
||||
"vue": "^3.3.4",
|
||||
"vue2": "npm:vue@^2.7.14",
|
||||
"webpack": "^5.73.0"
|
||||
"webpack": "^5.88.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.5",
|
||||
|
||||
4837
pnpm-lock.yaml
generated
4837
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
import typescript from "rollup-plugin-ts";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import replace from "@rollup/plugin-replace";
|
||||
import styles from "rollup-plugin-styles";
|
||||
|
||||
@ -1,16 +1,18 @@
|
||||
const fs = require("fs");
|
||||
const { readFileSync, writeFileSync } = require("fs");
|
||||
const { resolve } = require("path");
|
||||
const commentMark = require("comment-mark");
|
||||
const { name, version } = require("../package.json");
|
||||
|
||||
const { readFile, writeFile } = fs.promises;
|
||||
function resolvePath(...parts) {
|
||||
return resolve(__dirname, ...parts);
|
||||
}
|
||||
|
||||
const CDN_PREFIX = "https://cdn.jsdelivr.net/npm/";
|
||||
|
||||
const DEP_VERSIONS = {
|
||||
"vue@3": "3.2.45",
|
||||
"vue@3": "3.3.4",
|
||||
"vue@2": "2.7.14",
|
||||
echarts: "5.4.1",
|
||||
echarts: "5.4.3",
|
||||
[name]: version
|
||||
};
|
||||
|
||||
@ -39,29 +41,20 @@ const scripts = {
|
||||
};
|
||||
|
||||
const README_FILES = ["README.md", "README.zh-Hans.md"].map(name =>
|
||||
resolve(__dirname, "..", name)
|
||||
resolvePath("..", name)
|
||||
);
|
||||
|
||||
function exec() {
|
||||
return Promise.all(
|
||||
README_FILES.map(async file => {
|
||||
const content = await readFile(file, "utf8");
|
||||
README_FILES.forEach(file => {
|
||||
const content = readFileSync(file, "utf8");
|
||||
|
||||
return writeFile(
|
||||
file,
|
||||
commentMark(content, {
|
||||
vue2Scripts: getCodeBlock(scripts[2]),
|
||||
vue3Scripts: getCodeBlock(scripts[3])
|
||||
}),
|
||||
"utf8"
|
||||
);
|
||||
})
|
||||
writeFileSync(
|
||||
file,
|
||||
commentMark(content, {
|
||||
vue2Scripts: getCodeBlock(scripts[2]),
|
||||
vue3Scripts: getCodeBlock(scripts[3])
|
||||
}),
|
||||
"utf8"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
async function main() {
|
||||
await exec();
|
||||
console.log("README files updated.");
|
||||
}
|
||||
|
||||
main();
|
||||
console.log("README files updated.");
|
||||
|
||||
@ -73,6 +73,7 @@ export default defineComponent({
|
||||
inheritAttrs: false,
|
||||
setup(props, { attrs }) {
|
||||
const root = shallowRef<EChartsElement>();
|
||||
const inner = shallowRef<HTMLElement>();
|
||||
const chart = shallowRef<EChartsType>();
|
||||
const manualOption = shallowRef<Option>();
|
||||
const defaultTheme = inject(THEME_KEY, null);
|
||||
@ -99,12 +100,12 @@ export default defineComponent({
|
||||
const listeners = getCurrentInstance().proxy.$listeners;
|
||||
|
||||
function init(option?: Option) {
|
||||
if (!root.value) {
|
||||
if (!inner.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const instance = (chart.value = initChart(
|
||||
root.value,
|
||||
inner.value,
|
||||
realTheme.value,
|
||||
realInitOptions.value
|
||||
));
|
||||
@ -271,7 +272,7 @@ export default defineComponent({
|
||||
|
||||
useLoading(chart, loading, loadingOptions);
|
||||
|
||||
useAutoresize(chart, autoresize, root);
|
||||
useAutoresize(chart, autoresize, inner);
|
||||
|
||||
onMounted(() => {
|
||||
init();
|
||||
@ -292,6 +293,7 @@ export default defineComponent({
|
||||
return {
|
||||
chart,
|
||||
root,
|
||||
inner,
|
||||
setOption,
|
||||
nonEventAttrs,
|
||||
...publicApi
|
||||
@ -305,6 +307,6 @@ export default defineComponent({
|
||||
) as any;
|
||||
attrs.ref = "root";
|
||||
attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts";
|
||||
return h(TAG_NAME, attrs);
|
||||
return h(TAG_NAME, attrs, [h("div", { ref: "inner" })]);
|
||||
}
|
||||
});
|
||||
|
||||
@ -20,7 +20,7 @@ const METHOD_NAMES = [
|
||||
"dispose"
|
||||
] as const;
|
||||
|
||||
type MethodName = typeof METHOD_NAMES[number];
|
||||
type MethodName = (typeof METHOD_NAMES)[number];
|
||||
|
||||
type PublicMethods = Pick<EChartsType, MethodName>;
|
||||
|
||||
|
||||
@ -1,26 +1,42 @@
|
||||
import { Ref, watch } from "vue-demi";
|
||||
import { watch, type Ref, type PropType } from "vue-demi";
|
||||
import { throttle } from "echarts/core";
|
||||
import { addListener, removeListener, ResizeCallback } from "resize-detector";
|
||||
import { EChartsType } from "../types";
|
||||
import {
|
||||
addListener,
|
||||
removeListener,
|
||||
type ResizeCallback
|
||||
} from "resize-detector";
|
||||
import { type EChartsType } from "../types";
|
||||
|
||||
type AutoresizeProp =
|
||||
| boolean
|
||||
| {
|
||||
throttle?: number;
|
||||
onResize?: () => void;
|
||||
};
|
||||
|
||||
export function useAutoresize(
|
||||
chart: Ref<EChartsType | undefined>,
|
||||
autoresize: Ref<boolean>,
|
||||
autoresize: Ref<AutoresizeProp | undefined>,
|
||||
root: Ref<HTMLElement | undefined>
|
||||
): void {
|
||||
let resizeListener: ResizeCallback | null = null;
|
||||
|
||||
watch([root, chart, autoresize], ([root, chart, autoresize], _, cleanup) => {
|
||||
if (root && chart && autoresize) {
|
||||
resizeListener = throttle(() => {
|
||||
chart.resize();
|
||||
}, 100);
|
||||
const autoresizeOptions = autoresize === true ? {} : autoresize;
|
||||
const { throttle: wait = 100, onResize } = autoresizeOptions;
|
||||
|
||||
const callback = () => {
|
||||
chart.resize();
|
||||
onResize?.();
|
||||
};
|
||||
|
||||
resizeListener = wait ? throttle(callback, wait) : callback;
|
||||
addListener(root, resizeListener);
|
||||
}
|
||||
|
||||
cleanup(() => {
|
||||
if (resizeListener && root) {
|
||||
if (root && resizeListener) {
|
||||
removeListener(root, resizeListener);
|
||||
}
|
||||
});
|
||||
@ -28,5 +44,5 @@ export function useAutoresize(
|
||||
}
|
||||
|
||||
export const autoresizeProps = {
|
||||
autoresize: Boolean
|
||||
autoresize: [Boolean, Object] as PropType<AutoresizeProp>
|
||||
};
|
||||
|
||||
@ -4,21 +4,20 @@ import {
|
||||
computed,
|
||||
watchEffect,
|
||||
type Ref,
|
||||
type InjectionKey
|
||||
type InjectionKey,
|
||||
type PropType
|
||||
} from "vue-demi";
|
||||
import { EChartsType } from "../types";
|
||||
import type { EChartsType, LoadingOptions } from "../types";
|
||||
|
||||
export const LOADING_OPTIONS_KEY =
|
||||
"ecLoadingOptions" as unknown as InjectionKey<
|
||||
UnknownRecord | Ref<UnknownRecord>
|
||||
LoadingOptions | Ref<LoadingOptions>
|
||||
>;
|
||||
|
||||
type UnknownRecord = Record<string, unknown>;
|
||||
|
||||
export function useLoading(
|
||||
chart: Ref<EChartsType | undefined>,
|
||||
loading: Ref<boolean>,
|
||||
loadingOptions: Ref<UnknownRecord | undefined>
|
||||
loadingOptions: Ref<LoadingOptions | undefined>
|
||||
): void {
|
||||
const defaultLoadingOptions = inject(LOADING_OPTIONS_KEY, {});
|
||||
const realLoadingOptions = computed(() => ({
|
||||
@ -42,5 +41,5 @@ export function useLoading(
|
||||
|
||||
export const loadingProps = {
|
||||
loading: Boolean,
|
||||
loadingOptions: Object
|
||||
loadingOptions: Object as PropType<LoadingOptions>
|
||||
};
|
||||
|
||||
@ -165,8 +165,8 @@
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- <h2 id="radar">
|
||||
<a href="#radar">Radar chart <small>(with Vuex integration)</small></a>
|
||||
<h2 id="radar">
|
||||
<a href="#radar">Radar chart <small>(with Pinia integration)</small></a>
|
||||
<button
|
||||
:class="{
|
||||
round: true,
|
||||
@ -179,20 +179,35 @@
|
||||
<section v-if="expand.radar">
|
||||
<figure>
|
||||
<v-chart
|
||||
class="echarts" :option="scoreRadar" :init-options="initOptions" autoresize />
|
||||
:option="getRadarData(metricIndex)"
|
||||
:init-options="initOptions"
|
||||
autoresize
|
||||
/>
|
||||
</figure>
|
||||
<p>
|
||||
<select v-model="metricIndex">
|
||||
<option v-for="(metric, index) in metrics" :value="index" :key="index"
|
||||
>{{ metric }}
|
||||
<option
|
||||
v-for="(metric, index) in metrics"
|
||||
:value="index"
|
||||
:key="index"
|
||||
>
|
||||
{{ metric }}
|
||||
</option>
|
||||
</select>
|
||||
<button @click="increase(1)" :disabled="isMax">Increase</button>
|
||||
<button @click="increase(-1)" :disabled="isMin">Decrease</button>
|
||||
<input id="async" type="checkbox" v-model="asyncCount" />
|
||||
<label for="async">Async</label>
|
||||
<button
|
||||
@click="increase(metricIndex, 1)"
|
||||
:disabled="isMax(metricIndex)"
|
||||
>
|
||||
Increase
|
||||
</button>
|
||||
<button
|
||||
@click="increase(metricIndex, -1)"
|
||||
:disabled="isMin(metricIndex)"
|
||||
>
|
||||
Decrease
|
||||
</button>
|
||||
</p>
|
||||
</section>-->
|
||||
</section>
|
||||
|
||||
<h2 id="connect">
|
||||
<a href="#connect">Connectable charts</a>
|
||||
@ -334,6 +349,7 @@ import {
|
||||
} from "echarts/components";
|
||||
import { CanvasRenderer, SVGRenderer } from "echarts/renderers";
|
||||
import "echarts-liquidfill";
|
||||
import { mapState, mapActions } from "pinia";
|
||||
import logo from "./data/logo";
|
||||
import getBar from "./data/bar";
|
||||
import pie from "./data/pie";
|
||||
@ -341,6 +357,7 @@ import polar from "./data/polar";
|
||||
import scatter from "./data/scatter";
|
||||
import map from "./data/map";
|
||||
import { c1, c2 } from "./data/connect";
|
||||
import { useScoreStore } from "./store";
|
||||
|
||||
// custom theme
|
||||
import theme from "./theme.json";
|
||||
@ -434,6 +451,15 @@ export default {
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
autoresize() {
|
||||
return { throttle: 200, onResize: this.handleResize };
|
||||
},
|
||||
...mapState(useScoreStore, ["scores"]),
|
||||
metrics() {
|
||||
return this.scores.map(({ name }) => name);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick(...args) {
|
||||
console.log("click from echarts", ...args);
|
||||
@ -441,6 +467,9 @@ export default {
|
||||
handleZrClick(...args) {
|
||||
console.log("click from zrender", ...args);
|
||||
},
|
||||
handleResize() {
|
||||
console.log("resize");
|
||||
},
|
||||
refresh() {
|
||||
// simulating async data from server
|
||||
this.seconds = 3;
|
||||
@ -566,7 +595,8 @@ export default {
|
||||
},
|
||||
stopActions() {
|
||||
clearInterval(this.actionTimer);
|
||||
}
|
||||
},
|
||||
...mapActions(useScoreStore, ["getRadarData", "increase", "isMax", "isMin"])
|
||||
},
|
||||
watch: {
|
||||
connected: {
|
||||
|
||||
@ -1,4 +1,11 @@
|
||||
import { inject } from "@vercel/analytics";
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia";
|
||||
import Demo from "./Demo.vue";
|
||||
|
||||
createApp(Demo).mount("#app");
|
||||
inject();
|
||||
|
||||
const pinia = createPinia();
|
||||
const app = createApp(Demo);
|
||||
app.use(pinia);
|
||||
app.mount("#app");
|
||||
|
||||
76
src/demo/store.ts
Normal file
76
src/demo/store.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useScoreStore = defineStore("score", {
|
||||
state: () => {
|
||||
return {
|
||||
scores: [
|
||||
{ name: "Attack", max: 20, value: 19 },
|
||||
{ name: "Defense", max: 20, value: 9 },
|
||||
{ name: "Speed", max: 20, value: 18 },
|
||||
{ name: "Strength", max: 20, value: 16 },
|
||||
{ name: "Endurance", max: 20, value: 16 },
|
||||
{ name: "Agility", max: 20, value: 20 }
|
||||
],
|
||||
index: 0
|
||||
};
|
||||
},
|
||||
getters: {
|
||||
scoreRadar({ scores }) {
|
||||
return {
|
||||
title: {
|
||||
text: "Player Ability"
|
||||
},
|
||||
tooltip: {},
|
||||
radar: {
|
||||
indicator: scores.map(({ name, max }) => {
|
||||
return { name, max };
|
||||
})
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: "Value",
|
||||
type: "radar",
|
||||
data: [{ value: scores.map(({ value }) => value) }]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
getRadarData(activeIndex: number) {
|
||||
return {
|
||||
animation: false,
|
||||
title: {
|
||||
text: "Player Ability"
|
||||
},
|
||||
tooltip: {},
|
||||
radar: {
|
||||
indicator: this.scores.map(({ name, max }, index) => {
|
||||
if (index === activeIndex) {
|
||||
return { name, max, color: "goldenrod" };
|
||||
}
|
||||
return { name, max };
|
||||
})
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: "Value",
|
||||
type: "radar",
|
||||
data: [{ value: this.scores.map(({ value }) => value) }]
|
||||
}
|
||||
]
|
||||
};
|
||||
},
|
||||
increase(index: number, amount: number) {
|
||||
const metric = this.scores[index];
|
||||
metric.value = Math.max(Math.min(metric.value + amount, metric.max), 0);
|
||||
},
|
||||
isMax(index: number) {
|
||||
const { value, max } = this.scores[index];
|
||||
return value === max;
|
||||
},
|
||||
isMin(index: number) {
|
||||
return this.scores[index].value === 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1 +1 @@
|
||||
x-vue-echarts{display:block;width:100%;height:100%;min-width:0}
|
||||
x-vue-echarts{display:block;width:100%;height:100%;min-width:0}x-vue-echarts>div{width:100%;height:100%}
|
||||
|
||||
15
src/types.ts
15
src/types.ts
@ -25,6 +25,21 @@ export type EventTarget = EChartsType | ZRenderType;
|
||||
type SetOptionType = EChartsType["setOption"];
|
||||
export type Option = Parameters<SetOptionType>[0];
|
||||
|
||||
export type LoadingOptions = {
|
||||
text?: string;
|
||||
textColor?: string;
|
||||
fontSize?: number | string;
|
||||
fontWeight?: number | string;
|
||||
fontStyle?: string;
|
||||
fontFamily?: string;
|
||||
maskColor?: string;
|
||||
showSpinner?: boolean;
|
||||
color?: string;
|
||||
spinnerRadius?: number;
|
||||
lineWidth?: number;
|
||||
zlevel?: number;
|
||||
};
|
||||
|
||||
type MouseEventName =
|
||||
| "click"
|
||||
| "dblclick"
|
||||
|
||||
Reference in New Issue
Block a user