2

I'm trying to get a sum over a stacked column in a Highcharts chart to show both the $ and commas to separate thousands.

Here is an excerpt:

yAxis: {
   stackLabels: { 
       enabled: true,
             formatter: function() {
                   return 'Total: $' + this.total;
               },
       },
   labels: {
     format: '${value:,.0f}',
  },
  title: {
        text: 'Total $'
    },
},

The labels appear right, but can't quite get the "this.total" to display with commas for the value above the stacks. Any ideas?

Thanks in advance.

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
James Orr
  • 75
  • 2
  • 10
  • This should give you the commas http://stackoverflow.com/questions/3883342/add-commas-to-a-number-in-jquery – ded Jul 15 '15 at 21:35

1 Answers1

6

Use the Highcharts.numberFormat which has the definition like this

numberFormat (Number number, [Number decimals], [String decimalPoint], [String thousandsSep])

formatter: function () {
  return Highcharts.numberFormat(this.total, 1, '.', ',');
}

Here is a demo http://jsfiddle.net/dhirajbodicherla/ah7r2fy1/2/

Dhiraj
  • 32,144
  • 8
  • 59
  • 77