Kotlin / Kotlin/kandy

How to force y Axis to use floating point precision?

Open
#462 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
744
Forks
27
Avg merge
4d 1h
Merged PRs (30d)
1

Description

I used this code from kandy examples:
```
val years = listOf(1, 2, 3, 4, 5)
val cost = listOf(62.7, 39.3, 72.1, 73.7, 68.5)

plot {
line {
x(years)
y(cost)
type = LineType.SOLID
}
}
```
And when you hover over the resultant plot values, we see y axis labels that correctly show values with decimal point like 62.7, 72.1 etc.

![Image](https://github.com/user-attachments/assets/404d447e-ffea-4fd0-bbd2-c7a2dc1544a9)

But if I use this dataset instead:
```
val years2 = listOf(1, 2, 3, 4, 5)
val cost2 = listOf(95.0, 2.2, 3.3, 4.4, 5.5)

plot {
line {
x(years2)
y(cost2)
type = LineType.SOLID
}
}
```

I get a plot where all y values are rounded off to the nearest integer. I don't understand what is causing this and how to force y axis to be of Double type.

![Image](https://github.com/user-attachments/assets/87b70df9-b1e4-4064-8af9-4b97456c4064)

How do I force y axis to use decimal values?

Contributor guide

Open the contributing guide

Research direction

Reproduce the two Kotlin plotting snippets from the issue and compare the y-axis label behavior when the values span a wide range. Trace the y-axis scale and label-formatting entry points to determine why decimal values are rounded, then verify that the affected plot displays decimal labels without changing the first example.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.