Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQplot Format String

Can I please have some help to format the string on the Y Axis that has a '%' sign.

Here is the code for a '$':

tickOptions: {formatString: '$%d'}

How do I format the string to use a '%' sign as the '%' sign is used as a 'keyword'?

like image 486
Garry Avatar asked Jan 31 '26 18:01

Garry


2 Answers

Try something like this:

tickFormatter = function (format, val) { 
return val+"%";
}

And add this option to the plot:

axes: {
 yaxis: {
 tickOptions: {
  formatter: tickFormatter
 }
}

http://jsfiddle.net/pabloker/9ZrKA/3/

like image 183
Pablo Claus Avatar answered Feb 03 '26 10:02

Pablo Claus


To write a '%' sign you have to double it :

axes:
   {yaxis: 
        {tickOptions: 
               {formatString: '%%%d'}
        }
   }

%%%d will write '%10' if your value is 10. Similarly, %d%% will write '10%' if again your value is 10. So you just have to replace the '$' sign by '%%'.

Anthony.

like image 26
AnthonyLeGovic Avatar answered Feb 03 '26 11:02

AnthonyLeGovic