Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLOT chart date and time on x-axis

Tags:

jquery

flot

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.

like image 560
Satya Avatar asked Jan 10 '23 01:01

Satya


1 Answers

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.

like image 119
Raidri Avatar answered Jan 21 '23 14:01

Raidri