0

I am now getting a problem when using flot to display chart in time series. i have the data as below: [[gd(2012, 12, 10, 00, 06, 11), 382.94], [gd(2012, 12, 10, 00, 14, 59), 383.86],...[[gd(2012, 12, 12, 00, 06, 11), 382.94],...[[gd(2012, 12, 14, 00, 06, 11), 382.94],...[[gd(2012, 12, 10, 16, 06, 11), 382.94]] but every time I load this data, the xaxis value will be shown from 18:00 to 4:00. not from 00:00 to 23:00. below is the result screenshot: enter image description here

Do you see that? there are two lines there because the xaxis's is from 18:00 to 04:00, not from 00:00 to 23:00. any one can help me on this? I have studyed it for a while, but result in failure. thx.

here is some useful code:

    function gd(year, month, day, hour, min, second) { 
         return new Date(year, month - 1, day,hour,min,second).getTime(); 
        } 

below article did't save my time: jquery flot xaxis time

Community
  • 1
  • 1
CharlieShi
  • 888
  • 3
  • 17
  • 43
  • Flot will not sort your data for you -- you need to to that before you pass it to flot. I would suggest sorting it after you get the timestamp. – mechenbier Aug 28 '13 at 01:07
  • @prmech, The data I passed to it is sorting ok. but I don't know why it didn't work. – CharlieShi Aug 28 '13 at 01:14

1 Answers1

0

Have solved this。 In backend, we should convert the time format as total seconds from 1970.1.1

so in C# handler: we should get total seconds:

 DateTime.Parse(dr["GetTime"].ToString()).Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds

then In front end, we should use as below:

var data= eval(arrStr);

then all are ok. enter image description here

CharlieShi
  • 888
  • 3
  • 17
  • 43