2014-10-03 110 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 
          }); 
         } 
        } 
       } 
      } 
     }, 
} 

這將只設置最小值/最大值,如果沒有你的一系列可見的一個,但刪除它,如果你有一個可見的