【问题标题】:jQuery Flot xaxis Time FormatjQuery Flot xaxis 时间格式
【发布时间】:2012-05-18 18:04:52
【问题描述】:

我正在为我的图表使用 jQuery Plot。我有一个包含数据库中一些时间戳和值的列表。

我想将我的时间戳转换为 H:i:s 格式。 此结果是从 10-05-2012 08:57:45 到 10-05-2012 09:03:40。

var rx = [[1336633065,  152], [1336633071,  152], [1336633076,  152], [1336633080,  153], [1336633086,  152], [1336633090,  152], [1336633095,  152], [1336633100,  152], [1336633105,  152], [1336633110,  150], [1336633115,  150], [1336633120,  152], [1336633125,  152], [1336633130,  150], [1336633135,  149], [1336633140,  153], [1336633145,  149], [1336633150,  152], [1336633155,  149], [1336633161,  149], [1336633165,  152], [1336633170,  152], [1336633175,  151], [1336633180,  150], [1336633185,  149], [1336633190,  151], [1336633195,  152], [1336633201,  152], [1336633205,  149], [1336633210,  151], [1336633215,  149], [1336633220,  151], [1336633225,  152], [1336633230,  149], [1336633235,  151], [1336633240,  152], [1336633245,  149], [1336633250,  152], [1336633255,  150], [1336633260,  152], [1336633265,  152], [1336633270,  149], [1336633275,  152], [1336633280,  150], [1336633285,  152], [1336633290,  149], [1336633295,  152], [1336633300,  149], [1336633305,  152], [1336633310,  150], [1336633315,  152], [1336633321,  149], [1336633325,  149], [1336633330,  152], [1336633335,  150], [1336633340,  152], [1336633345,  149], [1336633350,  152], [1336633355,  149], [1336633360,  149], [1336633365,  150], [1336633370,  152], [1336633375,  150], [1336633380,  152], [1336633385,  150], [1336633390,  150], [1336633395,  152], [1336633400,  150], [1336633405,  152], [1336633410,  152], [1336633415,  149], [1336633420,  152]];

当我使用这个选项时,我的 xaxis 是空的.....我错了什么??????:

var options = {
  legend: { show: false },
  series: {
    lines: { show: true, shadowSize: 1 },
    points: { show: false }
  },
  yaxis: { ticks: 10 },
  xaxis: { mode: "time", timeformat: "%H:%M:%S"
  },
  selection: { mode: "x" }
};

当我使用此选项时,我会在我的 xaxis 中获得时间戳...但这对于阅读此图表的用户来说并不是很清楚:

var options = {
  legend: { show: false },
  series: {
    lines: { show: true, shadowSize: 1 },
    points: { show: false }
  },
  yaxis: { ticks: 10 },
  selection: { mode: "x" }
};

有人可以帮我解决这个问题吗?如何在 xaxis 中将时间戳转换为时:分:秒格式?

【问题讨论】:

    标签: javascript jquery time flot time-format


    【解决方案1】:

    Flot 使用 JavaScript 时间戳,它以毫秒而不是通常的秒表示。所以你需要将你的时间戳乘以一千。

    【讨论】:

    • 谢谢,但我已经找到了。耶,我需要得到我的时间戳,而不是 * 1000。
    • 在四个小时内确定答案,但没有被接受,因为提问者已经找到了。 :(
    【解决方案2】:

    flot 无法识别提到的时间格式。请使用%y/%m/%d

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多