Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple x axis tick sets in flot

Tags:

flot

Does anyone know if/how I can create multiple sets of ticks for the x axis in a flot grid? I'm graphing data over time and I'd like to be able to show specific ticks (days of the month) and then more general ticks (months) under the specific ticks. something like:

     1 2 3 4 5 6 7...1 2 3 4 5 6 7 8.....
           JUNE          JULY
like image 768
hackerhasid Avatar asked Oct 11 '22 07:10

hackerhasid


1 Answers

So multiple y-axes are supported as shown here:

http://people.iola.dk/olau/flot/examples/multiple-axes.html

This doc seems to indicate that you can have 2 x-axes: https://github.com/bluesmoon/yui-flot/wiki/API-Documentation---Axes but fails to really explain how it works;

my best guess right now is that you have to have multiple datasets, so you'd have to have a day-by-day series and a month-by-month series, and assign each to a different axis. But I haven't been able to get it to work.

Instead of my single x-axis:

xaxis: { show: false, tickFormatter: nanometers },                                                                                       

I'm using this line:

xaxes: [{ tickFormatter: nanometers }, { tickFormatter: function(n) { return n+"cm^-1" } }],                                               

No luck so far, tell me if you get anywhere!


UPDATE

OK, got it - you have to assign the second dataset to the second axis like this:

data = [{label: "Title",data:[1,2,3,4,5]},{data:[2,4],xaxis:2}]
like image 50
jywarren Avatar answered Oct 14 '22 02:10

jywarren