Apache ECharts is a JavaScript visualization library that makes creating interactive and customizable dashboards easy. Whether you're building business intelligence reports, web applications, or scientific research tools, ECharts offers the flexibility and performance to bring your data to life.
ECharts stands out from other charting libraries due to its:
ECharts can be installed using two methods:
npm install echarts
<script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
To create your first chart using ECharts:
var chart = echarts.init(document.getElementById('main'));
var barOption = {
title: { text: 'Bar Chart Example' },
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] },
yAxis: { type: 'value' },
series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }]
};
var chart = echarts.init(document.getElementById('main'));
var lineOption = {
title: { text: 'Line Chart Example' },
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] },
yAxis: { type: 'value' },
series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }]
};
To use multiple charts in the same page, we can use a function which will help make charts easily
function createChart(id, option) {
var chart = echarts.init(document.getElementById(id));
chart.setOption(option);
}
Now, we can create multiple charts using the same function with different configurations.
var barOption = {
title: { text: 'Bar Chart Example' },
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] },
yAxis: { type: 'value' },
series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }]
};
createChart('bar-chart', barOption);
var lineOption = {
title: { text: 'Line Chart Example' },
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] },
yAxis: { type: 'value' },
series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar' }]
};
createChart('line-chart', lineOption);
Apache ECharts is great for creating dynamic, interactive, and customizable data visualizations. Whether you're a beginner or a seasoned developer, its ease of use, high performance, and broad compatibility make it a top-tier tool for web-based visualizations..