因爲format
選項將不會在這種情況下工作,
可以提供您自己的ticks
爲vAxis
...
使用對象符號來表示每一跳
{
v: value,
f: formattedValue
}
使用谷歌的NumberFormat class ...
var formatNumber = new google.visualization.NumberFormat({
fractionDigits: 0,
groupingSymbol: '.'
});
格式每個刻度使用formatValue
方法
看到下面的工作片段...
google.charts.load('current', {
callback: function() {
var data = new google.visualization.DataTable();
data.addColumn('number', 'x');
data.addColumn('number', 'y');
data.addRows([
[1, 3000],
[2, 3100],
[3, 3200],
[4, 3300],
[5, 3400],
]);
var formatNumber = new google.visualization.NumberFormat({
fractionDigits: 0,
groupingSymbol: '.'
});
var columnRange = data.getColumnRange(1);
var ticks = [];
for (var i = columnRange.min; i <= columnRange.max; i=i+100) {
ticks.push({
v: i,
f: formatNumber.formatValue(i)
});
}
var options = {
hAxis: {
title: 'Month'
},
vAxis: {
ticks: ticks,
title: 'Price (€)'
}
};
var container = document.getElementById('chart');
var chart = new google.visualization.LineChart(container);
chart.draw(data, options);
},
packages: ['corechart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart"></div>