The BarStackChart
component renders grouped values as stacked bars, enabling visual comparison of cumulative totals and their individual components across categories. Each bar is split into colored segments that represent different subcategories within a shared label.
This example visualizes toy counts grouped by type (Cube
, Sphere
, Pyramid
) and stacked by color (Green
, Purple
, Pink
, Yellow
). The stacked bar chart shows how each color contributes to the total count per shape.
labelOnYAxis?: boolean
true
, category labels will be displayed on the Y-axis, rendering the bars horizontally.false
(default), labels appear on the X-axis, and bars are drawn vertically.marks: Array<object>
(required)Each mark represents a segment in the stacked bar and includes the following fields:
label: string | Date
The shared label used to group segments into one bar (e.g., "Cube", "Sphere").
category: string
The subcategory used to split the bar into segments (e.g., color groups like "Green", "Pink").
value: number
The numeric value for this segment.
unit?: CalendarComponent
(Optional) Used when rendering time-based charts.
Additional optional ChartMarkProps
For customizing appearance, including:
foregroundStyle
cornerRadius
symbol
annotation
The example also includes a toggle to switch between vertical and horizontal layouts using labelOnYAxis
.
BarStackChart
is ideal for: