我有一个具有3个y轴的图表。我有一个要求,用户可以选择在图表上显示或隐藏y轴,但是我需要一些帮助使其工作。我在图表上添加了一个按钮,并尝试了两种不同的方法来隐藏该轴:(i)在该轴上使用show和hide方法(这会产生控制台错误)(ii)将visible属性设置为trye并错误的。这是按钮的代码:exporting: { buttons: { customButton: { text: 'Hide/Show Y-Axis', onclick: function () { /* /// I get a console error trying to use the hide or show method this.yAxis[0].visible ? this.yAxis[0].hide() : this.yAxis[0].show(); */ if (this.yAxis[0].visible || this.yAxis[1].visible || this.yAxis[2].visible) { this.yAxis[0].visible = false; this.yAxis[1].visible = false; this.yAxis[2].visible = false; } else { this.yAxis[0].visible = true; this.yAxis[1].visible = true; this.yAxis[2].visible = true; } this.redraw(); } } } }到达时似乎可以执行某些操作,this.redraw()但不会隐藏轴。我在这里做错了什么?完整代码:JSFiddle
添加回答
举报
0/150
提交
取消