Synchronize ValueAxis grids

江枫思渺然 提交于 2019-12-11 11:44:24

问题


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:


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;
}


来源:https://stackoverflow.com/questions/32095436/synchronize-valueaxis-grids

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!