Put only integers in x and y axis of bar and line graphs - Flot

six.strings.and.a.bit picture six.strings.and.a.bit · Oct 16, 2012 · Viewed 12.2k times · Source

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?

Answer

Michael Cordingley picture Michael Cordingley · Apr 22, 2013

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.