ScriptsApr 11, 2026·2 min read

Apache ECharts — Powerful Interactive Charting Library

Apache ECharts is a powerful, interactive charting and data visualization library for browsers. 40+ chart types, canvas/SVG rendering, streaming data, and GPU acceleration. The enterprise choice used by Alibaba, Baidu, and countless dashboards.

TL;DR
Apache ECharts provides 40+ chart types with canvas/SVG rendering, streaming data, and rich interactive features.
§01

What it is

Apache ECharts is an open-source JavaScript charting library maintained by the Apache Software Foundation. It supports over 40 chart types including line, bar, scatter, pie, radar, treemap, sankey, and geographic maps. The library renders via both Canvas and SVG, handles large datasets with incremental rendering, and supports real-time streaming data.

ECharts targets frontend developers who need rich, interactive data visualizations in web applications. It works in any JavaScript environment -- vanilla JS, React, Vue, Angular -- and supports server-side rendering for static chart generation.

§02

How it saves time or tokens

ECharts uses a declarative options object to define charts. Instead of writing imperative drawing code, you describe what the chart should look like as a JSON-like configuration, and ECharts handles the rendering, animations, tooltips, and interactions. This approach reduces the amount of code needed for complex visualizations.

The library includes built-in responsive sizing, data zoom controls, and export-to-image functionality. These features would take significant development time to build from scratch with lower-level libraries like D3.js.

§03

How to use

  1. Install ECharts:
npm install echarts
  1. Initialize a chart and set options:
import * as echarts from 'echarts';

const chart = echarts.init(document.getElementById('main'));

chart.setOption({
  title: { text: 'Weekly Sales' },
  tooltip: { trigger: 'axis' },
  xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] },
  yAxis: { type: 'value' },
  series: [{ data: [120, 200, 150, 80, 70], type: 'bar' }]
});
  1. The chart renders automatically with animations, tooltips, and responsive behavior.
§04

Example

import * as echarts from 'echarts';

const chart = echarts.init(document.getElementById('chart'));

chart.setOption({
  tooltip: { trigger: 'item' },
  legend: { top: '5%', left: 'center' },
  series: [{
    name: 'Traffic Sources',
    type: 'pie',
    radius: ['40%', '70%'],
    avoidLabelOverlap: false,
    itemStyle: { borderRadius: 10, borderColor: '#fff', borderWidth: 2 },
    label: { show: false, position: 'center' },
    emphasis: { label: { show: true, fontSize: 24, fontWeight: 'bold' } },
    data: [
      { value: 1048, name: 'Search' },
      { value: 735, name: 'Direct' },
      { value: 580, name: 'Email' },
      { value: 484, name: 'Social' },
      { value: 300, name: 'Referral' }
    ]
  }]
});

This creates a donut chart with hover emphasis effects, a legend, and tooltips -- all from a single options object.

§05

Related on TokRepo

§06

Common pitfalls

  • ECharts requires a DOM element with explicit width and height. If the container has zero dimensions when init is called, the chart will not render. Set CSS dimensions on the container before initialization.
  • Importing the full ECharts bundle adds significant bundle size. Use tree-shaking imports (import { BarChart } from 'echarts/charts') to include only the chart types and components you need.
  • Resizing the browser window does not automatically resize charts. Call chart.resize() in a window resize event listener or use ResizeObserver for container-level resizing.

Frequently Asked Questions

How does ECharts compare to D3.js?+

ECharts is a higher-level, declarative charting library. You define what the chart looks like via a configuration object. D3.js is a lower-level library that gives you fine-grained control over SVG/Canvas elements. ECharts is faster for standard chart types; D3 is more flexible for custom or unusual visualizations.

Can ECharts handle large datasets?+

Yes. ECharts supports incremental rendering and data sampling for large datasets. It can render hundreds of thousands of data points using progressive rendering, where the chart builds up over multiple animation frames. The dataset component supports data transforms like filtering and sorting.

Does ECharts work with React and Vue?+

Yes. ECharts works with any frontend framework. The community maintains wrapper libraries like echarts-for-react and vue-echarts that provide component-level integration with lifecycle management. You can also use the core library directly in any framework.

Can I render ECharts on the server?+

Yes. ECharts provides a server-side rendering mode using node-canvas or the SVG renderer. This lets you generate chart images (PNG, SVG) in Node.js for use in emails, PDFs, or static pages without a browser.

Is ECharts free for commercial use?+

Yes. Apache ECharts is released under the Apache 2.0 license, which permits commercial use, modification, and distribution without royalty fees. The Apache Software Foundation maintains the project.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets