Greg Meyer
Greg Meyer

Reputation: 71

jqplot tickOptions formatString options

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?

Upvotes: 7

Views: 21021

Answers (4)

gabrielAnzaldo
gabrielAnzaldo

Reputation: 3294

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

Upvotes: 1

Andy Lorenz
Andy Lorenz

Reputation: 3084

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.

Upvotes: 12

user649198
user649198

Reputation:

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
...

Upvotes: 5

Rich Strle
Rich Strle

Reputation: 51

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.

Upvotes: 0

Related Questions