Highcharts : trouble with axis Label

144 Views Asked by At

I can't explain this behavior :
Sometimes, my charts are displaying the first or the last label of the axis with a lot of decimals.

enter image description here enter image description here

In my graph options, here is how the yAxis look like :

yAxis : [{
     alternateGridColor: "white",
     gridLineColor : "#E3E3E3",
     lineWidth: 2,
     tickLength : 5, 
     lineColor : '#A5A5A5',
     tickWidth : 2,
     tickLength : 5,
     tickColor : '#A5A5A5',
     labels : {
         style : {
             fontWeight : 'bold',
             fontSize: '10px'
         }, 
         x : -labelMargin
     },
     tickPixelInterval: 20  
},
//more axis
]

How to fix that ? Any help appreciated.

1

There are 1 best solutions below

3
muradin On BEST ANSWER

You did not mentioned what should be the value of your labels so it uses the naive value for them that could be float number generated by a division perhaps.

I suggest you to handle your labels manually something like this:

    labels: {
        formatter: function () {
            return Math.floor(this.value)
        }
    }

As you can see i use floor() function to remove decimals.