问题
The xaxis in my flot line charts can take an array of data up to but no more than 16 in length. The problem is when my data is less than 16, the x axis is spreading out to show the maximum value of whatever the length of the data array is.
Even if my data is say 4 in length, i'd still like to show 16 points on the xaxis.
I have tried various configs and nothing seems to be working :(
http://www.discussthemarket.com/ratings/
The graphs lower down have an x axis greater than the graphs nearer the top which have fewer items in the data. I'd like to consistently apply a fixed length of 16 to the x axis but am really struggling.
回答1:
One possibility is to provide a number for the ticks option:
ticks: 16
However that is treated only as a guideline; Flot always tries to make the ticks fit, and will reduce the number when it detects that they would overlap or run off the side of the plot. If you really want to force it to use 16 (which I wouldn't recommend, since the labels will probably overlap) you'll need to manually provide an array of ticks:
ticks: [0, 5, 10, ...]
回答2:
I've cracked it byadding another data set which is 16 in length but has lines:{show:false} set :) job done!
回答3:
You can use minTickSize
according to the documentation of flot.
minTickSize : [1, "day"],
来源:https://stackoverflow.com/questions/17723904/flot-charts-xaxis-minimum-length