ECharts (Apache ECharts): A Highly Customizable JavaScript Visualization Library for Dashboards

Introduction

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.

Why Use ECharts?

ECharts stands out from other charting libraries due to its:

  1. Extensive Charting Options: Supports bar charts, line charts, scatter plots, pie charts, heatmaps, treemaps, and geographic maps.
  2. Interactive Features: Features like tooltips, zooming, and real-time data updates make charts engaging.
  3. Customization: Adjust colours, themes, animations, and layouts to fit your brand or application style.
  4. Performance: Handles large datasets smoothly using WebGL for enhanced rendering.
  5. Cross-Platform Compatibility: Works seamlessly across browsers and devices with responsive design capabilities.
  6. Integration-Friendly:Works seamlessly across different browsers and devices. Compatible with popular frameworks like React, Vue.js, and Angular.
  7. Open Source & Community Support: Free to use under the Apache 2.0 license with a growing developer community.

Getting Started with ECharts

Installation

ECharts can be installed using two methods:

  1. Using npm (Node Package Manager):
    npm install echarts
  2. Using a CDN (Content Delivery Network): Add the following script tag in your HTML file.
    <script src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>

Basic Setup

To create your first chart using ECharts:

  1. Create an HTML container where the chart will render.
  2. Initialize the chart instance using 'echarts.init'.
  3. Define the chart configuration ('option') and apply it using 'setOption'.

Example of a Simple Bar Chart

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' }]
};
Example of Echarts Bar Chart

Example of a simple Line Chart

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' }]
};
Example of Echarts Line Chart

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);
Use Cases of ECharts:
Conclusion

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..