barChart

fun ContainerScope.barChart(series: List<ChartSeries>, width: Dp, height: Dp, showValues: Boolean = true, showAxis: Boolean = true, gridLines: Int = 0, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a vertical bar chart.

Each entry in series becomes one filled bar whose height is proportional to its value relative to the largest value in the set. A baseline axis line is stroked along the bottom of the plot. Bar captions are laid out in a row of equal-width weighted slots so every label sits centred under its bar, and — when showValues is on — the numeric value is drawn above each bar.

The whole drawing is emitted through freeDraw / text, so the output stays crisp vector at any zoom.

An empty series, or one whose values are all <= 0, draws nothing.

When showAxis is on, a baseline is stroked along the bottom. When gridLines is greater than 0, that many faint horizontal value-grid lines are drawn across the plot and the min (0) and max value are labelled at the left edge so the bar heights can be read against a scale.

Parameters

series

the bars, left to right.

width

total width of the plot area.

height

total height of the plot area (bars + value captions live inside this; the label row is added beneath it).

showValues

when true (default), draws each bar's value above it.

showAxis

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

gridLines

number of faint horizontal value-grid lines (and the min/max axis labels). 0 (default) draws no grid.

axisColor

colour of the baseline axis line.

gridColor

colour of the faint value-grid lines.