Highcharts x-axis datetime issue

巧了我就是萌 提交于 2019-12-11 06:27:55

问题


in my javascript I defined how to populate a LineChart of Highcharts. This is populated with the data given by a database. The x-axis of the chart is of datetime type and the x-value is DateTime type.

xAxis: {
     type: 'datetime',
     labels: {
            formatter: function () {
               return Highcharts.dateFormat('%d %b - %H:%M:%S', this.value);
            }
     }
},


lineCharts[index].series[roiIndex].addPoint([point.creationDateTime, point.result]);

but what I see is the following:

I can't find the solution..does anyone have an idea? Thanks!

EDIT

Now creationDateTime is the epoch time expressed in milliseconds:

DateTime date = roi.created_at;
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var creationDateTimeEpoch = Convert.ToInt64((date - epoch).TotalMilliseconds);

infact, the value is that converted with https://www.epochconverter.com/ corresponds to the correct value. But now I see the series .


回答1:


As suggested, x value must be epoch time, in milliseconds. My final error was that they were all the same, so I saw the vertical lines.



来源:https://stackoverflow.com/questions/43736087/highcharts-x-axis-datetime-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!