[英]Google Chart hAxis.gridlines.count does not work as expected
我有一個谷歌圖表,百分比值從0到100%(即0到1)當我將hAxis.gridlines.count設置為10期望得到網格線0,10,20 0, 10, 20, ... 90, 100
90,100我得到網格線0, 12, 24, 36, ..., 96, 108
我現在找不到任何解決方案。
這是我的代碼:
function getData() {
// Create the data table.
var data = new google.visualization.arrayToDataTable([
['Category', 'Fulfillment (%)'],
['A', .75],
['B', .50],
['C', .50],
['D', .30],
['E', 0]
]);
// Set chart options
var options = {
'title': 'My Title',
'height': 300,
'backgroundColor': 'none',
'hAxis': {
'maxValue': 1,
format: '#%',
gridlines: {
count: 10
}
},
'colors': ['#F5821E'],
legend: { position: "none" }
};
var formatter = new google.visualization.NumberFormat({ pattern: '#%' });
formatter.format(data, 1);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
閱讀文檔 ,你可以看到, hAxis.gridlines.count
指定多少行畫,沒有繪制位置。 您正在尋找的可能是hAxis.ticks
。
使用count: 11
而不是10
。 這將更改網格線的標簽。
我有同樣的問題(錯誤),我意識到,如果你設置一個圖表的高度(柱形圖),那么水平網格的數量將是2.我想使用的是適當的hAxis.gridlines.count,你應該刪除高度禮。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.