Reputation: 19413
I'm using the Google Visualization API, aka Google Charts, and I'm trying to get the numbers to show ,'s in them.
My data:
var data = google.visualization.arrayToDataTable([
['Device', 'Views'],
['Mobile', 1456632],
['Tablet', 6]
]);
Chart initialization:
var myChart = new google.visualization.PieChart(document.getElementById('myChart'));
myChart.draw(data, { title: 'My pie chart' });
On the pie chart, if you hover over the slices, it shows 1456632
for the Mobile slice. Can I have it show 1,456,632
? I've tried passing in strings and not numbers in the arrayToDataTable
to define my data
, but it needs numbers. Thanks.
Upvotes: 2
Views: 2389
Reputation: 16068
You need to use google formatter:
var formatter = new google.visualization.NumberFormat(
{negativeColor: 'red', negativeParens: true, groupingSymbol:','});
formatter.format(data, 1);
Read more about NumberFormatter
Upvotes: 2