A grouped bar chart that displays multiple bars side-by-side for each category, enabling direct comparison of values across different groups within the same categorical dimension. This visualization excels at showing how different groups perform relative to each other across multiple categories, making patterns and differences immediately apparent. Grouped bar charts are essential for comparative analysis where you need to track multiple series against the same set of categories.

// anyplot.ai
// bar-grouped: Grouped Bar Chart
// Library: echarts 6.1.0 | JavaScript 22.23.1
// Quality: 91/100 | Created: 2026-08-05
const t = window.ANYPLOT_TOKENS;
// --- Data (in-memory, deterministic) ----------------------------------------
// Quarterly revenue ($K) by product line across regions
// West flips the usual Electronics-leads rank order: an in-store apparel
// campaign put Apparel ahead of Electronics that quarter.
const regions = ["North", "South", "East", "West", "Central"];
const productLines = ["Electronics", "Apparel", "Home Goods"];
const revenue = {
Electronics: [420, 380, 510, 340, 390],
Apparel: [310, 340, 280, 460, 260],
"Home Goods": [180, 210, 195, 220, 175],
};
const overallAverage =
Object.values(revenue)
.flat()
.reduce((sum, v) => sum + v, 0) / (regions.length * productLines.length);
// --- Init ---------------------------------------------------------------------
const chart = echarts.init(document.getElementById("container"));
// --- Option ---------------------------------------------------------------------
chart.setOption({
animation: false,
color: t.palette,
backgroundColor: "transparent",
title: {
text: "bar-grouped · javascript · echarts · anyplot.ai",
left: "center",
top: 30,
textStyle: { color: t.ink, fontSize: 22 },
},
legend: {
data: productLines,
top: 90,
textStyle: { color: t.ink, fontSize: 16 },
itemWidth: 18,
itemHeight: 12,
},
tooltip: {
trigger: "axis",
axisPointer: { type: "shadow" },
valueFormatter: (v) => `$${v}K`,
},
grid: { left: 110, right: 60, top: 160, bottom: 80 },
xAxis: {
type: "category",
data: regions,
name: "Region",
nameLocation: "middle",
nameGap: 45,
nameTextStyle: { color: t.ink, fontSize: 16 },
axisLabel: { color: t.inkSoft, fontSize: 14 },
axisLine: { lineStyle: { color: t.inkSoft } },
axisTick: { show: false },
splitLine: { show: false },
},
yAxis: {
type: "value",
name: "Revenue ($K)",
nameLocation: "middle",
nameGap: 70,
nameTextStyle: { color: t.ink, fontSize: 16 },
axisLabel: { color: t.inkSoft, fontSize: 14 },
axisLine: { show: false },
axisTick: { show: false },
splitLine: { lineStyle: { color: t.grid } },
},
series: productLines.map((name, i) => ({
name,
type: "bar",
data: revenue[name],
itemStyle: {
color: t.palette[i],
borderRadius: [4, 4, 0, 0],
shadowBlur: 6,
shadowColor: "rgba(0, 0, 0, 0.12)",
},
emphasis: { focus: "series" },
barGap: "12%",
barCategoryGap: "32%",
...(i === 0
? {
markPoint: {
symbol: "pin",
symbolSize: 46,
itemStyle: { color: t.palette[0] },
label: { color: "#fff", fontSize: 12, fontWeight: 600, formatter: "${c}K" },
data: [{ type: "max", name: "Peak" }],
},
markLine: {
symbol: "none",
lineStyle: { color: t.inkSoft, type: "dashed", width: 1.5 },
label: {
color: t.inkSoft,
fontSize: 12,
formatter: `Avg ${overallAverage.toFixed(0)}K`,
position: "insideEndTop",
},
data: [{ yAxis: overallAverage, name: "Overall average" }],
},
}
: {}),
})),
});
Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/bar-grouped/echarts/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.
{
"spec_id": "bar-grouped",
"language": "javascript",
"library": "echarts",
"page": "https://anyplot.ai/bar-grouped/javascript/echarts",
"hub": "https://anyplot.ai/bar-grouped",
"code_json": "https://api.anyplot.ai/specs/bar-grouped/echarts/code",
"spec_json": "https://api.anyplot.ai/specs/bar-grouped",
"render_light_png": "https://storage.googleapis.com/anyplot-images/plots/bar-grouped/javascript/echarts/plot-light.png",
"render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/bar-grouped/javascript/echarts/plot-dark.png",
"interactive_light_html": "https://storage.googleapis.com/anyplot-images/plots/bar-grouped/javascript/echarts/plot-light.html",
"interactive_dark_html": "https://storage.googleapis.com/anyplot-images/plots/bar-grouped/javascript/echarts/plot-dark.html",
"quality_score": 91.0,
"license": "MIT",
"guide": "https://anyplot.ai/llms.txt"
}Part of Grouped Bar Chart on anyplot.ai.