HighStocks工具提示无法正常工作

时间:2014-09-05 20:06:28

标签: javascript jquery json highcharts highstock

我只是使用了highcharts中的开箱即用示例:

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

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


        rangeSelector : {
            inputEnabled: $('#container').width() > 480,
            selected : 1
        },

        title : {
            text : 'Sample Stock Price'
        },

        series : [{
            name : 'Sample Stock Price',
            data : data,
            type : 'areaspline',
            threshold : null,
            tooltip : {
                valueDecimals : 0
            },
            fillColor : {
                linearGradient : {
                    x1: 0,
                    y1: 0,
                    x2: 0,
                    y2: 1
                },
                stops : [
                    [0, Highcharts.getOptions().colors[0]],
                    [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                ]
            }
        }]
    });
});

});

我替换了"数据"具有以编程方式填充的值的变量: [[1409788800000,14215],[1409702400000,14332],[1409616000000,14569],[1409529600000,14898],[1409443200000,15144],[1409356800000,15335],[1409270400000,15531],[1409184000000,15647],[ 1409097600000,15454],[1409011200000,15143],[1408924800000,15179],[1408838400000,15537],[1408752000000,15784],[1408665600000,15844],[1408579200000,15998],[1408492800000,15678],[1408406400000, 15148],[1408320000000,15106],[1408233600000,15327],[1408147200000,15642],[1408060800000,15781],[1407974400000,15686],[1407888000000,15349],[1407801600000,14830],[1407715200000,14770] [1407628800000,14948],[1407542400000,15217],[1407456000000,15495],[1407369600000,15414],[1407283200000,14976],[1407196800000,14494],[1407110400000,14572],[1407024000000,14979],[ 1406937600000,15541],[1406851200000,15905],[1406764800000,16076],[1406678400000,15997],[1406592000000,15698],[1406505600000,15777],[1406419200000,16012],[1406332800000,16239],[1406246400000, 16367],[1406160000000,16393],[1406073600000,16131],[1405987200000,15862],[14059008 00000,16002],[1405814400000,16206],[1405728000000,16478],[1405641600000,16683],[1405555200000,16803],[1405468800000,16666],[1405382400000,16625],[1405296000000,16992],[1405209600000, 17075],[1405123200000,17127],[1405036800000,17262],[1404950400000,17351],[1404864000000,17154],[1404777600000,16943],[1404691200000,16656],[1404604800000,16718],[1404518400000,16943] [1404432000000,17197],[1404345600000,17379],[1404259200000,17505],[1404172800000,17255],[1404086400000,17191],[1404000000000,17299],[1403913600000,17468],[1403827200000,17664],[ 1403740800000,17741],[1403654400000,17563],[1403568000000,17371],[1403481600000,17049],[1403395200000,17144],[1403308800000,17320],[1403222400000,17492],[1403136000000,17598],[1403049600000, 17670],[1402963200000,17187],[1402876800000,17157],[1402790400000,17226],[1402704000000,17425],[1402617600000,17625],[1402531200000,17746],[1402444800000,17465],[1402358400000,16844] [1402272000000,16937],[1402185600000,17043],[1402099200000,17684],[1402012800000,1814 0],[1401926400000,18304],[1401840000000,18104],[1401753600000,17486],[1401667200000,16666],[1401580800000,15873],[1401494400000,15528],[1401408000000,15495],[1401321600000,15474] [1401235200000,15391],[1401148800000,15380],[1401062400000,15421],[1400976000000,15352],[1400889600000,15312],[1400803200000,15248],[1400716800000,15258],[1400630400000,15323],[ 1400544000000,15437],[1400457600000,15492],[1400371200000,15427],[1400284800000,15429],[1400198400000,15492],[1400112000000,15473],[1400025600000,15439],[1399939200000,15400],[1399852800000, 15373],[1399766400000,15373],[1399680000000,15621],[1399593600000,15645],[1399507200000,15692],[1399420800000,15666],[1399334400000,15583],[1399248000000,15533],[1399161600000,15667] [1399075200000,15514],[1398988800000,15478],[1398902400000,15389],[1398816000000,15414],[1398729600000,15161],[1398643200000,15022],[1398556800000,15305],[1398470400000,15575],[ 1398384000000,15608],[1398297600000,15514],[1398211200000,15339],[1398124800000,15177],[139803 8400000,15352],[1397952000000,15743],[1397865600000,15983],[1397779200000,16090],[1397692800000,16069],[1397606400000,15855],[1397520000000,15761],[1397433600000,15556],[1397347200000, 15737],[1397260800000,15889],[1397174400000,15961],[1397088000000,15950],[1397001600000,15853],[1396915200000,15699],[1396828800000,15906],[1396742400000,16205],[1396656000000,16394] [1396569600000,16303],[1396483200000,16228],[1396396800000,16256],[1396310400000,16065],[1396224000000,15905],[1396137600000,15863],[1396051200000,15766],[1395964800000,15646],[ 1395878400000,15585],[1395792000000,15583],[1395705600000,15605],[1395619200000,15590],[1395532800000,15643],[1395446400000,15609],[1395360000000,15593],[1395273600000,15550]]

工具提示不再正常工作,除了"所有"

之外,任何按钮范围都不会显示图表

这是我所拥有的JSFiddle: http://jsfiddle.net/9Lwp0dw6/1/

非常感谢任何帮助 - 谢谢!

1 个答案:

答案 0 :(得分:0)

在调试器中,highcharts会抛出此错误 - highcharts.com/errors/15。它基本上是说它想要排序数据。您必须对数组进行排序