How would I go about adding commas to the numbers shown in the column chart?

629 views
Skip to first unread message

Captain Gordon Freeman

unread,
Mar 31, 2014, 2:18:51 PM3/31/14
to google-visua...@googlegroups.com
Like the title says I have a column chart that shows the values of each column on the column itself. I would like to add commas to it if possible. I have looked at this page here: https://developers.google.com/chart/interactive/docs/reference?hl=de-DE#numberformatter but I think I'm missing something because it doesn't quite work. Here's my code so far:

var chart = new google.visualization.ColumnChart(document.getElementById('homescreenDetailChart'));

    var formatter = new google.visualization.NumberFormat({
        groupingSymbol: ','
    });

    chart.draw(view, options);

What'd I miss?

asgallant

unread,
Mar 31, 2014, 4:23:02 PM3/31/14
to google-visua...@googlegroups.com
You have to set the format pattern and format your data:

var formatter = new google.visualization.NumberFormat({
    pattern: '#,###',
    groupingSymbol: ','
});
// format column 1 of the DataTable
formatter.format(data, 1);
Reply all
Reply to author
Forward
0 new messages