4

I'm using dotnet.highcharts to generate a chart.

If I do not set any label formatting on the y-axis labels, this is what is displayed.

enter image description here

This is good. So 200M = 200,000,000 And it looks like this is done automatically.

If I wanted to put a $ in front of the value and I use:

function() { return '$' + Highcharts.numberFormat(this.value, 0) ; }

Then the label will now display $200,000,000.

How would i get the format to display it with the short form with the dollar sign like $200M ? thanks.

Mike Stone
  • 319
  • 9
  • 22

3 Answers3

11

Unfortunately in this case, you have to either take the pre formatted label, or rebuild the level of abbreviation you want in the formatter yourself.

In this case, you could something like

 yAxis: {
        labels: {
            formatter: function() {
                return '$'+this.value / 1000000 + 'M';
            }
        }
    },
jlbriggs
  • 17,612
  • 4
  • 35
  • 56
5

According to this stackoverflow post, you can call the original formatter with:

this.axis.defaultLabelFormatter.call(this);
Community
  • 1
  • 1
stevenspiel
  • 5,775
  • 13
  • 60
  • 89
0

Put this code before call the chart

Highcharts.setOptions({
    lang: {
        thousandsSep: ','
    }
});
jai3232
  • 383
  • 3
  • 6