I'm drawing chart in Jetpack Compose, with x labels written using drawIntoCanvas method. Basically very simple block of code:
data.forEachIndexed { index, point ->
drawIntoCanvas {
it.nativeCanvas.drawText(
"${point.x}",
chartCanvasStartX + index * intervalX,
size.height + 4.dp.toPx(),
textPaint
)
}
}
However I would like to achieve those labels to be sloped at desired angle, to fit longer text. I've tried applying rotation to the canvas, but that produces output, where whole canvas is rotated, not the individual iterations of this forEach loop. Even using methods like canvas.save() and canvas.restore() between angle transformation didn't produce desired output. Maybe in Compose declarative world there is some simpler solution for drawing such a texts?
Here is mockup for visualization of what I would like to achieve:

Note: Whole chart is written in single Compose Canvas method, because I want to have reference to every x value of chart to place label precisely at this point, so I don't want to place any Column with regular Compose Text with rotate modifier applied.

