Highstock错误:a.ownerDocument未定义

时间:2015-09-10 23:27:13

标签: highcharts

我在我的javascript中使用以下代码,但在呈现图表时得到错误,即“a.ownerdocument未定义”如果我在“highchart”库中绘制线图,那么它工作正常。这是我方的确切代码。

(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
                                    }
                                }]
                            });
                        });

1 个答案:

答案 0 :(得分:0)

如果您使用任何其他图表库,如flot等或任何冲突的库..删除它们。

同样的问题在这里得到解答:Initializing Highstock.js throws a jQuery error in getComputedStyle