ECharts
Bar Chart
Category bar chart with axis tooltip and styled bars.
By EZ4Code Team
echartsbar
Code
const chart = echarts.init(document.getElementById('chart'));
chart.setOption({
title: { text: 'Monthly Sales', left: 'center' },
tooltip: { trigger: 'axis' },
xAxis: {
type: 'category',
data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
},
yAxis: { type: 'value', name: 'k$' },
series: [{
name: 'Sales',
type: 'bar',
data: [120, 200, 150, 80, 70, 110],
itemStyle: { color: '#5470c6', borderRadius: [4, 4, 0, 0] },
barWidth: '60%',
label: { show: true, position: 'top' }
}]
});Explanation
Initialize echarts on a DOM element and pass an option object to setOption. The bar series maps category xAxis data to value yAxis via the data array. itemStyle.borderRadius rounds the top corners and label.show displays the value above each bar; trigger:'axis' shows all series values on hover.
More ECharts Snippets
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.
Options & Series
Dataset-driven multi-series chart with grid and legend config.
Tooltip
Custom HTML tooltip with crosshair axis pointer.