Flot 未正确显示 x 轴标签

发布于 2024-08-28 22:12:43 字数 908 浏览 8 评论 0原文

我必须显示一个图表,其中 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 技术交流群。

扫码二维码加入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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文