Quick Start
This guide will walk you through creating your first interactive chart with Apache ECharts. By the end, you’ll have a working chart and understand the basic concepts.Prerequisites
Install ECharts
Make sure you have ECharts installed in your project. See the Installation Guide if you haven’t already.
Creating Your First Chart
Prepare a DOM container
First, create an HTML element with explicit dimensions to hold your chart:
The container must have a defined width and height. ECharts cannot render in a container with zero dimensions.
Initialize the chart instance
Import ECharts and initialize a chart instance using The
echarts.init():init() function returns an ECharts instance that you’ll use to configure and update your chart.Configure the chart options
Define your chart configuration using an option object. This example creates a simple bar chart:Let’s break down the key components:
- title: The chart title displayed at the top
- tooltip: Enables interactive tooltips on hover
- xAxis: Defines the x-axis (category type for discrete values)
- yAxis: Defines the y-axis (value type for continuous values)
- series: The actual data and chart type (bar, line, pie, etc.)
Complete Example
Here’s the complete code for your first chart:Try Different Chart Types
Changing the chart type is as simple as modifying thetype property in the series:
Updating Charts
You can update your chart by callingsetOption() again with new data:
Responsive Charts
Make your chart responsive to window resizing:Common Chart Configurations
Adding Multiple Series
Display multiple datasets on the same chart:Custom Colors
Customize the color palette:Enhanced Tooltips
Customize the tooltip formatter:Next Steps
Now that you’ve created your first chart, explore more features:Chart Examples
Browse hundreds of chart examples and copy the code
Configuration Manual
Deep dive into all available configuration options
API Reference
Learn about chart instance methods and events
Extensions
Discover community extensions and integrations
Tips and Best Practices
Memory Management: Always call
myChart.dispose() when you’re done with a chart to free up memory, especially in single-page applications.