frappe / charts

Simple, responsive, modern SVG Charts with zero dependencies
https://frappe.io/charts
MIT License
14.9k stars 716 forks source link

fix: fix rounding error in y-axis when max less than 1 #352

Closed schnerd closed 2 years ago

schnerd commented 2 years ago
Explanation About What Code Achieves:

Fixes this rounding issue: image

So that ticks are calculated without rounding errors.

You can run getChartIntervals(0.8) to replicate this behavior:

getChartIntervals(0.8) === [ 0, 0.2, 0.4, 0.6000000000000001, 0.8 ]

I'm on version 1.6.1. Couldn't test 1.6.2 because it caused a separate bug for me and also the css file isn't present in dist/: https://unpkg.com/browse/frappe-charts@1.6.2/dist/

Screenshots/GIFs:

See above

Steps To Test:

Create a chart where the maximum value is 0.8.

I tried to write some test cases for this but the project doesn't have a test command (even thought it has some test files)

schnerd commented 2 years ago

@scmmishra Can you do a build+release with this change?