【发布时间】:2021-06-03 10:30:44
【问题描述】:
我正在尝试使用 DateTime 和数字制作图表; xAxis 是 DateTime,yAxis 是数字值。当我布局数据时,我注意到每次 x 轴的值都是这样的:
since I don't intend to make this post with a long code, please click this
series: [{
data: [
{x: new Date("2021-05-27T01:15Z"), y: 102},
{x: new Date("2021-05-26T06:20Z"), y: 603},
{x: new Date("2021-05-26T06:19Z"), y: 200},
{x: new Date("2021-05-26T06:18Z"), y: 100},
{x: new Date("2021-05-26T06:17Z"), y: 120},
{x: new Date("2021-05-26T24:00Z"), y: 203}
],
}]
}
// THIS CODE THROWS ReferenceError: Highcharts is not defined
我尝试了一种不同的方法,而是在 new Date() 中输入毫秒数:
series: [{
// number of articles published example
//data:[1,2,3]
data: [
{x: new Date(1622078100000), y: 102},
{x: new Date(1622010000000), y: 603},
{x: new Date(1622009940000), y: 200},
{x: new Date(1622009880000), y: 100},
{x: new Date(1622009820000), y: 120},
{x: new Date(1622073600000), y: 203}
],
// pointInterval: 3600000,
}]
// THIS CODE ALSO THROWS ReferenceError: Highcharts is not defined
请注意,我尝试使用它来查找错误原因并最终得到以下数据:
data: [
{x: new Date(16220), y: 102},
{x: new Date(16220), y: 603},
{x: new Date(16240), y: 200},
]
//this code doesn't throw an error, but of course, the date is wrong and if I try to add
//more object into the array, then the error message return
任何人都知道如何正确设置 Highcharts 的 dateTime 以使其不会引发错误?感谢您的帮助
错误信息:
【问题讨论】:
-
x 值的类型应为数字。按照文档api.highcharts.com/highcharts/series.spline.data.x
标签: reactjs highcharts