How can I make the X axis labels in Flot transform with my data?

I use Flot to display some data that I wrap from the server. The data I received on the X axis are in units of milliseconds, and I want to display a graph with the X axis in seconds. So, I thought it was useful to use the transform axis API option. I applied my conversion like this:

 var plot = $.plot($("#placeholder"), { grid: { hoverable: true, clickable: true }, xaxis: { transform: function(x) { return x/1000; } } }); 

I see that my conversion function is called by the wireframe, and I see that the points themselves are transformed - when I attach the plothover event and hover over the points, I see that the X value is converted accordingly. The problem is that the label marks on the x axis also do not convert.

What do I need to do to convert the axis labels themselves to my data?

+1
jquery flot
May 04 '10 at 7:26 a.m.
source share
1 answer

I'm not sure what the β€œright” answer is, but you can provide your own tag labeling function and just do the same job as your conversion function.

 var plot = $.plot($("#placeholder"), { grid: { hoverable: true, clickable: true }, xaxis: { transform: function(x) { return x/1000; }, tickFormatter: function(x) { return x/1000; } } }); 
+4
May 18 '10 at 22:49
source share



All Articles