在向下钻取时动态设置轴极值 [英] Set axis extremes dynamically on drilldown

查看:146
本文介绍了在向下钻取时动态设置轴极值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个两轴坐标图,它们是成比例的,即第二轴最大值正好是第一轴最大值的13.5%。

使用Highcharts的回调函数来做到这一点,因为@KacperMadej在中建议我这篇文章

pre $ 函数(图表){
chart.yAxis [1] .update({
max:chart.yAxis [0] .getExtremes()。max * 0.135
});
}

效果很好,但是当我在图表中钻取第二根轴在深入分析之前将其固定为其值。钻取加载后我无法找到影响此轴的方法。



关于如何在Highcharts上获取展开后的任何想法事件?



这是我到目前为止的尝试:

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



$ / code $ / pre
$ b $

完全不起作用因为第二轴在钻取之前和之后保持完全相同。在这里查看我的 JSFiddle (点击'2015'进行深入分析)。

解决方案

您可以调用这个函数:

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

在钻取事件中的setTimeout中。零毫秒的延迟似乎有足够的时间。例如: http://jsfiddle.net/zd5do0s7



< (相关问题:按第一轴比例设置第二轴< a>)


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).

解决方案

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)

这篇关于在向下钻取时动态设置轴极值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆