Highstocks 图表未正确显示

Highstocks chart doesn't show up properly

我正在尝试复制我在 fiddle( link) 上找到的 highstocks 图表示例。我将代码复制并粘贴到 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>

添加 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>