Closed rhult closed 6 months ago
I realized just after submitting that I can implement an AxisOverrider to make sure I always have a good range, and as the consumer of the API I probably have a better idea of what that would be since it is highly domain specific. I understand if you want to just close this issue.
how
Hello! Both of these issues are caused by Float
imprecision. We’ll be switching from Float
to Double
to make such problems less likely—all data types have their limits—but it should be possible to transform the chart data such that the x values are in a safe range and undo the transformation during formatting. The chart will then behave as expected:
Let me know if you have any questions about this. Regarding AxisItemPlacer.Horizontal.default
, it always produces a constant x delta between labels, so for nonuniform spacing, a custom AxisItemPlacer.Horizontal
implementation is needed. I’ll be closing this issue because the problem in question results not from a computational error in Vico but from how the Float
data type works. The switch to Double
is planned for Vico 2, so please keep an eye on the release notes.
How to reproduce
The following snippet shows the bug. The x value might need tweaking, but the following works for me in previews and on my device. I'm not sure if it depends on the resolution.
Observed behavior
The x value is not visible, and no x line is shown. When adding in the second commented out value, both x values are shown in full.
I have also noticed that long x titles are ellipsized even when it is not necessary. In the snippet here, if setting the one x value to 10000000 (that is, one 0 less than the snippet), the title is displayed as "100000...", even though there is a lot of space left.
(I might need to implement my own item placer in the end, since I actually want to use a formatter that displays the value like "1 k", "1 M", "1 G" etc and I don't want to see more than one of each, which the builtin placer cannot do as far as I understand.)
Expected behavior
Charts with one value should ideally display the x value if it fits, and long x titles should not be ellipsized unless needed to leave space for other titles.
Vico version(s)
Latest unstable version
Android version(s)
13 and 14
Additional information
I'm using alpha 11.