FLOT chart date and time on x-axis

14,946

Answer edited after understanding what the problem is:

The ticks on the x axis are not where your data points are (unless you use the ticks option) but are evenly spaced over the range of your time values. If your data ranges over several days there will be only one tick per day and that tick will be at midnight.

To change this behaviour you can use the tickSize option with something like

tickSize: [4, 'hour']

to generate a tick every 4 hours.

See here and here for more info in the documentation.

Share:
14,946
Satya
Author by

Satya

Updated on June 05, 2022

Comments

  • Satya
    Satya about 2 years

    I'm using flot charts. I want to show date and time on x-axis. Here is my code:

    $.plot($("#placeholder"), data, {
        xaxis: {
          mode: "time", 
          timeformat:"%y/%m/%d %H:%M:%S"        
        },
    });
    

    In the graph on x-axis shown as 14/07/15 00:00:00. Time is not displayed.

  • Raidri
    Raidri almost 10 years
    @user3514944 See my edit. I misunderstood your problem.
  • Raidri
    Raidri almost 10 years
    Sorry, my fault. It's tickSize not ticksize.
  • Satya
    Satya almost 10 years
    ok, I changed to tickSize but it is changing in the date only not in time format.It still shows time as 00:00
  • Raidri
    Raidri almost 10 years
    With tickSize: [4, 'hours'] and a wider placeholder div I get this: i.stack.imgur.com/zTJA5.png which shows the expected results