2
我搜索解決方案,只顯示Google LineChart的hAxis標籤上的每第二個值。谷歌圖表API,只顯示hAxis上的每秒數值
我搜索解決方案,只顯示Google LineChart的hAxis標籤上的每第二個值。谷歌圖表API,只顯示hAxis上的每秒數值
hAxis標籤間隔由hAxis.showTextEvery
選項設置,如here所述。這僅適用於離散(非數字)水平軸。例如:
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['x', 'Cats', 'Blanket 1', 'Blanket 2'],
['A', 1, 1, 0.5],
['B', 2, 0.5, 1],
['C', 4, 1, 0.5],
['D', 8, 0.5, 1],
['E', 7, 1, 0.5],
['F', 7, 0.5, 1],
['G', 8, 1, 0.5],
['H', 4, 0.5, 1],
['I', 2, 1, 0.5],
['J', 3.5, 0.5, 1],
['K', 3, 1, 0.5],
['L', 3.5, 0.5, 1],
['M', 1, 1, 0.5],
['N', 1, 0.5, 1]
]);
// Create and draw the visualization.
new google.visualization.LineChart(document.getElementById('visualization')).
draw(data, {curveType: "function",
width: 500, height: 400,
vAxis: {maxValue: 10},
hAxis: {showTextEvery: 2}}
);
}
如果軸的數值,你可以設置使用hAxis.minorGridlines.count
選項,如下所示:
hAxis: {minorGridlines: {count: 1}}
這將添加一個單獨的網格線(無標籤)中每兩個之間主要網格線。