2013-07-02 108 views
0

xAxis中的你好,我需要使用getTime()(例如)每天早上0:00或者早上06:00或者中午12:00或者在下午18:00每天在同一小時開始

xAxis: { categories: ["+6","+9","+12","+15","+18","+21","+24","+27","+30","+33","+36","+39","+42","+45","+48","+51","+54","+57","+60","+63","+66","+69","+72","+75","+78","+81","+84","+87","+90","+93","+96","+99","+102","+105","+108","+111","+114","+117","+120","+123",+"126","+129","+132","+135","+138","+141","+144","+147","+150","+153","+156","+159","+162","+165","+168","+171","+174","+177","+180","+183","+186","+189","+192"], 

+6總是開始於00:00時,6小時至12:00和18:00

所以,我需要知道函數的getTime()開始在特定的時間每天爲四個不同的圖形

感謝

+0

你能表現出一定的樣機應該怎麼這個樣子?在Highcharts中,您可以設置[pointStart](http://api.highcharts.com/highcharts#plotOptions.series.pointStart)和[pointInterval](http://api.highcharts.com/highcharts#plotOptions.series.pointInterval) 。 –

+0

感謝: 我同意,但我需要動態的pointstar(今天上午12.00開始,明天............每天上午12.00開始應該開始於12.00上午)http:// jsfiddle .net/raposu/JtMDj /但我不能使它工作 – raposu

+0

'pointStart'如何可以動態?你的意思是每個點應該在'12:00:00:AM AM'?在這種情況下,請看一下:http://jsfiddle.net/JtMDj/2/ –

回答

1

例子:http://jsfiddle.net/JtMDj/2/

需要設置pointStart和pointInterval以這種方式:

var date = new Date(); 
date.setHours(12); 
date.setMinutes(0); 
date.setSeconds(0); 
date.setMilliseconds(0); 


var ts = Math.round(date/1000); 
var tsNoon = ts; 

var chart = new Highcharts.Chart({ 
    chart: { 
     renderTo: 'container' 
    }, 
    xAxis: { 
     type: 'datetime', 
     dateTimeLabelFormats: { 
      day: '%e of %b' 
     } 
    }, 

    series: [{ 
     data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], 
     pointStart: tsNoon * 1000, // highcharts asks for miliseconds 
     pointInterval: 24 * 3600 * 1000 // one day 
    }] 
}); 
+0

它的工作完美,謝謝 – raposu

相關問題