发车日期问题
我正在尝试在 flot 中显示日期字段:
数据:
var data = [
[parseInt(1309150800.0)*1000, 220],
[parseInt(1309064400.0)*1000, 230],
];
Flot 创建:
$.plot($("#graph"), [ data ], {
grid: {
hoverable: true
},
xaxis: {
mode: "time",
timeformat: "%d.%m.%y"
},
yaxis: {
mode: "number",
tickSize: 2
},
series: {
lines: { show: true },
points: { show: true }
}
});
根据此站点 http://tools.semsym.com/index.php?tool=timestamp×tamp=1309150800 时间戳是 Jun 2011 年 26 日晚上 10:00:00。 但图表看起来像: https://i.sstatic.net/NUayx.png
点有点不对劲。第一个应该是 26,但现在是 25.5。我玩了一下时间戳格式,但无法将其达到特定点。
我缺少什么?
它还显示“26.06.2011”大约 6 次。需要什么配置才能将其保持为 1?
i'm trying to display a date field in flot:
Data:
var data = [
[parseInt(1309150800.0)*1000, 220],
[parseInt(1309064400.0)*1000, 230],
];
Flot creation:
$.plot($("#graph"), [ data ], {
grid: {
hoverable: true
},
xaxis: {
mode: "time",
timeformat: "%d.%m.%y"
},
yaxis: {
mode: "number",
tickSize: 2
},
series: {
lines: { show: true },
points: { show: true }
}
});
According to this site http://tools.semsym.com/index.php?tool=timestamp×tamp=1309150800 the timestamp is Jun 26, 2011 10:00:00 PM.
But the graph looks like: https://i.sstatic.net/NUayx.png
The dots are a bit off. The first one should be at 26, but is at 25,5. I played a bit with timestamp formatting but wasn't able to get it to the specific point.
What am i missing?
Also it shows "26.06.2011" about 6 times. What config is needed to keep it at 1?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保设置了 minTickSize。这是 http://jsfiddle.net/hAXHq/ 的示例,其中我将 minTickSize 设置为 1 天,明确设置最小/最大值。您应该能够根据您的数据以编程方式设置自己的最小值/最大值。
这是代码:
Make sure you set a minTickSize. Here is an example at http://jsfiddle.net/hAXHq/ where I have set minTickSize to 1 day and set the min/max values explicitly. You should be able to set your own min/max programmatically depending on your data.
Here is the code: