7

I'm incredibly new to web dev. What I'm finding frustrating are the options used in the axesRendererDefaults options in jqplot.

According to this link:

the way to specify how a tick will appear on the axis (either X or Y) will be determined by what is specified by the formatString: '' option.

What options are available for formatString option? In the tutorial given on the jqplot page, they pass options such as: %d, $%d and %n. How do I find the full list of options available?

Are these formatting options separate from jqplot and actually a property of jQuery?

RAM
  • 2,413
  • 1
  • 21
  • 33
Greg Meyer
  • 71
  • 1
  • 1
  • 4

4 Answers4

12

The format commands are similar (if not identical) to those for the sprintf function.

A decent reference for these is http://perldoc.perl.org/functions/sprintf.html

e.g. yaxis: { tickOptions: {formatString: '%.2f'} }

will output a floating point number to 2 decimal places.

Andy Lorenz
  • 2,905
  • 1
  • 29
  • 29
  • there is a section in the git hub repo of the project: https://github.com/jqPlot/jqPlot/ "JavaScript printf/sprintf functions". – gabrielAnzaldo Sep 20 '16 at 18:29
5

http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html

Accecptable format codes are:

Code    Result                  Description
            == Years ==
%Y      2008                Four-digit year
%y      08                  Two-digit year
            == Months ==
%m      09                  Two-digit month
...
1

According to official documentation: https://github.com/jqPlot/jqPlot/ in the last section: "JavaScript printf/sprintf functions", jqplot uses "sprintf for JS"

gabrielAnzaldo
  • 3,014
  • 4
  • 19
  • 19
0

I believe the formatString is the same as used by Highcharts and is a subset of PHP's strftime function. Here's a link to to Highcharts doc about it.

Rich Strle
  • 51
  • 8