Set axis extremes dynamically on drilldown

拜拜、爱过 提交于 2019-12-12 06:19:09

问题


I am working on a chart with two axes, which are proportional, i.e., the second axis maximum is exactly 13.5% of the first axis maximum.

I managed to do this with the callback functionnality of Highcharts, as @KacperMadej suggested me in this post:

function (chart) {
        chart.yAxis[1].update({
            max: chart.yAxis[0].getExtremes().max * 0.135
        });
 }

It works great, but when I drilldown on my chart, the second axis stays fixed to its values before drilldown. I can't find a way to affect this axis after the drilldown has been loaded.

Any idea on how I can get an after drilldown event on Highcharts ?

Here is what I have attempted so far:

chart: {
        alignTicks: false,
        events: {
            drilldown: function () {
                this.yAxis[1].update({
                    max: this.yAxis[0].getExtremes().max * 0.135
                });
            }
        }
}

This does not work at all as the second axis stays exactly the same before and after drilldown. See my JSFiddle here (Click on '2015' to drilldown).


回答1:


You could call this function:

function(chart){
    chart.yAxis[1].update({max: chart.yAxis[0].getExtremes().max * 0.135});
}

in setTimeout in drilldown event. Zero milliseconds of delay seems to be an enough amount of time. Example: http://jsfiddle.net/zd5do0s7

(connected question: Set second axis in proportion of first axis)



来源:https://stackoverflow.com/questions/32068994/set-axis-extremes-dynamically-on-drilldown

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