fix: YAxis offset not correct

This commit is contained in:
Florian Bouillon 2023-01-10 14:46:27 +01:00
parent 732aa65c19
commit 4c9b4bd2a6

View File

@ -100,9 +100,9 @@ class YAxis(
var maxWidth = 0f var maxWidth = 0f
val increment = (bottom - top) / labelCount val increment = (bottom - top) / labelCount
val valueIncrement = (max - min) / labelCount val valueIncrement = max / labelCount
for (index in 0 until labelCount) { for (index in 0 until labelCount) {
val text = onValueFormat((valueIncrement * (index + 1))) val text = onValueFormat(min + (valueIncrement * (index + 1)))
textLabel.getTextBounds(text, 0, text.length, rect) textLabel.getTextBounds(text, 0, text.length, rect)
maxWidth = maxWidth.coerceAtLeast(rect.width().toFloat()) maxWidth = maxWidth.coerceAtLeast(rect.width().toFloat())