24

In Flot.js, bar graphs and line graphs have numbers as the coordinates in the x and y axis by default.

Line graph sample

How can you make the coordinates such that the numbers are only integers or at least only the integers are visible?

3 Answers3

62

Looks like more recent versions of Flotr use a different option to control this since the original answer:

    xaxis: {
        tickDecimals: 0
    }

Just supply an integer with the number of decimals to show.

NB: This is for Flotr2.

Michael Cordingley
  • 1,485
  • 1
  • 11
  • 23
22

Check out the minTickSize option from the documentation:

Alternatively, you can specify that you just don't want ticks at a size less than a specific tick size with "minTickSize".

So in your graph options, you would specify it like this:

$.plot($('#placeholder'),data,{
   //your options,
   xaxis: {
      minTickSize: 1
   }
});

See it working here: http://jsfiddle.net/ryleyb/g2CTz/

Ryley
  • 21,046
  • 2
  • 67
  • 81
0

If you want to show integers on the x or y-axis try this

yaxis: {
    tickSize: 1,
    tickDecimals: 0
}, 
Ikram Khizer
  • 121
  • 2
  • 10