ECharts
Options & Series
Dataset-driven multi-series chart with grid and legend config.
By EZ4Code Team
echartsoptionsdataset
Code
const chart = echarts.init(document.getElementById('chart'));
chart.setOption({
color: ['#5470c6', '#91cc75', '#ee6666'],
title: { text: 'Multi-Series Demo', left: 'center' },
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
legend: { top: '8%' },
grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true },
dataset: {
source: [
['product', '2015', '2016', '2017'],
['Matcha Latte', 43.3, 85.8, 93.7],
['Milk Tea', 83.1, 73.4, 55.1],
['Cheese Cocoa', 86.4, 65.2, 82.5]
]
},
xAxis: { type: 'category' },
yAxis: {},
series: [
{ type: 'bar', seriesLayoutBy: 'row' },
{ type: 'bar', seriesLayoutBy: 'row' },
{ type: 'bar', seriesLayoutBy: 'row' }
]
});Explanation
dataset.source lets you share tabular data across multiple series instead of repeating arrays; seriesLayoutBy:'row' treats each row (after the header) as a series. The grid option controls chart padding with containLabel:true reserving space for axis labels. The color array sets the per-series palette.
More ECharts Snippets
Bar Chart
Category bar chart with axis tooltip and styled bars.
Line Chart
Smooth multi-series line chart with area fill.
Pie Chart
Donut-style pie with emphasis effect and percentage labels.
Scatter Plot
Scatter plot with point size encoded by a third dimension.
Radar Chart
Radar with multiple indicators and overlaid value series.
Tooltip
Custom HTML tooltip with crosshair axis pointer.