Flot 未正确显示 x 轴标签
我必须显示一个图表,其中 X 轴为日期,Y 轴为金额。将有 8 条线(系列),每条线有 n 个月的数据。 当我绘制图表时,我肯定会发送 6 个月的数据。(一行数据如下所示)
[1251701950000, 34.50553] [1254294030000, 27.014463] [1256972350000, 26.7805] [1259567970000, 33.08871] [1262246430000, 51.987762] [1264924750000, 56.868233]
然而,图表显示如下 http://twitpic.com/1gbb7m
前几个月标签丢失且上个月未正确对齐,我的flot js代码如下
$.plot($("#lgdGraphTab"),graphData, {
xaxis: {
mode: "time",
timeformat: "%b-%y",
monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
minTickSize: [1, "month"]
},
yaxis : {
tickSize: 5
},
series: {
lines: { show: true , shadowSize:0},
points: { show: true }
},
legend:{
container: $('#legendArea'),
noColumns:8
},
clickable: true,
hoverable: true
});
I have to display a graph with date on the X axis and Amt on the Y axis. There will be 8 lines (series) each with n months data.
When I plot the graph I am sending in 6 months data for sure.( one line's data is shown below)
[1251701950000, 34.50553]
[1254294030000, 27.014463]
[1256972350000, 26.7805]
[1259567970000, 33.08871]
[1262246430000, 51.987762]
[1264924750000, 56.868233]
However the graph shows up like this http://twitpic.com/1gbb7m
The first months label is missing and last month is not aligned correctly, my flot js code is as follows
$.plot($("#lgdGraphTab"),graphData, {
xaxis: {
mode: "time",
timeformat: "%b-%y",
monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
minTickSize: [1, "month"]
},
yaxis : {
tickSize: 5
},
series: {
lines: { show: true , shadowSize:0},
points: { show: true }
},
legend:{
container: $('#legendArea'),
noColumns:8
},
clickable: true,
hoverable: true
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据中的所有时间戳都保存每个月的最后一天而不是第一天。我相信这就是你的问题的原因。
All of the timestamps in your data hold the last day of each month rather than the 1st. I believe this is the cause of your problem.