Search code examples
highchartsdotnethighcharts

HighCharts - number format with $ in its short form


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.


Solution

  • 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';
                }
            }
        },