gpt4 book ai didi

javascript - Google Chart hAxis.gridlines.count 无法按预期工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:05:00 25 4
gpt4 key购买 nike

我有一个百分比值从 0 到 100%(即 0 到 1)的 google 图表当我将 hAxis.gridlines.count 设置为 10 时,希望在 0, 10, 20, ... 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);
}

最佳答案

阅读 the documentation ,您可以看到 hAxis.gridlines.count 指定要绘制多少行,而不是绘制它们的位置。您正在寻找的可能是 hAxis.ticks

关于javascript - Google Chart hAxis.gridlines.count 无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25552824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com