Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts - yAxis logarithmic scale and allowDecimals set to false not seeming to have any effect

I am wanting to prevent the display of decimal values on a y-axis of an area chart I have configured.

When my chart initially shows with all series showing, I see:

enter image description here

But after filtering out some of the series to show, I see the y axis start showing decimal values like so:

enter image description here

My yAxis config is as follows:

yAxis: {
            gridLineColor: 'transparent',
            allowDecimals: false,
            type: 'logarithmic',
            minorTickInterval: 1,
            lineWidth: 0,
            gridLineWidth: 0,
            minorGridLineWidth: 0
        },

I wondered if this had something to do with being a logarithmic scale, but when I comment out the type option to revert to using a default scale, it makes no difference, I observe the same behaviour.

Is there a way to prevent decimals showing and only have whole values showing?

Thanks

Update:

So I have replicated in a fiddle here -> https://jsfiddle.net/parky12/cn5mdzea/

Seems this is related to being on a logarithmic scale.

If you disable the low series, then decimals appear on the axis.

Is there a way to prevent these showing?

like image 822
mindparse Avatar asked Oct 02 '19 11:10

mindparse


1 Answers

I found this configuration worked for me:

  yAxis: {
    gridLineColor: 'transparent',
    allowDecimals: false,
    type: 'logarithmic',
    tickInterval: 0.1,
    startOnTick: false,
    lineWidth: 0,
    gridLineWidth: 0,
    minorGridLineWidth: 0
  },

bear in mind that the tickInterval property works differently for logarithmic axes, i.e. 1 would be a label at every power of 10, so for this data set at least you want an interval of 0.1

Fiddle

like image 146
John M Avatar answered Nov 14 '22 22:11

John M