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.
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.
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.
How to use
- Install ECharts:
npm install echarts
- 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' }]
});
- The chart renders automatically with animations, tooltips, and responsive behavior.
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.
Related on TokRepo
- AI design tools -- Explore visualization and design tools for data presentation
- Featured workflows -- Discover other popular tools and libraries on TokRepo
Common pitfalls
- ECharts requires a DOM element with explicit width and height. If the container has zero dimensions when
initis 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
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.
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.
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.
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.
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)
- Apache ECharts— Apache ECharts is an open-source charting library
- ECharts GitHub— 40+ chart types with Canvas and SVG rendering
- Apache License— Apache 2.0 license
Related on TokRepo
Discussion
Related Assets
doctest — The Fastest Feature-Rich C++ Testing Framework
doctest is a single-header C++ testing framework designed for minimal compile-time overhead and maximum speed.
Chai — BDD/TDD Assertion Library for Node.js
Chai is a flexible assertion library for Node.js and browsers that supports expect, should, and assert styles.
Supertest — HTTP Assertion Library for Node.js APIs
Supertest provides a high-level API for testing HTTP servers in Node.js with fluent assertion chaining.