Home›Bar›Stacked Bar Chart
POPULARBar

Stacked Bar Chart

Stacked segments per bar to show part-to-whole relationships over quarterly time periods with custom device attribution.

Loading chart…
#bar#stacked#composition#part-to-whole#multi-series#devices
Customization Guides & Code Snippets

◆Rounded Corners on Top Stacked Bars Only

To prevent awkward pill shapes inside the stack, only add radius={[4, 4, 0, 0]} to the topmost Bar component in your JSX.

<Bar dataKey="mobile" stackId="a" fill="#00e5a0" />
<Bar dataKey="desktop" stackId="a" fill="#4a9eff" radius={[4, 4, 0, 0]} />
When to use a Stacked Bar Chart

A Stacked Bar Chart is ideal for developers and designers who need to display data clearly and effectively. Use this chart type when:

  • ✓Comparing values across multiple categories (e.g. monthly revenue per region)
  • ✓Showing ranked data where order matters (e.g. top 10 products by sales)
  • ✓Displaying survey results or poll responses
  • ✓Visualizing before/after comparisons
Tips for Recharts Stacked Bar Chart
TIP 1Always start the Y-axis at zero to avoid misleading comparisons
TIP 2Use rounded corners (radius prop) for a modern, polished look
TIP 3Add a Tooltip component so users can see exact values on hover
TIP 4Use Cell components to color individual bars differently
TIP 5For long category names, switch to a horizontal bar chart layout
Key Recharts Props
PROPTYPEDESCRIPTION
dataarrayArray of objects with your data values
dataKeystringThe key in your data objects to use for bar height
fillstringBar color — accepts hex, rgb, or CSS variable
radius[number,number,number,number]Corner radius [topLeft, topRight, bottomRight, bottomLeft]
stackIdstringGroup bars with the same stackId into a stacked bar
Frequently Asked Questions

What is a stacked bar chart and how does it work?

A stacked bar chart segments each rectangular bar into multiple color-coded sub-bars stacked atop each other. It displays both the overall aggregate total of each category as well as the relative part-to-whole contribution of each sub-series.

How do you make a stacked bar chart in Recharts?

In Recharts, render multiple <Bar> components inside a <BarChart> and give them the same stackId attribute (e.g. stackId='traffic'). Recharts will automatically calculate vertical offsets and stack them sequentially.

How do you round only the top corners of a stacked bar in Recharts?

Only apply the radius prop (such as radius={[6, 6, 0, 0]}) to the final/topmost <Bar> component in your JSX. Leaving the inner and bottom bars without radius prevents awkward rounded seams inside the stack.

How do you create a stacked bar chart in Excel (stacked bar chart excel)?

In Excel, select your data table, click the Insert tab, select Column or Bar Chart, and choose 'Stacked Column' or 'Stacked Bar'. In React applications, you can render this dynamically with Recharts using interactive tooltips and modern theme styles.

Related Charts