Loading...
Loading...
Use when building, auditing, styling, debugging, or optimizing Apache ECharts visualizations in vanilla JavaScript, React, or Vue applications — chart setup, lifecycle management, responsive resizing, theming, large datasets, streaming updates, server-side rendering (SVG in Node), and symptoms like a blank or empty chart, a chart that does not resize or update, stale series after switching chart types, or "component not exists" errors. Not for choosing chart types or visual design, and not for other charting libraries (D3, Chart.js, Highcharts).
npx skill4agent add sentimony/skills echartsUser task -> Does the project already use ECharts?
- Yes -> Find existing chart components/helpers, reuse their init, theme,
and resize patterns. Match import style (full vs echarts/core).
- No -> Pick integration by framework:
- React -> echarts-for-react wrapper, or a small hook around
init/dispose if the project avoids extra deps
- Vue 3 -> vue-echarts wrapper, or composable around init/dispose
- Vanilla / other -> echarts.init on a sized container
Next -> Bundle size a concern (app ships to users)?
- Yes -> Import from 'echarts/core' and register only the used charts,
components, and renderer (tree-shaking)
- No / internal tool / prototype -> import * as echarts from 'echarts'
Then -> Build the smallest working option, render it, then layer on
interactivity (tooltip, dataZoom, toolbox) and theming.echarts.initinitresize()dispose()setOptionnotMerge: truenpm install echarts # core library (always)
npm install echarts-for-react # React wrapper (optional)
npm install vue-echarts # Vue 3 wrapper (optional)import * as echarts from 'echarts/core';
import { LineChart, BarChart } from 'echarts/charts';
import { GridComponent, TooltipComponent, DataZoomComponent } from 'echarts/components';
import { CanvasRenderer } from 'echarts/renderers';
echarts.use([LineChart, BarChart, GridComponent, TooltipComponent, DataZoomComponent, CanvasRenderer]);console.errorecharts.use([...])useimport type { ... } from 'echarts'XAXisComponentOptionDefaultLabelFormatterCallbackParamsimport type'echarts''echarts/core'ComposeOption'echarts/core'import type { ComposeOption } from 'echarts/core';
import type { LineSeriesOption } from 'echarts/charts';
import type { GridComponentOption, TooltipComponentOption } from 'echarts/components';
type ChartOption = ComposeOption<LineSeriesOption | GridComponentOption | TooltipComponentOption>;chart.resize()ResizeObserverchart.dispose()optionnotMergeref.getEchartsInstance()setOptiondispatchActioninitdisposeoption:optionautoresizedispatchAction:update-options="{ notMerge: true }"themeTHEME_KEYupdate-optionsgroupecharts.connectecharts.initecharts.getInstanceByDomdatasetsourceencodedataxAxis: { type: 'time' }[timestamp, value]axisLabel.intervalrotatetrigger: 'axis'trigger: 'item'valueFormattertooltip.formatterformattertooltip.renderMode: 'richText'large: truesampling: 'lttb'animationecharts-glsetOption({ series: [{ data }] })notMergeResizeObserverecharts.connectconnectchart.group = 'name'; echarts.connect('name')groupecharts.registerTheme('name', themeObject)initinit(el, null, ...)darkMode: truechart.setTheme(...)themeecharts.init(null, null, { renderer: 'svg', ssr: true, width, height })renderToSVGString()echarts.use([...])toolbox.feature.saveAsImagechart.getDataURL({ pixelRatio: 2 })grid.containLabelcontainLabel: true{ outerBoundsMode: 'same', outerBoundsContain: 'axisLabel' }grid.outerBoundsLegacyGridContainLabel'echarts/features'containLabel: trueimport 'echarts/theme/v5''v5'initgrid.outerBoundsMode: 'none'xAxis/yAxis.nameMoveOverlap: falsenode_modules/echarts/package.jsonuse([...])use([...])initdisposenotMergeupdate-options'echarts'import typecontainLabelresize()notMerge: truenotMerge: truechart.getOption().legend[0].selectedecharts.use([...])dispose()resizeautoresizetooltip.confine: trueappendToBodytooltip.appendToanimation: falsesampling: 'lttb'large: trueexamples/vanilla_line.htmlexamples/react_chart.tsxexamples/vue_chart.vue