开发者

multiple x axis tick sets in flot

Does anyone know if/how I 开发者_JAVA技巧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


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}]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜