9

在创建动态系列和数据时,Highstock 导航器总是将 1970-1-1 作为起点显示有问题……有人遇到过这个问题并有一些解决方法吗?

这是一个例子:http: //jsfiddle.net/sokarovski/SRtvn/

var $container = $('.canvas');
var chart = new Highcharts.StockChart({
    chart: {
        renderTo: $container[0]
    },
    xAxis: {
        type: 'datetime' , 
        ordinal: false 
    } 
});

chart.addSeries({
    data: [
        [Date.UTC(2013,1,1), 0],
        [Date.UTC(2013,1,5), 10],
        [Date.UTC(2013,1,15), 15],
        [Date.UTC(2013,2,5), 20],
        [Date.UTC(2013,2,28), 25],
        [Date.UTC(2013,3,3), 30],
    ]        
});

//I tried to fix it with this also but it does not help
chart.xAxis[0].setExtremes(Date.UTC(2013,1,1), Date.UTC(2013,3,3));
4

2 回答 2

3

这是因为当您尝试将系列/添加点添加到没有系列/数据的图表时,导航器无法正常工作。此处报告此错误:

https://github.com/highslide-software/highcharts.com/issues/624

于 2013-03-06T14:16:21.627 回答
0

What we do is we pre-fetch our data we want to add to the chart and take the first point and create a series on the stock chart with just that one point. We then call the add data code to add the rest of the points such that the chart "plays".

Now, if you do not know what data you are going to get first (for example you let the user click a button to show data1 or data2 and you do not have a default) you can create your chart - but hide it. By using the loading options. So, you create an empty chart and do not show it until such time the user has selected the data.

于 2013-03-06T15:52:08.417 回答