LCL*_*LCL 6 javascript jquery highcharts
我有一些看起来像这样的数据:
min ="00:09"med ="03:11"mean ="23:39"max ="12:40:26"
我希望能够将这些值用作数据点,但我不确定如何绘制它们,因为它们不是简单的整数.理想情况下,我希望Y轴上的标签显示"小时"或者如果我使用多个y轴,那么它可以显示'min'值的'秒','''的'分钟'值等等适应适当的时间窗口.
我不确定我是否可以使用datetime对象,因为我只有时间值而不是日期.
任何想法将得到赞赏,并提前感谢.
NT3*_*3RP 10
如果您拥有的是静态字符串,则可以将它们转换为日期时间对象...
//convert 'string' times into a timestamp (milliseconds)
//so long as your string times are consistently formatted
//e.g. "0:03:00" not "3:00"
var t = Date.parse("1-1-1 " + yourTime)
Run Code Online (Sandbox Code Playgroud)
...但是如果你可以将它们变成毫秒值,你应该没问题.
然后使用y轴的正常时间格式,并使用日期标签格式将其格式化为...
var chart = new HighChart({
//...
yAxis: {
type: 'datetime', //y-axis will be in milliseconds
dateTimeLabelFormats: { //force all formats to be hour:minute:second
second: '%H:%M:%S',
minute: '%H:%M:%S',
hour: '%H:%M:%S',
day: '%H:%M:%S',
week: '%H:%M:%S',
month: '%H:%M:%S',
year: '%H:%M:%S'
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11971 次 |
| 最近记录: |