stackedBarChart

fun ContainerScope.stackedBarChart(groups: List<StackedBarGroup>, width: Dp, height: Dp, showAxis: Boolean = true, gridLines: Int = 0, showLegend: Boolean = true, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a stacked bar chart.

Each entry in groups becomes one bar whose segments are stacked bottom-to-top in list order; every bar is scaled against the largest group total so the tallest stack fills the plot. A baseline axis line is stroked along the bottom (when showAxis is on) and an optional faint value grid is drawn behind the bars (when gridLines is greater than 0).

When showLegend is on, a swatch + label legend is appended below, one row per distinct segment label encountered (first occurrence wins its colour), so the segment colours can be decoded.

An empty groups list, or one whose every segment is <= 0, draws nothing.

Parameters

groups

the bars, left to right; each stacks its StackedBarGroup.segments.

width

total width of the plot area.

height

total height of the plot area; the label row is added beneath.

showAxis

when true (default), strokes the baseline axis line.

gridLines

number of faint horizontal value-grid lines; 0 draws none.

showLegend

when true (default), appends a per-segment swatch legend.

axisColor

colour of the baseline axis line.

gridColor

colour of the faint value-grid lines.