如何将日期时间分配给具有间隔和日期开始的高图

时间:2013-06-05 12:52:50

标签: javascript highcharts

HI在高图中,有没有办法在x轴上给出时间,如下所示

1)通过开始时间
2)给出一系列时间点
3)给出时间单位

例如

start time will set as
pointStart: Date.UTC(timeArr[3],timeArr[1],timeArr[2],timeArr[4],timeArr[5])
where timeArr[3] -> year
timeArr[3] -> year
timeArr[1] -> month
timeArr[2] -> day of month
timeArr[4] -> hour
timeArr[5] -> minute

now set time intervals array as below
[0,60,120,180,240]

now give unit of time as 1000(which tells time in array is in seconds)

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

我问这个问题,因为我们的旧应用程序使用JClass图表,我正在转换,这对我给出的逻辑起作用

2 个答案:

答案 0 :(得分:4)

使用pointStart设置初始日期:

plotOptions: {
    column: {
        pointStart: Date.UTC(2015, 1, 12) // feb 12, 2015
    }
}

在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)
}

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

答案 1 :(得分:1)

如果我理解正确,你正在寻找pointInterval:

http://api.highcharts.com/highcharts#plotOptions.series.pointInterval

如果那不能满足您的需求,那么只需解析您的对象就可以满足您的需求......

相关问题