1
votes

I have these two ValueAxes:

{
    ...
    minimum: 0,
    maximum: 100,
    strictMinMax: true,
    autoGridCount: false,
    gridCount: 10
},
{
    ...
    minimum: -15,
    maximum: 215,
    strictMinMax: true,
    autoGridCount: false,
    gridCount: 10
}

Now the grid lines of both axes are creating a total mess in the chart and its hard to not get confused while trying to read values. The reason for this is, that AmCharts rounds the labels up or down to ten-steps, not respecting the gridCount.

I need to know if there's a way to get AmCharts to stop trying to round the labels. I'm totally fine to have numbers like 62 as a label, as long as it reduces the amount of grid lines.

1
Sth. like setting the step manually. In my case it would be 10 for the first axis and 23 for the second one. - gerric
I'm afraid there's no way to do that in amCharts. The step is auto-calculated and is always in magnitudes of ten for value ranges that are bigger than 10. - martynasma
Ok, thanks. I was expecting this answer so made I already made a work-around by myself. - gerric
If that is a clever workaround, maybe you could post it as an answer for other people looking for the same solution? - martynasma
Hm, well i just added an option strictGridCount to valueAxis and if it's set to true im just overwriting the old min/max and step to my wishes (inside valueAxis.draw()). Thats all. - gerric

1 Answers

1
votes

My workaround is pretty easy.
I introduced a new option, so that the normal strictMinMax will still work: strictGridCount

I used the implementation of strictMinMax and added these lines just a few lines above the place where strictMinMax is used:

if(_this.strictGridCount) {
    if (!isNaN(_this.minimum)) {
        _this.min = _this.minimum;
    }

    if (!isNaN(_this.maximum)) {
        _this.max = _this.maximum;
    }

    _this.step = (_this.max - _this.min) / _this.gridCount;
}