Installations
npm install vue-echarts
Score
56
Supply Chain
97
Quality
85.9
Maintenance
100
Vulnerability
97.9
License
Releases
Contributors
Developer
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
20.10.0
NPM Version
10.2.3
Statistics
9,781 Stars
231 Commits
1,490 Forks
139 Watching
9 Branches
12 Contributors
Updated on 27 Nov 2024
Bundle Size
6.01 kB
Minified
2.38 kB
Minified + Gzipped
Languages
JavaScript (42.31%)
Vue (34.68%)
TypeScript (22.19%)
HTML (0.74%)
CSS (0.07%)
Total Downloads
Cumulative downloads
Total Downloads
12,055,043
Last day
-2.2%
17,927
Compared to previous day
Last week
4.8%
98,686
Compared to previous week
Last month
11.2%
415,244
Compared to previous month
Last year
44.2%
4,008,017
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Peer Dependencies
3
Dev Dependencies
43
Vue-ECharts
Vue.js component for Apache ECharts™.
Still using v6? Read v6 docs here →
Installation & Usage
npm
1npm add echarts vue-echarts
Example
Vue 3 Demo →
1<template> 2 <v-chart class="chart" :option="option" /> 3</template> 4 5<script setup> 6import { use } from "echarts/core"; 7import { CanvasRenderer } from "echarts/renderers"; 8import { PieChart } from "echarts/charts"; 9import { 10 TitleComponent, 11 TooltipComponent, 12 LegendComponent 13} from "echarts/components"; 14import VChart, { THEME_KEY } from "vue-echarts"; 15import { ref, provide } from "vue"; 16 17use([ 18 CanvasRenderer, 19 PieChart, 20 TitleComponent, 21 TooltipComponent, 22 LegendComponent 23]); 24 25provide(THEME_KEY, "dark"); 26 27const option = ref({ 28 title: { 29 text: "Traffic Sources", 30 left: "center" 31 }, 32 tooltip: { 33 trigger: "item", 34 formatter: "{a} <br/>{b} : {c} ({d}%)" 35 }, 36 legend: { 37 orient: "vertical", 38 left: "left", 39 data: ["Direct", "Email", "Ad Networks", "Video Ads", "Search Engines"] 40 }, 41 series: [ 42 { 43 name: "Traffic Sources", 44 type: "pie", 45 radius: "55%", 46 center: ["50%", "60%"], 47 data: [ 48 { value: 335, name: "Direct" }, 49 { value: 310, name: "Email" }, 50 { value: 234, name: "Ad Networks" }, 51 { value: 135, name: "Video Ads" }, 52 { value: 1548, name: "Search Engines" } 53 ], 54 emphasis: { 55 itemStyle: { 56 shadowBlur: 10, 57 shadowOffsetX: 0, 58 shadowColor: "rgba(0, 0, 0, 0.5)" 59 } 60 } 61 } 62 ] 63}); 64</script> 65 66<style scoped> 67.chart { 68 height: 400px; 69} 70</style>
Vue 2 Demo →
1<template> 2 <v-chart class="chart" :option="option" /> 3</template> 4 5<script> 6import { use } from "echarts/core"; 7import { CanvasRenderer } from "echarts/renderers"; 8import { PieChart } from "echarts/charts"; 9import { 10 TitleComponent, 11 TooltipComponent, 12 LegendComponent 13} from "echarts/components"; 14import VChart, { THEME_KEY } from "vue-echarts"; 15 16use([ 17 CanvasRenderer, 18 PieChart, 19 TitleComponent, 20 TooltipComponent, 21 LegendComponent 22]); 23 24export default { 25 name: "HelloWorld", 26 components: { 27 VChart 28 }, 29 provide: { 30 [THEME_KEY]: "dark" 31 }, 32 data() { 33 return { 34 option: { 35 title: { 36 text: "Traffic Sources", 37 left: "center" 38 }, 39 tooltip: { 40 trigger: "item", 41 formatter: "{a} <br/>{b} : {c} ({d}%)" 42 }, 43 legend: { 44 orient: "vertical", 45 left: "left", 46 data: [ 47 "Direct", 48 "Email", 49 "Ad Networks", 50 "Video Ads", 51 "Search Engines" 52 ] 53 }, 54 series: [ 55 { 56 name: "Traffic Sources", 57 type: "pie", 58 radius: "55%", 59 center: ["50%", "60%"], 60 data: [ 61 { value: 335, name: "Direct" }, 62 { value: 310, name: "Email" }, 63 { value: 234, name: "Ad Networks" }, 64 { value: 135, name: "Video Ads" }, 65 { value: 1548, name: "Search Engines" } 66 ], 67 emphasis: { 68 itemStyle: { 69 shadowBlur: 10, 70 shadowOffsetX: 0, 71 shadowColor: "rgba(0, 0, 0, 0.5)" 72 } 73 } 74 } 75 ] 76 } 77 }; 78 } 79}; 80</script> 81 82<style scoped> 83.chart { 84 height: 400px; 85} 86</style>
[!IMPORTANT] We encourage manually importing components and charts from ECharts for smaller bundle size. We've built an import code generator to help you with that. You can just paste in your
option
code and we'll generate the precise import code 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:
1import "echarts";
CDN
Drop <script>
inside your HTML file and access the component via window.VueECharts
.
Vue 3 Demo →
1<script src="https://cdn.jsdelivr.net/npm/vue@3.4.33"></script> 2<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script> 3<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
1const app = Vue.createApp(...) 2 3// register globally (or you can do it locally) 4app.component('v-chart', VueECharts)
Vue 2 Demo →
1<script src="https://cdn.jsdelivr.net/npm/vue@2.7.16"></script> 2<script src="https://cdn.jsdelivr.net/npm/echarts@5.5.1"></script> 3<script src="https://cdn.jsdelivr.net/npm/vue-echarts@7.0.3"></script>
1// register globally (or you can do it locally)
2Vue.component("v-chart", VueECharts);
See more examples here.
Props
-
init-options: object
Optional chart init configurations. See
echarts.init
'sopts
parameter here →Injection key:
INIT_OPTIONS_KEY
. -
theme: string | object
Theme to be applied. See
echarts.init
'stheme
parameter here →Injection key:
THEME_KEY
. -
option: object
ECharts' universal interface. Modifying this prop will trigger ECharts'
setOption
method. Read more here →💡 When
update-options
is not specified,notMerge: false
will be specified by default when thesetOption
method is called if theoption
object is modified directly and the reference remains unchanged; otherwise, if a new reference is bound tooption
,notMerge: true
will be specified. -
update-options: object
Options for updating chart option. See
echartsInstance.setOption
'sopts
parameter here →Injection key:
UPDATE_OPTIONS_KEY
. -
group: string
Group name to be used in chart connection. See
echartsInstance.group
here → -
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: object
Configuration item of loading animation. See
echartsInstance.showLoading
'sopts
parameter here →Injection key:
LOADING_OPTIONS_KEY
. -
manual-update: boolean
(default:false
)For performance critical scenarios (having a large dataset) we'd better bypass Vue's reactivity system for
option
prop. By specifyingmanual-update
prop withtrue
and not providingoption
prop, the dataset won't be watched any more. After doing so, you need to retrieve the component instance withref
and manually callsetOption
method to update the chart.
Events
You can bind events with Vue's v-on
directive.
1<template> 2 <v-chart :option="option" @highlight="handleHighlight" /> 3</template>
Note
Only the
.once
event 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
- ZRender events
zr:click
zr:mousedown
zr:mouseup
zr:mousewheel
zr:dblclick
zr:contextmenu
See supported events here →
Native DOM Events
As Vue-ECharts binds events to the ECharts instance by default, there is some caveat when using native DOM events. You need to prefix the event name with native:
to bind native DOM events (or you can use the .native
modifier in Vue 2, which is dropped in Vue 3).
1<template> 2 <v-chart @native:click="handleClick" /> 3</template>
Provide / Inject
Vue-ECharts provides provide/inject API for theme
, init-options
, update-options
and loading-options
to help configuring contextual options. eg. for init-options
you can use the provide API like this:
Vue 3
1import { THEME_KEY } from 'vue-echarts' 2import { provide } from 'vue' 3 4// composition API 5provide(THEME_KEY, 'dark') 6 7// options API 8{ 9 provide: { 10 [THEME_KEY]: 'dark' 11 } 12}
Vue 2
1import { THEME_KEY } from 'vue-echarts' 2 3// in component options 4{ 5 provide: { 6 [THEME_KEY]: 'dark' 7 } 8}
Note
You need to provide an object for Vue 2 if you want to change it dynamically.
1// in component options 2{ 3 data () { 4 return { 5 theme: { value: 'dark' } 6 } 7 }, 8 provide () { 9 return { 10 [THEME_KEY]: this.theme 11 } 12 } 13}
Methods
setOption
→getWidth
→getHeight
→getDom
→getOption
→resize
→dispatchAction
→convertToPixel
→convertFromPixel
→containPixel
→showLoading
→hideLoading
→getDataURL
→getConnectedDataURL
→clear
→dispose
→
Static Methods
Static methods can be accessed from echarts
itself.
CSP: style-src
or style-src-elem
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 v7
Read the breaking changes document in the release log and the migration shoud be straightforward.
Local development
1pnpm i 2pnpm serve
Open http://localhost:8080
to see the demo.
Notice
The Apache Software Foundation Apache ECharts, ECharts, Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the Apache Software Foundation.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool is not run on all commits -- score normalized to 8
Details
- Warn: 14 commits out of 16 are checked with a SAST tool
Reason
Found 2/18 approved changesets -- score normalized to 1
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
15 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.6
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More