resting
resting

Reputation: 17467

Flot xaxis ticks exceeds the specified number

I'm new to Flot, so my understanding of ticks is the number of columns that flot will draw on the chart.

As my labels are quite long, having 6 ticks fits nicely. But most times, it just exceeds the number I set, and that screws up the labels.

I assume this has to do with Flot's algorithm? Is there any way I can fix it to 6 columns?

A simplet of how I set it.

xaxis: { mode: 'time', timeformat: "%y/%m/%d %H:%M:%S", tick:6 },

Upvotes: 1

Views: 1514

Answers (1)

DNS
DNS

Reputation: 38189

The ticks option is a guideline. Flot tries to match that value, but its first priority is to choose 'round' values, i.e. 5:00 instead of 5:01.

There are several ways to work around this, depending on your data. The guaranteed solution is to calculate your six tick values manually, and provide them to Flot in the 'ticks' array option. Besides that, you may be able to coax Flot into generating the correct number of ticks by adjusting the minTickSize and axis min/max.

Upvotes: 3

Related Questions