2015-09-10 108 views
0

我在我的javascript中使用下面的代碼,但獲取圖表時出現錯誤,即「a.ownerdocument未定義」如果我在「高圖」庫中繪製線圖,那麼它的作品精細。這裏是我身邊的確切代碼。Highstock錯誤:a.ownerDocument未定義

(function ($) { 


    $(document) 
      .ready(
        function() { 
         // alert("Hello! I am an alert box!!"); 


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

          // split the data set into ohlc and volume 
          var ohlc = [], 
           volume = [], 
           dataLength = data.length, 
           // set the allowed units for data grouping 
           groupingUnits = [[ 
            'week',       // unit name 
            [1]        // allowed multiples 
           ], [ 
            'month', 
            [1, 2, 3, 4, 6] 
           ]], 

           i = 0; 

          for (i; i < dataLength; i += 1) { 
           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 
           ]); 
          } 

          // create the chart 
          $('#container').highcharts('StockChart', { 

           rangeSelector: { 
            selected: 1 
           }, 

           title: { 
            text: 'AAPL Historical' 
           }, 

           yAxis: [{ 
            labels: { 
             align: 'right', 
             x: -3 
            }, 
            title: { 
             text: 'OHLC' 
            }, 
            height: '60%', 
            lineWidth: 2 
           }, { 
            labels: { 
             align: 'right', 
             x: -3 
            }, 
            title: { 
             text: 'Volume' 
            }, 
            top: '65%', 
            height: '35%', 
            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

你能複製你的例子作爲jsfiddle.net現場演示? –

+0

它在Jsfiddle.net中正常工作,但是當我在Drupal環境中使用它時,它會出現此錯誤。所有與「highcharts」選項一起使用的圖表都可以正常工作,但是當使用「highstock」選項時會出現錯誤。 – Bilal

+0

因此,它看起來像與drupal腳本衝突,你是否試圖禁用所有的擴展/插件? –

回答