如何在Google图表wrap.setOptions中设置动态值?

发布于 2024-12-01 07:54:35 字数 584 浏览 3 评论 0原文

我正在使用 ChartWrapper在我的 Google Chart 中,我需要在 wrap.setOptions 中使用动态值。

我当前的解决方案是这样的:

// This works
wrap.setOptions({'width':'300','height':'300','min': '2000'});

//This is NOT working. 'Min' value is ignored
var minimum = get_minimum_value();
wrap.setOptions({'width':'300','height':'300','min': minimum });

wrap.draw(data); <--- This is triggered after I set the options

如何在wrap.setOptions中添加动态值?

I'm using ChartWrapper in my Google Chart and I need to use dynamic values in the wrap.setOptions.

My current solution is like this:

// This works
wrap.setOptions({'width':'300','height':'300','min': '2000'});

//This is NOT working. 'Min' value is ignored
var minimum = get_minimum_value();
wrap.setOptions({'width':'300','height':'300','min': minimum });

wrap.draw(data); <--- This is triggered after I set the options

How can I add dynamic values in the wrap.setOptions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

榕城若虚 2024-12-08 07:54:35

来自文档:

绘制(opt_container_ref)

绘制图表。您必须在进行任何更改之后调用此方法
您对图表或数据进行更改以显示更改。

opt_container_ref [可选] - 对有效容器的引用

页面上的

元素。如果指定,图表将绘制在那里。如果
不,图表将在 ID 指定的元素中绘制
容器ID。

仅更改选项是不够的。您需要重新绘制图形

希望这有帮助

from the doc:

draw(opt_container_ref)

Draws the chart. You must call this method after any changes that
you make to the chart or data to show the changes.

opt_container_ref [Optional] - A reference to a valid container

element on the page. If specified, the chart will be drawn there. If
not, the chart will be drawn in the element with ID specified by
containerId.

just changing the options won't be enough. You'll need to redraw the graphic

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文