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
  • 732,580
  • 175
  • 1,330
  • 1,459
James Orr
  • 85
  • 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

7

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
  • 33,140
  • 10
  • 61
  • 78