Gathering detailed insights and metrics for vue-echarts
Gathering detailed insights and metrics for vue-echarts
Gathering detailed insights and metrics for vue-echarts
Gathering detailed insights and metrics for vue-echarts
npm install vue-echarts
56
Supply Chain
97
Quality
85.9
Maintenance
100
Vulnerability
97.9
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
9,781 Stars
231 Commits
1,490 Forks
139 Watching
9 Branches
12 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
JavaScript (42.31%)
Vue (34.68%)
TypeScript (22.19%)
HTML (0.74%)
CSS (0.07%)
Cumulative downloads
Total Downloads
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
1
3
43
Vue.js component for Apache ECharts™.
Still using v6? Read v6 docs here →
1npm add echarts vue-echarts
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>
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";
Drop <script>
inside your HTML file and access the component via window.VueECharts
.
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)
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.
init-options: object
Optional chart init configurations. See echarts.init
's opts
parameter here →
Injection key: INIT_OPTIONS_KEY
.
theme: string | object
Theme to be applied. See echarts.init
's theme
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
's opts
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
's opts
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 specifying manual-update
prop with true
and not providing option
prop, the dataset won't be watched any more. After doing so, you need to retrieve the component instance with ref
and manually call setOption
method to update the chart.
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
→zr:click
zr:mousedown
zr:mouseup
zr:mousewheel
zr:dblclick
zr:contextmenu
See supported events here →
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>
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:
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}
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}
setOption
→getWidth
→getHeight
→getDom
→getOption
→resize
→dispatchAction
→convertToPixel
→convertFromPixel
→containPixel
→showLoading
→hideLoading
→getDataURL
→getConnectedDataURL
→clear
→dispose
→Static methods can be accessed from echarts
itself.
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.
Read the breaking changes document in the release log and the migration shoud be straightforward.
1pnpm i 2pnpm serve
Open http://localhost:8080
to see the demo.
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
Reason
SAST tool is not run on all commits -- score normalized to 8
Details
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
15 existing vulnerabilities detected
Details
Score
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