I'm trying to build a similar chart in Jetpack compose to the one from the screenshot. Let's assume that instead of those labels I'm trying to draw squares ( which should be icons actually but it does not change the problem). I managed to draw all the arches but when I draw the squares they are not possitioned as I would like them to be The issue is that the square is drawn from the top left corner. And it works fine if they are drawn from 0 to 90 degrees (clockwise). But how I can reposition the squares as if from 90 to 180 degrees they are drawn from the top right, from 180 to 270 they are drawn from the bottom right and from 270 to 360 they are drawn from bottom left.
Currently I have the following code for drawing the squares
val angle = spendingChartItem.startAngle + spendingChartItem.archAngle / 2f
val offset = Offset(
drawScope.center.x + (circleInnerRadius + chartBarWidth.toPx() / 2) * cos(
angle.degreeToRadians
),
drawScope.center.y + (circleInnerRadius + chartBarWidth.toPx() / 2) * sin(
angle.degreeToRadians
)
)
drawRect(
color = Color.Red,
size = androidx.compose.ui.geometry.Size(24f,24f),
topLeft = offset
)