Highcharts x轴日期时间问题 [英] Highcharts x-axis datetime issue
问题描述
我定义了如何填充Highcharts
的LineChart
.这是用数据库提供的数据填充的.图表的x轴是datetime
类型,x值是DateTime
类型.
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!
编辑
现在creationDateTime是以毫秒为单位的纪元时间:
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);
实际上,该值为. epochconverter.com/对应于正确的值.但是现在我看到了.
infact, the value is that converted with .
推荐答案
如建议的那样, x值必须是纪元时间(以毫秒为单位).我最后的错误是它们都是一样的,所以我看到了垂直线.
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.
这篇关于Highcharts x轴日期时间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!