Search code examples
highchartshighcharts-ng

printing pie's dataLabels numbers with commas


I'm trying to print numbers with commas (showing 9,000 instand of just 9000), this is the way I'm setting the format format: '{point.name}: {point.y}'

I cant find a way to get {point.y} into a function that will return the wanted result, I tried this way format: '{point.name}: '+ numberWithCommas(point.y) but then of course point is not defined I'm not sure how to handle it, any direction how can I make it work ?

thanks


Solution

  • You need to do two things:

    • set separator:

      Highcharts.setOptions({
        lang: {
          decimalPoint: '.',
          thousandsSep: ','
        }
      });
      
    • set point format, to use that separator:

      format: '{point.name}: {point.y:,.0f}'
      

    More about formatting string in Highcharts can be found in the DOCs ;)

    And live demo.