2013-03-25 21 views
0

編輯HighStock示例2窗格圖表,在軸上設置極值導致體積圖消失。下面是一個例子Highstock xAxis.setExtremes調用導致體積圖消失或繪製在兩個窗格圖表

http://jsfiddle.net/gbcLC/1/

我使用的是雙窗口的圖表,但是當我打電話setExtremes(因爲我想設置導航器的初始值),在大多數情況下的第一張圖是好的,然而,體積圖(這是我的第二個x軸)每次都跳到不同的高度(導致其從x軸脫離),有時它完全消失(儘管y軸本身看起來仍然很好)。

$(函數(){$ .getJSON( '?http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=',函數(數據){

// split the data set into ohlc and volume 
    var ohlc = [], 
     volume = [], 
     dataLength = data.length; 

    for (i = 0; i < dataLength; i++) { 
     ohlc.push([ 
      data[i][0], // the date 
      data[i][1], // open 
      data[i][2], // high 
      data[i][3], // low 
      data[i][4] // close 
     ]); 

     volume.push([ 
      data[i][0], // the date 
      data[i][5] // the volume 
     ]) 
    } 

    // set the allowed units for data grouping 
    var groupingUnits = [[ 
     'week',       // unit name 
     [1]        // allowed multiples 
    ], [ 
     'month', 
     [1, 2, 3, 4, 6] 
    ]]; 

    // create the chart 
    $('#container').highcharts('StockChart', { 
       chart: { 
        events: { 
         load: function() { 
          this.xAxis[0].setExtremes(Date.UTC(2008,1,1),Date.UTC(2008,8,1),true,true); 
         } 
        } 
       },   
     rangeSelector: { 
      selected: 1 
     }, 

     title: { 
      text: 'AAPL Historical' 
     }, 

     yAxis: [{ 
      title: { 
       text: 'OHLC' 
      }, 
      height: 200, 
      lineWidth: 2 
     }, { 
      title: { 
       text: 'Volume' 
      }, 
      top: 300, 
      height: 100, 
      offset: 0, 
      lineWidth: 2 
     }], 

     series: [{ 
      type: 'candlestick', 
      name: 'AAPL', 
      data: ohlc, 
      dataGrouping: { 
       units: groupingUnits 
      } 
     }, { 
      type: 'column', 
      name: 'Volume', 
      data: volume, 
      yAxis: 1, 
      dataGrouping: { 
       units: groupingUnits 
      } 
     }] 
    }); 
}); 

});

回答

0

問題是與動畫相關的,但被固定在最新的master分支:

http://jsfiddle.net/gbcLC/4/

<script src="https://raw.github.com/highslide-software/highcharts.com/master/js/highstock.src.js"></script>