如何使用间隔和日期开始将日期时间分配给 highchart

aga*_*era 3 javascript highcharts

HI 在 highchart 中,有什么方法可以在 x 轴上给出时间,如下所示

1) 传递开始时间
2) 给出时间点数组
3) 给出时间单位

例如

开始时间将设置为
pointStart: Date.UTC(timeArr[3],timeArr[1],timeArr[2],timeArr[4],timeArr[5])
其中 timeArr[3] -> 年
timeArr[3] -> 年份
timeArr[1] -> 月份
timeArr[2] -> 月中的某一天
timeArr[4] -> 小时
timeArr[5] -> 分钟

现在设置时间间隔数组如下
[0,60,120,180,240]

现在给出时间单位为 1000(它告诉数组中的时间以秒为单位)

然后 highchart 从开始日期开始绘制 x 轴,然后从时间数组中选择间隔并添加到开始时间并为下一个数据点创建时间

我问这个问题是因为我们的旧应用程序使用 JClass 图表,我正在从中进行转换,这适用于我给出的逻辑

Pab*_*zos 5

使用 pointStart 设置初始日期:

plotOptions: {
    column: {
        pointStart: Date.UTC(2015, 1, 12) // feb 12, 2015
    }
}
Run Code Online (Sandbox Code Playgroud)

在 xAxis 中设置间隔:

xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
            second: '%H:%M:%S',
            minute: '%H:%M',
            hour: '%H:%M',
            day: '%e. %b',
            week: '%e. %b',
            month: '%b \'%y',
            year: '%Y'
    },
    tickInterval: 24 * 3600 * 1000 // interval of 1 day (in your case = 60)
}
Run Code Online (Sandbox Code Playgroud)

测试:http : //jsfiddle.net/ppazos/jjn7noqg/