6

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?

mindparse
  • 6,115
  • 27
  • 90
  • 191
  • Hi @mindparse, Could you provide me with some minimal live example? Here: http://jsfiddle.net/BlackLabel/j0rwuek7/ everything seems to work correctly. – ppotaczek Oct 03 '19 at 07:54
  • Hi @ppotaczek - see my update above – mindparse Oct 03 '19 at 09:51
  • Thanks fot the update. In your case the problem is caused by too small tick interval - please check this example: https://jsfiddle.net/BlackLabel/26kv5fg8/ Are you sure that you need to use `logarithmic` axis type? – ppotaczek Oct 04 '19 at 10:41
  • I can't see anything different about your example – mindparse Oct 04 '19 at 10:50
  • Please check the data. Additionally you can analize how `tickPositions` are calculated in `logarithmic` axis here: https://github.com/highcharts/highcharts/blob/master/ts/parts/LogarithmicAxis.ts#L127 – ppotaczek Oct 04 '19 at 12:03

1 Answers1

3

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

John M
  • 2,510
  • 6
  • 23
  • 31