gpt4 book ai didi

javascript - 隐藏系列而不隐藏 y 轴

转载 作者:太空宇宙 更新时间:2023-11-04 12:50:33 26 4
gpt4 key购买 nike

有很多隐藏 Y-Axis without hiding the series 的例子- 但我需要相反的东西。

我想在显示 y 轴的同时隐藏一个系列,但我不知道该怎么做!

为什么?

因为我有 2 个图表,它们的 x 轴完全对齐: enter image description here

但是当我禁用两个温度场时,轴将丢失,并且图表的大小不正确: enter image description here

我也不喜欢禁用所有并丢失整个图表样式的想法: enter image description here

有一个空图没有问题,但是有一个空白框不是我想要达到的风格。

我试图在 legendItemClick 中操纵轴事件,但选择正确的轴并将其值设置为可见并没有成功。我该如何解决这个问题?

最佳答案

我认为你有两个选择:

如果您不知道开始时的最小/最大值,您可以在 legendItemClick 中更改它们,如下所示:

 plotOptions: {
series: {
events: {
legendItemClick: function() {
var temperatur = this.chart.series[0];
var taupunkt = this.chart.series[1];
var other = this.name=="Lufttemperatur"?taupunkt:temperatur;
var element = this;
if(this.name == "Lufttemperatur" || this.name == "Taupunkt") {
if(this.visible && !other.visible) {
//both will be invisible soon
this.chart.yAxis[0].update({
min:element.yAxis.min,
max:element.yAxis.max
});
} else {
//one will be visible
this.chart.yAxis[0].update({
min:null,
max:null
});
}
}
}
}
},
}

如果你的系列中没有一个可见,这将只设置最小/最大,但如果你有一个可见,则将其删除

关于javascript - 隐藏系列而不隐藏 y 轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26175770/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com