numberFormat: The numberFormat property specifies the format of numeric labels using one of the following:
- 'auto' (automatic)
- JSON Object
- format 'string'
- function()
auto: Use numberFormat: 'auto' to let the charting engine choose the number format based on the chart data. Prefix and suffix characters can be added to the chosen format by enclosing auto in brackets. Example:
data: [[1000,2000,3000,4000,5000]], title: {visible: false}, border: {width: 2, color: 'teal'}, blaProperties: {orientation: 'vertical'}, yaxis: {labels: {font: 'bold 10pt Sans-Serif', color: 'red'}, numberFormat: '~${{auto}}+' }, dataLabels: {font: 'bold 10pt Sans-Serif', color: 'teal', numberFormat: '~${{auto}}+'}, series: [{series: 0, color: 'teal'}]
JSON Object: The JSON object includes the following properties:
numberFormat: { mode: 'string', thousandSep: 'string', decimalSep: 'string', decimalPlaces: Number, grouping: 'string', prefix: 'string', suffix: 'string', }mode: Use 'numeric', 'percent', 'currency', or 'scientific'
thousandSep: Character to separate values above and in multiples of a thousand (e.g., 1,000,000).
decimalSep: Character to separate decimals (e.g., 1.00)
decimalPlaces: Number of decimal places (i.e., number of digits to show to the right of the decimalSep character).
grouping: Use 'K', 'M', 'B', or 'T' to group large numbers by thousands (i.e., 1,000 = 1K), millions (i.e., 1 million = 1M), billions (i.e., 1 billing = 1B), or trillions (i.e., 1 trillion = 1T).
prefix: Character(s) to add to the front of the label
suffix: Character(s) to add to the end of the label
Example:
data: [[1000,2000,3000,4000,5000]], title: {visible: false}, border: {width: 2, color: 'teal'}, blaProperties: {orientation: 'vertical'}, yaxis: {labels: {font: 'bold 10pt Sans-Serif', color: 'red'}, numberFormat: {mode: 'currency', decimalPlaces: 0,grouping: 'K', prefix: '~',suffix: '+'} }, dataLabels: {font: 'bold 10pt Sans-Serif', color: 'teal', numberFormat: {mode: 'currency', decimalPlaces: 0,grouping: 'K', prefix: '~',suffix: '+'} }, series: [{series: 0, color: 'teal'}]
string: You can specify the format of numeric labels using a format string:
numberFormat: 'string'The string must be in the format defined by the Custom Numeric Format Strings defined at: http://msdn.microsoft.com/en-us/library/0c899ak8(vs.71).aspx.
In addition to the format specifiers defined here, you may also use the following characters:
- 't' to specify a thousands separator character.
- 'd' to specify a decimals separator character.
- back tick (`): A percent sign (%) in a format string causes a number to be multiplied by 100 before it is formatted. Add a back tick in front of the percent sign (`%) to disable the multiplication.
Examples:
// format 4000.5 as '4.000,5' (European standard) data: [[1000,2000,3000,4000,5000]], title: {visible: false}, border: {width: 2, color: 'teal'}, blaProperties: {orientation: 'vertical'}, yaxis: {labels: {font: 'bold 10pt Sans-Serif', color: 'red'},numberFormat: 't.d,#,#.#'}, dataLabels: {font: 'bold 10pt Sans-Serif', color: 'teal', numberFormat: 't.d,#,#.#'}, series: [{series: 0, color: 'teal'}]// format percentage without multiplier data: [[10,20,30,40,50]], title: {visible: false}, border: {width: 2, color: 'teal'}, blaProperties: {orientation: 'vertical'}, yaxis: {labels: {font: 'bold 10pt Sans-Serif', color: 'red'}, numberFormat: '[>9]#`%;[<0]-#`%;[<=9]#`%;[=0]0'}, dataLabels: {font: 'bold 10pt Sans-Serif', color: 'teal', numberFormat: '[>9]#`%;[<0]-#`%;[<=9]#`%;[=0]0'}, series: [{series: 0, color: 'teal'}]
function(): The function takes one argument (the number to format) and returns a string. Example:
// Return number with a '$' in front chart.yaxis.numberFormat = function(n){ return '$' + n; };
This cannot be used inside the traditional JSON-style blocks { x: y }. It can only be used with the 'dot' notation as shown in this example.
numberFormat: '[>9]#,#;[<0]-#.#;[<9]#.#;[=0]0'
numberFormat: '[>=9]#,#;[<0]-#.#;[<9]#.#;[=0]0'