Y-axis scale precision problem

I have a problem where the scale for the y-axis uses a single decimal for precision except for one particular value. See the following image:

Screenshot 2022-07-05 102155.png

I have set the minimum to 0 and the maximum to 0.5 and interval to 0.1. I set labelFormat to '{value} ntu'. Why does the scale value label for 0.3 show as 0.300?


2 Replies

SB Swetha Babu Syncfusion Team July 6, 2022 06:12 AM UTC

Hi Travis,


Greetings from Syncfusion.


We have considered the reported scenario as a bug and logged a defect report for the same. The fix for the reported scenario will be included in our weekly patch release which is expected to be rolled out on 19th July, 2022. Please find the below feedback link to keep track of the reported scenario.


Feedback link: https://www.syncfusion.com/feedback/36141/axis-label-interval-is-not-proper


If you have any more specification/precise replication procedure or a scenario to be tested, you can add it as a comment in the portal.


Regards,

Swetha



SB Swetha Babu Syncfusion Team July 20, 2022 11:33 AM UTC

Hi Travis,


Thank you for your patience.


When we tried to fix the reported scenario, we came to know that when we add 0.2 and 0.1, it gives 0.3000004. Refer the below link


StackOverflow link:  https://stackoverflow.com/questions/588004/is-floating-point-math-broken



So, to overcome the reported issue, we can set the labelFormat property in primaryYAxis as n1 and change the first label in the y-axis as 0 using the text argument in axisLabelRender event in Charts. We have created a simple Javascript application to demonstrate the same. Please find the below stackblitz link for your sample reference and stack overflow link for your reference.



Sample link: https://stackblitz.com/edit/7tydmz-n6ctgt?file=index.js


Code Snippet:


primaryYAxis: {

    minimum: 0,

    maximum: 0.5,

    interval: 0.1,

    lineStyle: { width: 0 },

    labelFormat: 'n1',

  },

 

axisLabelRender: function (args) {

    if (args.text === '0.0' && args.axis.name == 'primaryYAxis') {

      args.text = '0';

    }

  },


Screenshot:



Kindly, revert us if you have any concerns.


Regards,

Swetha


Loader.
Up arrow icon