How to plot a date range on X-axis in Flot Charts?

前端 未结 1 912
遇见更好的自我
遇见更好的自我 2020-12-18 01:53

I\'m using Flot charts to display data for a certain period (to be selected by the user, e.g. last 30 days, last 7 days, from 1st Jan 2013 to 3rd Mar 2013 etc)

So I

相关标签:
1条回答
  • 2020-12-18 02:24

    You will need to change the numbers to UNIX time stamps multiplied by 1000. This is from the API if you search Time Series Data:

    The time series support in Flot is based on Javascript timestamps, i.e. everywhere a time value is expected or handed over, a Javascript timestamp number is used. This is a number, not a Date object. A Javascript timestamp is the number of milliseconds since January 1, 1970 00:00:00 UTC. This is almost the same as Unix timestamps, except it's in milliseconds, so remember to multiply by 1000!

    There is a .Net example in the API:

    public static int GetJavascriptTimestamp(System.DateTime input)
    {
    System.TimeSpan span = new System.TimeSpan(System.DateTime.Parse("1/1/1970").Ticks);
    System.DateTime time = input.Subtract(span);
    return (long)(time.Ticks / 10000);
    }
    

    Here is an example - http://jsfiddle.net/zxtFc/4/

    0 讨论(0)
提交回复
热议问题