stack key. The variables are the series, so variant assigns color per series index. Use monochrome for four or fewer series, and categorical for five or more.
- Design rules: Bar charts — stacked
- Shared API / tooltips / taps / palettes: Chart component
- Plain bar / direct labels: Bar
Minimal option
The option matches a grouped bar chart, withstack set on every series in the stack. Set stack in the option, since stacking carries meaning. variant supplies the rest of the treatment.
Variant styling
variant applies the following treatment:
Segment gaps apply only on the
variant path, where the theme fills the stack. Composing with chartPalette and chartStepItemStyle, as a semantic palette does, leaves the segments touching. Separate them another way: borders on outlined steps usually suffice, and otherwise leave space in the data or layout. See Chart component and Palettes.
Tooltips
PassrenderTooltip to add tooltip content. See Chart component.
Data point taps
PassonDataPointClick to handle activation of a segment. Pointer users tap the plot; VoiceOver and TalkBack users activate the matching value in the data list. The callback receives the same ChartTooltipInfo a tooltip does: name is the category the segment belongs to, and points[0] is the segment itself, carrying seriesName, seriesIndex, dataIndex, value, and color. Taps that do not land on a segment are ignored, and a pinch never reports a mark. onDataPointClick is not supported when the option produces no list.
Hold the reported segment in state to open a Dialog, reveal a detail panel, or navigate. See Chart component.