2016-02-05 61 views
1

此图表(线)完美地工作。但我与DATEFORMAT()的格式问题:我不能显示在Y-M-d H-M-S格式的时间。Highcharts.dateFormat( “%Y-%间 - %d%H:%M”,this.x)不工作

<!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="//code.highcharts.com/highcharts.js"></script> </head> <body> <div id="chart"></div> <script> $(document).ready(function() { $("#chart").highcharts({ xAxis: { type: "datetime", labels: { formatter: function() { return Highcharts.dateFormat("%I:%M", this.value); }, } }, yAxis: [{ labels: { formatter: function() { return (this.value) }, } }], tooltip: { formatter: function() { var s = "<span>" + Highcharts.dateFormat("%Y-%m-%d %H:%M", this.x) + "</span>"; s += "<table>", $.each(this.points, function(i, point) { s += '<tr><td><span>' + point.series.name + "</span> :</td><td></strong>" + point.y + "</strong></td></tr>"; }); s += "</table>" return s; }, shared: true, style: { "line-height": "120%" }, useHTML: true }, series: [{ name: '1', data: [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5] }, { name: '2', data: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10] }, { name: '3', data: [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15] }], }); }); </script> </body> </html>

为什么提示给我1970-01-01 00 时,它应该给我2016年2月5日02:00 什么是错的白衣这个代码 与x轴给我00:00:00.0002 ??

回答

2

您需要添加x轴的信息,只需添加pointStart(设置起点)和pointInterval(X数据之间的间隔)。

请检查jsfiddle

plotOptions: { 
    series: { 
    pointStart: Date.UTC(2016, 01, 5,2), 
    pointInterval: 3600 * 1000 // one Hour 
    } 
}, 
相关问题