Vue Echarts
Vue.js component for Apache ECharts™.
Install / Use
npx skills add ecomfe/vue-echartsInstalls into whichever agent you are using.
README
Still using Vue 2? Read v7 docs here →
Installation & usage
npm
npm install echarts vue-echarts
Example
<details open> <summary><a href="https://stackblitz.com/edit/vue-echarts-8?file=src%2FApp.vue">Demo →</a></summary><template>
<VChart class="chart" :option="option" />
</template>
<script setup>
import { use } from "echarts/core";
import { CanvasRenderer } from "echarts/renderers";
import { PieChart } from "echarts/charts";
import { TitleComponent, TooltipComponent, LegendComponent } from "echarts/components";
import VChart, { THEME_KEY } from "vue-echarts";
import { ref, provide } from "vue";
use([CanvasRenderer, PieChart, TitleComponent, TooltipComponent, LegendComponent]);
provide(THEME_KEY, "dark");
const option = ref({
title: {
text: "Traffic Sources",
left: "center",
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
legend: {
orient: "vertical",
left: "left",
data: ["Direct", "Email", "Ad Networks", "Video Ads", "Search Engines"],
},
series: [
{
name: "Traffic Sources",
type: "pie",
radius: "55%",
center: ["50%", "60%"],
data: [
{ value: 335, name: "Direct" },
{ value: 310, name: "Email" },
{ value: 234, name: "Ad Networks" },
{ value: 135, name: "Video Ads" },
{ value: 1548, name: "Search Engines" },
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
],
});
</script>
<style scoped>
.chart {
height: 400px;
}
</style>
</details>
On-demand importing <sup><a href="#on-demand-importing"><img src="https://img.shields.io/badge/recommended-10B981" alt="recommended" align="middle" height="16"></a></sup>
To keep your bundle size small, we recommend manually importing the components and charts you need from ECharts. To make this easier, we’ve created an import code generator. Simply paste your option code into the tool, and it will generate the exact import statements for you.
But if you really want to import the whole ECharts bundle without having to import modules manually, just add this in your code:
import "echarts";
CDN
Drop <script> inside your HTML file and access the component via window.VueECharts.
<script src="https://cdn.jsdelivr.net/npm/echarts@6.1.0"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3.5.40"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@8.1.0"></script>
<!-- scripts:end -->
const app = Vue.createApp(...)
// register globally (or you can do it locally)
app.component('VChart', VueECharts)
</details>
See more examples here.
Props
-
init-options: objectOptional chart init configurations. See
echarts.init'soptsparameter here →Injection key:
INIT_OPTIONS_KEY. -
theme: string | objectTheme to be applied. See
echarts.init'sthemeparameter here →Injection key:
THEME_KEY. -
option: objectECharts' universal interface. Modifying this prop triggers Vue ECharts to compute an update plan and call
setOption. Read more here →Smart update
- If you supply
update-options(via prop or injection), Vue ECharts forwards it directly tosetOptionand skips the planner. - Manual
setOptioncalls (only available whenmanual-updateistrue) behave like native ECharts, honouring only the per-call override you pass in and are not carried across re-initializations. - Otherwise, Vue ECharts analyses the change: removed objects become
null, removed arrays become[]withreplaceMerge, ID/anonymous deletions triggerreplaceMerge, and risky changes fall back tonotMerge: true.
- If you supply
-
update-options: objectOptions for updating chart option. If supplied (or injected), Vue ECharts forwards it directly to
setOption, skipping the smart update. SeeechartsInstance.setOption'soptsparameter here →Injection key:
UPDATE_OPTIONS_KEY. -
group: stringGroup name to be used in chart connection. See
echartsInstance.grouphere → -
autoresize: boolean | { throttle?: number, onResize?: () => void }(default:false)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)Whether the chart is in loading state.
-
loading-options: objectConfiguration item of loading animation. See
echartsInstance.showLoading'soptsparameter here →Injection key:
LOADING_OPTIONS_KEY. -
manual-update: boolean(default:false)Handy for performance-sensitive charts (large or high-frequency updates). When set to
true, Vue only uses theoptionprop for the initial render; later prop changes do nothing and you must drive updates viasetOptionon a template ref. If the chart re-initializes (for example due toinit-optionschanges, flippingmanual-update, or a remount), the manual state is discarded and the chart is rendered again from the currentoptionvalue.
Events
You can bind events with Vue's v-on directive.
<template>
<VChart :option="option" @highlight="handleHighlight" />
</template>
[!NOTE] Only the
.onceevent modifier is supported as other modifiers are tightly coupled with the DOM event system.
Vue ECharts support the following events:
highlight→downplay→selectchanged→legendselectchanged→legendselected→legendunselected→legendselectall→legendinverseselect→legendscroll→datazoom→datarangeselected→timelinechanged→timelineplaychanged→restore→dataviewchanged→magictypechanged→geoselectchanged→geoselected→geounselected→axisareaselected→brush→brushEnd→brushselected→globalcursortaken→rendered→finished→- Mouse events
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.7kCommit, push, and open a PR
