2016-06-02 2 views
0

Я пытаюсь воспроизвести примерный пример с верхушками, который я нахожу на скрипке ( link). Я скопировал и вставил код в html-файл, но диаграмма не отображается. Может ли кто-нибудь помочь мне с этой проблемой? Благодарю.График высоких статов не отображается должным образом

Файл HTML выглядит следующим образом:

<!DOCTYPE html> 
<html> 
<head> 

<!--highStocks start--> 

    <!--script src="./static/lib/js/highstock.js"></script> 
    <script src="./static/lib/js/exporting.js"></script--> 

    <script src="http://github.highcharts.com/highstock.js"></script> 
    <script src="http://code.highcharts.com/stock/modules/exporting.js"></script> 
    <script type="text/javascript"> 
$(function() { 
    $.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 = [], 
      volume2 = [], 
      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 
      ]); 

      volume2.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 
     chart = new Highcharts.StockChart({ 
      chart: { 
       renderTo: 'container', 
       alignTicks: false 
      }, 

      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 
      }, { 
       title: { 
        text: 'Volume2' 
       }, 
       top: 400, 
       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 
       } 
      }, { 
       type: 'column', 
       name: 'Volume2', 
       data: volume, 
       yAxis: 2, 
       dataGrouping: { 
        units: groupingUnits 
       } 
      }] 
     }); 
    }); 
}); 
    </script> 


<!--highStocks end--> 



</head> 
<body class="application"> 

<hr> 
<div id="container" style="height: 600px; min-width: 500px"></div> 
<hr> 



</body> 
</html> 

ответ

3

Добавить библиотеку Jquery будет работать

<!DOCTYPE html> 
 
<html> 
 
<head> 
 

 
<!--highStocks start--> 
 

 
    <!--script src="./static/lib/js/highstock.js"></script> 
 
    <script src="./static/lib/js/exporting.js"></script--> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
 
    <script src="http://github.highcharts.com/highstock.js"></script> 
 
    <script src="http://code.highcharts.com/stock/modules/exporting.js"></script> 
 
    <script type="text/javascript"> 
 
$(function() { 
 
    $.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 = [], 
 
      volume2 = [], 
 
      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 
 
      ]); 
 

 
      volume2.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 
 
     chart = new Highcharts.StockChart({ 
 
      chart: { 
 
       renderTo: 'container', 
 
       alignTicks: false 
 
      }, 
 

 
      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 
 
      }, { 
 
       title: { 
 
        text: 'Volume2' 
 
       }, 
 
       top: 400, 
 
       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 
 
       } 
 
      }, { 
 
       type: 'column', 
 
       name: 'Volume2', 
 
       data: volume, 
 
       yAxis: 2, 
 
       dataGrouping: { 
 
        units: groupingUnits 
 
       } 
 
      }] 
 
     }); 
 
    }); 
 
}); 
 
    </script> 
 

 

 
<!--highStocks end--> 
 

 

 

 
</head> 
 
<body class="application"> 
 

 
<hr> 
 
<div id="container" style="height: 600px; min-width: 500px"></div> 
 
<hr> 
 

 

 

 
</body> 
 
</html>

Смежные вопросы