2014-10-03 70 views
0

有很多隐藏的例子Y-Axis without hiding the series - 但我需要的是相反的。Hide系列没有隐藏y轴

我想做一个系列隐形,同时仍然显示y轴,我不知道如何!

为什么?

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

但是,当我禁用这两个温度场,轴将被丢失,并且图中的尺寸是不正确的: enter image description here

我也并不喜欢这个主意,禁止所有与失去整个图的风格: enter image description here

有由具有空图,BU没问题有空白的盒子不是我想要的风格。

我试图在legendItemClick事件中操作轴,但选择正确的轴并将其值设置为可见。我怎么解决这个问题?

+0

FYI:第二个“图”是一个简单的HTML表格 - 无关highcharts – Neysor 2014-10-03 08:40:57

回答

1

我认为你有两个选择:

  • 玩弄margins - 让他们固定
  • 设置minmax为轴线,所以标签将保持在图表上:example

如果您在开始时不知道最小/最大值,则可以在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 
          }); 
         } 
        } 
       } 
      } 
     }, 
} 

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