最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery Flot xaxis Time Format - Stack Overflow

programmeradmin6浏览0评论

I'am using jQuery Plot for my graph. I have a list with some timestamp's and value's from a database.

I want to convert my timestamp to H:i:s format. This results are from 10-05-2012 08:57:45 to 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]];

When i use this options my xaxis is empty..... What do i wrong???????:

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" }
};

When i use this options i get the timestamps in my xaxis... But this is not very clear for user that read this graph:

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

Can someone help me with this? How do i convert time stamp to hour:minute:seconds format in xaxis?

I'am using jQuery Plot for my graph. I have a list with some timestamp's and value's from a database.

I want to convert my timestamp to H:i:s format. This results are from 10-05-2012 08:57:45 to 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]];

When i use this options my xaxis is empty..... What do i wrong???????:

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" }
};

When i use this options i get the timestamps in my xaxis... But this is not very clear for user that read this graph:

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

Can someone help me with this? How do i convert time stamp to hour:minute:seconds format in xaxis?

Share Improve this question edited Sep 4, 2013 at 9:25 Doug 3,3121 gold badge26 silver badges32 bronze badges asked May 10, 2012 at 7:36 user1386421user1386421 311 gold badge2 silver badges4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 17

Flot uses JavaScript timestamps, which are expressed in milliseconds rather than the usual seconds. So you need to multiply your timestamps by a thousand.

The Time format mentioned is not recognized by flot. Please use %y/%m/%d

发布评论

评论列表(0)

  1. 暂无评论