Scale number of y ticks in linegraph data fields (#150)

This commit is contained in:
timklge 2025-06-11 20:17:02 +02:00 committed by GitHub
parent f35ffe52cc
commit 1727e606ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -381,7 +381,7 @@ class LineGraphBuilder(val context: Context) {
// Draw Left Y-axis ticks and labels // Draw Left Y-axis ticks and labels
if (hasLeftYAxisData) { if (hasLeftYAxisData) {
textPaint.textAlign = Align.RIGHT textPaint.textAlign = Align.RIGHT
val numYTicks = if (gridWidth > 15) 2 else 1 val numYTicks = if (gridHeight > 15) (gridHeight / 10) else 1
if (abs(dataMaxYLeft - dataMinYLeft) > 0.0001f) { if (abs(dataMaxYLeft - dataMinYLeft) > 0.0001f) {
for (i in 0..numYTicks) { for (i in 0..numYTicks) {
val value = dataMinYLeft + ((dataMaxYLeft - dataMinYLeft) / numYTicks) * i val value = dataMinYLeft + ((dataMaxYLeft - dataMinYLeft) / numYTicks) * i