gpt4 book ai didi

javascript - 使用 Highcharts 在 y 轴上绘制秒、分和小时

转载 作者:数据小太阳 更新时间:2023-10-29 05:08:41 25 4
gpt4 key购买 nike

我有一些看起来像这样的数据:

min="00:09" med="03:11" mean="23:39" max="12:40:26"

我希望能够将这些值用作数据点,但我不确定如何绘制它们,因为它们不是简单的整数。理想情况下,我希望 Y 轴上的标签显示“小时”之类的内容,或者如果我要使用多个 y 轴,那么它可以显示“分钟”值的“秒”,“平均”值的“分钟”值等适应适当的时间窗口。

我不确定是否可以使用日期时间对象,因为我只有时间值而没有日期。

如有任何想法,我们将不胜感激,并提前致谢。

最佳答案

如果您拥有的时间是静态字符串,您可以将它们转换为日期时间对象...

//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)

...但是如果你能把它们变成毫秒值,你应该没问题。

然后对 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'
}
}
});

关于javascript - 使用 Highcharts 在 y 轴上绘制秒、分和小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8268170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com