Google visualization 如何格式化';在谷歌图表中有逗号

Google visualization 如何格式化';在谷歌图表中有逗号,google-visualization,Google Visualization,我正在使用谷歌可视化API,也就是aka,我正试图让数字显示出来 我的数据: var data = google.visualization.arrayToDataTable([ ['Device', 'Views'], ['Mobile', 1456632], ['Tablet', 6] ]); 图表初始化: var myChart = new google.visualization.PieChart(document.getElementById('myChart')); m

我正在使用谷歌可视化API,也就是aka,我正试图让数字显示出来

我的数据:

var data = google.visualization.arrayToDataTable([
  ['Device', 'Views'],
  ['Mobile', 1456632],
  ['Tablet', 6]
]);
图表初始化:

var myChart = new google.visualization.PieChart(document.getElementById('myChart'));
myChart.draw(data, { title: 'My pie chart' });

在饼图上,如果将鼠标悬停在切片上,移动切片将显示
1456632
。我可以让它显示
1456632
?我尝试在
arrayToDataTable
中传入字符串而不是数字来定义我的
数据,但它需要数字。谢谢。

您需要使用google formatter:

var formatter = new google.visualization.NumberFormat(
  {negativeColor: 'red', negativeParens: true, groupingSymbol:','});
formatter.format(data, 1);      

阅读更多关于

我使用此技巧格式化每个数字列:for(I=1;I