2013-07-10 32 views
0

因此,當我有一個只包含0個數據(例如數據包丟失測量)的圖表時,除非您隱式定義最大值和最小值,否則不繪製Y軸。具有有效0值但不會生成y軸的Highstock圖形

但是我有圖需要自動繪製0數據而不指定最大值,因爲max可能並不總是知道的(例如數據吞吐量)。

http://jsfiddle.net/fYkQy/2/顯示我所得到的。見代碼附加

$(document).ready(function() { 
    Highcharts.setOptions({ 
     global: { 
      useUTC: false 
     } 
    }); 
    PacketLoss = new Highcharts.StockChart({ 
     chart: { 
      renderTo: 'container', 
      defaultSeriesType: 'line', 
      spacingRight: 30, 
      spacingBottom: 45, 
      width: 600, 
      height: 400 
     }, 
     rangeSelector: { 
      enabled: false 
     }, 
     title: { 
      text: 'PacketLoss' 
     }, 
     scrollbar: { 
      liveRedraw: true 
     }, 
     navigator: { 
      adaptToUpdatedData: true 
     }, 
     xAxis: { 
      type: 'datetime', 
      tickPixelInterval: 80, 
      maxZoom: 1440 * 1000 
     }, 
     yAxis: { 
      minPadding: 0.2, 
      maxPadding: 0.2, 
      min: 0, 
      offset: 35, 
      title: { 
       text: 'PacketLoss (%)', 
       margin: 12 
      } 
     }, 
     tooltip: { 
      valueDecimals: 2, 
      valueSuffix: "%" 
     }, 
     plotOptions: { 
      line: { 
       marker: { 
        enabled: false, 
        states: { 
         hover: { 
          enabled: true, 
          radius: 5 
         } 
        } 
       }, 
       shadow: false 
      } 
     }, 
     legend: { 
      enabled: true, 
      layout: 'horizontal', 
      align: 'center', 
      verticalAlign: 'bottom', 
      x: 30, 
      y: 35, 
      floating: true, 
      shadow: true 
     }, 
     series: [{ 
      name: 'PacketLoss', 
      color: '#660000', 
      zIndex: 100, 
      data: [[1373354992000,0],[1373361195000,0],[1373363923000,0],[1373380804000,0],[1373388550000,0],[1373392475000,0],[1373399655000,0],[1373409555000,0],[1373409858000,0],[1373410160000,0],[1373410765000,0],[1373411067000,0],[1373411369000,0],[1373411670000,0],[1373411971000,0],[1373412273000,0],[1373412574000,0],[1373412875000,0],[1373413177000,0],[1373413479000,0],[1373413780000,0],[1373414082000,0],[1373414384000,0],[1373414686000,0],[1373414988000,0],[1373415289000,0],[1373415591000,0],[1373415893000,0],[1373416196000,0],[1373416497000,0],[1373416799000,0],[1373417101000,0],[1373417402000,0],[1373417704000,0],[1373418006000,0],[1373418308000,0],[1373418610000,0],[1373418911000,0],[1373419212000,0],[1373419514000,0],[1373419819000,0],[1373420120000,0],[1373420421000,0],[1373420723000,0],[1373421025000,0],[1373421326000,0],[1373421628000,0],[1373421929000,0],[1373422231000,0],[1373422532000,0],[1373422834000,0],[1373423136000,0],[1373425197000,0],[1373432327000,0]] 
     }] 
    }); 
}); 

http://jsfiddle.net/aBsqz/顯示它的外觀與一組最大值和最小值(可與百分比值而不是未知的值。

$(document).ready(function() { 
    Highcharts.setOptions({ 
     global: { 
      useUTC: false 
     } 
    }); 
    PacketLoss = new Highcharts.StockChart({ 
     chart: { 
      renderTo: 'container', 
      defaultSeriesType: 'line', 
      spacingRight: 30, 
      spacingBottom: 45, 
      width: 600, 
      height: 400 
     }, 
     rangeSelector: { 
      enabled: false 
     }, 
     title: { 
      text: 'PacketLoss' 
     }, 
     scrollbar: { 
      liveRedraw: true 
     }, 
     navigator: { 
      adaptToUpdatedData: true 
     }, 
     xAxis: { 
      type: 'datetime', 
      tickPixelInterval: 80, 
      maxZoom: 1440 * 1000 
     }, 
     yAxis: { 
      minPadding: 0.2, 
      maxPadding: 0.2, 
      min: 0, 
      max: 100, 
      offset: 35, 
      title: { 
       text: 'PacketLoss (%)', 
       margin: 12 
      } 
     }, 
     tooltip: { 
      valueDecimals: 2, 
      valueSuffix: "%" 
     }, 
     plotOptions: { 
      line: { 
       marker: { 
        enabled: false, 
        states: { 
         hover: { 
          enabled: true, 
          radius: 5 
         } 
        } 
       }, 
       shadow: false 
      } 
     }, 
     legend: { 
      enabled: true, 
      layout: 'horizontal', 
      align: 'center', 
      verticalAlign: 'bottom', 
      x: 30, 
      y: 35, 
      floating: true, 
      shadow: true 
     }, 
     series: [{ 
      name: 'PacketLoss', 
      color: '#660000', 
      zIndex: 100, 
      data: [[1373354992000,0],[1373361195000,0],[1373363923000,0],[1373380804000,0],[1373388550000,0],[1373392475000,0],[1373399655000,0],[1373409555000,0],[1373409858000,0],[1373410160000,0],[1373410765000,0],[1373411067000,0],[1373411369000,0],[1373411670000,0],[1373411971000,0],[1373412273000,0],[1373412574000,0],[1373412875000,0],[1373413177000,0],[1373413479000,0],[1373413780000,0],[1373414082000,0],[1373414384000,0],[1373414686000,0],[1373414988000,0],[1373415289000,0],[1373415591000,0],[1373415893000,0],[1373416196000,0],[1373416497000,0],[1373416799000,0],[1373417101000,0],[1373417402000,0],[1373417704000,0],[1373418006000,0],[1373418308000,0],[1373418610000,0],[1373418911000,0],[1373419212000,0],[1373419514000,0],[1373419819000,0],[1373420120000,0],[1373420421000,0],[1373420723000,0],[1373421025000,0],[1373421326000,0],[1373421628000,0],[1373421929000,0],[1373422231000,0],[1373422532000,0],[1373422834000,0],[1373423136000,0],[1373425197000,0],[1373432327000,0]] 
     }] 
    }); 
}); 

這是一個錯誤嗎?還是我發起什麼錯誤?不知道這個bug是否只在highstock叉可見。

感謝

+0

你總是可以設置'minRange:1',它比設置最小和最大效果更好,請參閱:http://jsfiddle.net/fYkQy/3/當然,缺少像是一個錯誤(請參閱Sebastian的答案) 。 –

回答

0

它看起來像一個問題,據報道,我們的開發here

相關問題