简体   繁体   English

图例点击后高图无法正确呈现

[英]Highcharts not rendering properly on legend clicks

Problem: When series of the charts are set hidden and visible by clicking the legends the YAxis on right side do not render properly: 问题:通过单击图例将一系列图表设置为隐藏和可见时,右侧的YAxis无法正确呈现:

enter code here

http://jsfiddle.net/yzqdekhr/5/ http://jsfiddle.net/yzqdekhr/5/

Steps To Reproduce : 重现步骤

1) Click Diversion % Monthly Legend and Hide right side y axis 1)点击转化%每月图例并隐藏右侧y轴
2) Click on both Diverted Tons and Trash Tons Legend (Complete chart will be blank) 2)点击“已转换吨数”和“垃圾吨位图例”(完整图表将为空白)
3) Click Diversion % Monthly Legend to show it again 3)点击“转化百分比每月图例”以再次显示
4) Click both Diverted Tons and Trash Tons Legend to show chart data 4)单击“分散吨数”和“垃圾吨位图例”以显示图表数据

See now both axis have their own plotlines which should not be, see below image 现在看到两个轴都有它们自己的绘图线,不应绘制,请参见下图

在此处输入图片说明

Expected Result Plot lines must be common as in the first load 预期结果图线必须与第一次加载时一样

This is a known issue reported as a bug here - https://github.com/highslide-software/highcharts.com/issues/4374 这是一个已知的问题,这里报告为错误-https: //github.com/highslide-software/highcharts.com/issues/4374

Suggested workaround is to add a wrapper that will realign ticks. 建议的解决方法是添加一个包装器,该包装器将重新排列刻度线。

H.wrap(H.Axis.prototype, 'setScale', function(p) {
        if(this.options.alignTicks !== false || this.chart.options.alignTicks !== false) {
             this.forceRedraw = true;   
        }
        p.call(this);
    });
})(Highcharts)

JSFiddle example: http://jsfiddle.net/q6sr1c0f/ JSFiddle示例: http : //jsfiddle.net/q6sr1c0f/

The problem is with how the secondary axis acts - when removing all and drawing the Diversion % there is no data or primary axis to be dynamically linked to. 问题在于辅助轴的行为-删除所有轴并绘制Diversion % ,没有数据或主轴可以动态链接到。

The only way I can think of doing what you want without getting the double axis line is to set the second Yaxis linkedTo option to the first one. 我可以想到的而没有获得双轴线的唯一方法是将第二个linkedTo选项设置为第一个。

This will make sure that if there is no first Yaxis the plot will not render new lines. 这将确保如果没有第一个Yaxis,该图将不会渲染新线。 This present another problem because now the Diversion % line is not painted at all (if the others are not visible) so you will have to set a min and max value for the first Yaxis. 这带来了另一个问题,因为现在根本没有绘制Diversion %线(如果其他线不可见),因此您必须为第一个Yaxis设置minmax

JSnippet Demo JSnippet演示

//Added to the second Yaxis:
linkedTo: 0;

//Added to the first Yaxis:
min: 0;
max: 100;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM