lineChart

fun ContainerScope.lineChart(points: List<Float>, width: Dp, height: Dp, color: PdfColor = PdfColor.Blue, strokeWidth: Float = 2.0f, fillUnderLine: Boolean = false, gridLines: Int = 0, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a line chart.

The points are plotted at evenly spaced x positions and scaled vertically so the smallest value sits on the baseline and the largest at the top. They are joined into a single stroked polyline. When fillUnderLine is on, the same polyline is closed down to the baseline and filled with a translucent tint of color (alpha 0.15) to shade the area under the curve.

Fewer than two points draws nothing — a polyline needs at least a start and an end. When every value is identical the line is drawn flat across the vertical centre.

When gridLines is greater than 0, that many faint horizontal grid lines are drawn behind the curve and the min / max values are labelled at the top and bottom so the curve can be read against a scale.

Parameters

points

y values in plot order.

width

plot width.

height

plot height.

color

stroke (and fill tint) colour.

strokeWidth

polyline thickness in points.

fillUnderLine

when true, shades the area under the line.

gridLines

number of faint horizontal 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 grid lines.


fun ContainerScope.lineChart(series: List<LineSeries>, width: Dp, height: Dp, strokeWidth: Float = 2.0f, gridLines: Int = 0, showLegend: Boolean = true, axisColor: PdfColor = PdfColor.Gray, gridColor: PdfColor = PdfColor.LightGray)

Appends a multi-series line chart.

Every series in series is plotted in the same plot area, scaled against the combined min / max across all series so the lines share one vertical axis, each stroked in its own LineSeries.color. As with the single-series overload, gridLines draws a faint grid plus min/max axis labels, and showLegend appends a swatch + label legend so the lines can be told apart.

Series with fewer than two points are skipped. If no series has at least two points, nothing is drawn.

Parameters

series

the lines to overlay.

width

plot width.

height

plot height.

strokeWidth

polyline thickness in points, shared by every series.

gridLines

number of faint horizontal grid lines; 0 draws none.

showLegend

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

axisColor

colour of the baseline axis line.

gridColor

colour of the faint grid lines.