Adding thousands separator for custom formatted highcharts tooltip

Use Highcharts.numberFormat() in point.x or point.y

example:

tooltip: {
  enabled: true,
  split: true,
  shared: true,
  formatter: function () {
    // The first returned item is the header, subsequent items are the points
    return [Highcharts.dateFormat("%Y-%m-%d %H:%M:%S", this.x)].concat(
      this.points
        ? this.points.map(function (point) {
            return (
              point.series.name +
              ": " +
              // numberFormat(data, decimal)
              Highcharts.numberFormat(point.y, 2)
            );
          })
        : []
    );
  },
},

Just following Nishith Kant Chaturvedi's answer, and since there is no jsfiddle example available, here you can see how to implement that answer.

Highcharts.setOptions({
    lang: {
      decimalPoint: '.',
      thousandsSep: ','
    }
});

Highcharts.chart('container', {
    chart: {
        type: 'column'
    },
    title: {
        text: ''
    },
    xAxis: {
        categories: ['Salary']
    },
    yAxis: {
        title: {
            text: ''
        },
        stackLabels: {
            enabled: true,
            format: '{total:,.2f} $us'
        },
        labels: {
            format: "{value:,.2f} $us",
        }
    },
    legend: {
        backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
        borderColor: '#CCC',
        borderWidth: 1,
    },
    tooltip: {
        headerFormat: '<b>{point.x}</b><br/>',
        pointFormat: '{series.name}: {point.y}<br/>Total: {point.stackTotal}'
    },
    plotOptions: {
        column: {
            stacking: 'normal',
            dataLabels: {
                    format: '{point.y:,.2f} $us',
                enabled: true,
                color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
            }
        }
    },
    series: [{
            type: 'column',
        name: 'Tomas',
        data: [60000]
    }, {
            type: 'column',
        name: 'Amy',
        data: [18000]
    }, {
            type: 'column',
        name: 'Jenny',
        data: [85000]
    }]
});

http://jsfiddle.net/zrc5skLy/


use thousand separator in lang

$(function () {
Highcharts.setOptions({

    lang: {
      decimalPoint: '.',
      thousandsSep: ','
    }
});

and in tooltip- formatter use like

   tooltip: {
             pointFormat: '<b>{point.x} :</b>' + 'Count: <b>{point.y:,.0f}</b>',

            shared: true,
            useHTML: true
        }

Updated fiddle with separator without decimal point

Tags:

Highcharts