gpt4 book ai didi

javascript - 在 Google Charts 中设置条形图的基线和范围

转载 作者:行者123 更新时间:2023-11-27 23:46:18 24 4
gpt4 key购买 nike

我正在绘制代表美国凶杀率的条形图。我试图通过将基线设置为 > 0 来 chop 此图表,但代码:

    var options = {
chart: {
title: 'Intentional homicide rate per 100,000 population, by country/territory (2000-2013) in the US',
subtitle: 'Intentional homicide is defined as unlawful death purposefully inflicted on a person by another person',
hAxis: {title: 'Year'},
vAxis: {
title: 'Rate per 100,000',
viewWindow:{
max:20,
min:2
},
// ticks: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
},
}
};

没有完成它的工作,并且显示了与我的目标相反的整个范围。

This是图表的完整代码。我做错了什么?

相同的过程适用于面积图 ( Pluckr example )...怎么会这样?

最佳答案

正如其他答案中所述,您的代码不正确。

使用 Material 图表时,您需要使用函数google.charts.Bar.convertOptionsSource (向下滚动一点,或按 ctrl + f 进行转换选项)。

您当前正在使用以下内容绘制图表

chart.draw(data, options);

正确的方法是

chart.draw(data, google.charts.Bar.convertOptions(options));

Working plunker

(这也是它使用面积图的原因。这不是 Material 图)。

关于javascript - 在 Google Charts 中设置条形图的基线和范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33148280/

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