答案 0 :(得分:1)
{hAxis,vAxis,hAxes.*,vAxes.*}.format
用于轴标签...
工具提示处理数据
使用格式化程序格式化数据,例如NumberFormat
NumberFormat
- 描述应如何格式化数字列。格式化选项包括指定前缀符号(例如美元符号)或用作千位标记的标点符号。
NumberFormat.format(dataTable, columnIndex)
var formatMS = new google.visualization.NumberFormat({
pattern: '# (ms)'
});
formatMS.format(data, colIndex);
请参阅以下工作代码段...
google.charts.load('current', {
callback: drawChart,
packages: ['bar']
});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['x', 'y0', 'y1'],
['row 0', 10, 30],
['row 1', 20, 40],
['row 2', 30, 60],
['row 3', 40, 80]
]);
var formatMS = new google.visualization.NumberFormat({
pattern: '# (ms)'
});
// format y
for (var colIndex = 1; colIndex < data.getNumberOfColumns(); colIndex++) {
formatMS.format(data, colIndex);
}
var chart = new google.charts.Bar(document.getElementById('chart_div'));
chart.draw(data);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>