user944513
user944513

Reputation: 12729

how to add comma between the digit (as a label )

I am working on high chart .I want to add comma between the digit (as a label ).I am using high chart http://jsfiddle.net/xpLgj7n5/ enter image description here

As shown in image there is gap between 0 and 7 .I understand this , it is because number represent the thousand. I need to add comma between them ",".I need to display numbers like this "10,700" when I change the data nothing happen I change the data like this data: [10,700, 31,00, 63,500, 20,300, 2,000]

nothing happen.

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Historic World Population by Region'
        },
        subtitle: {
            text: 'Source: <a href="https://en.wikipedia.org/wiki/World_population">Wikipedia.org</a>'
        },
        xAxis: {
            categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
            title: {
                text: null
            }
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Population (millions)',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        tooltip: {
            valueSuffix: ' millions'
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                }
            }
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -40,
            y: 80,
            floating: true,
            borderWidth: 1,
            backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
            shadow: true
        },
        credits: {
            enabled: false
        },
        series: [{
            name: 'Year 1800',
            data: [10700, 3100, 63500, 20300, 2000]
        }]
    });
}); 

Upvotes: 0

Views: 63

Answers (2)

proudmercer
proudmercer

Reputation: 1

That may work, but this also works:

 plotOptions: {
    line: {
        dataLabels: {
            enabled: true,
            format: '${y:,.2f}'
        }
    }
}

$ - for dollar sign Y - for y axis , - adds a comma where a space would be 2f - two digits after decimal point

ex: format: '${y:,.2f}' would show up as $10,000.00

Upvotes: 0

Prashanth Thurairatnam
Prashanth Thurairatnam

Reputation: 4361

Refer to documentation

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

Fiddle

Upvotes: 3

Related Questions