1

I am trying to draw a chart using flot jquery library.

I want to this:

if the value is 4.52124515, I want it to be 4.2

if the values is 41.215, i want it to be 41.2

this is my code

tickFormatter: function (val, axis) {
                       return val + '%';
                   }

the value i am talking about is passing through the val variable.

1 Answers1

3

Try this:

function (val, axis) {                     
    val = Math.round(val * 10) / 10;
    return val + '%';
}

using toFixed will add additional zeros.

Check the JSFiddle with values like 12.02 to see the difference.
JSFIDDLE.

Amir Popovich
  • 29,350
  • 9
  • 53
  • 99