jquery 浮点 xaxis 时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2507235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jquery flot xaxis time
提问by Tommaso Taruffi
In this example in xaxis will compare the days...
在此示例中,xaxis 将比较天数...
$.plot($("#placeholder"), data, {
yaxis: {},
xaxis: { mode: "time",minTickSize: [1, "day"],timeformat: "%d/%m/%y"},"lines": {"show": "true"},"points": {"show": "true"},clickable:true,hoverable: true
});
How I can print time?
如何打印时间?
This is the result that I wanna:
这是我想要的结果:
22:00 23:00 00:00 01:00 02:00 ...... 23:00 00:00 01:00 02:00 .... 06:00
22:00 23:00 00:00 01:00 02:00 ...... 23:00 00:00 01:00 02:00 .... 06:00
Is it possible?
是否可以?
回答by MaTriXy
From the Api Official Docs of Flot: (see https://github.com/flot/flot/blob/master/API.md)
来自 Flot 的 Api 官方文档:(参见https://github.com/flot/flot/blob/master/API.md)
xaxis: {
mode: "time",
timeformat: "%y/%m/%d"
}
This will result in tick labels like "2000/12/24". The following specifiers are supported
这将导致像“2000/12/24”这样的刻度标签。支持以下说明符
%h: hours
%H: hours (left-padded with a zero)
%M: minutes (left-padded with a zero)
%S: seconds (left-padded with a zero)
%d: day of month (1-31), use %0d for zero-padding
%m: month (1-12), use %0m for zero-padding
%y: year (2 digits)
%Y: year (4 digits)
%b: month name (customizable)
%p: am/pm, additionally switches %h/%H to 12 hour instead of 24
%P: AM/PM (uppercase version of %p)
回答by undertakeror
$.plot($("#placeholder"), data, {
yaxis: {
},
xaxis: { mode: "time",minTickSize: [1, "hour"],
min: (new Date("2000/01/01")).getTime(),
max: (new Date("2000/01/02")).getTime()
},
"lines": {"show": "true"},
"points": {"show": "true"},
clickable:true,hoverable: true
});
use this as a starting point and you can see the result here http://jsfiddle.net/UEePE/
以此为起点,您可以在此处查看结果http://jsfiddle.net/UEePE/