在GWT中设置谷歌可视化组合图表中的最大值
我正在使用 google 可视化在 GWT 应用程序中创建组合图表,并且我想手动设置垂直轴的最大值。我发现帖子告诉我如何在 javascript 中执行此操作,例如 在 Google Charts API 中设置硬性最小轴值,这些表示我需要设置 viewWindow。然而我无法弄清楚如何在 Java 中做到这一点。我目前有此方法来获取图表选项:
private static Options createOptionsChart() {
Options options = Options.create();
options.setWidth(800);
options.setHeight(600);
if (max > 0) {
options.setVAxisOptions(getAxisOptions());
}
options.set("isStacked", true);
options.set("legend", "none");
return options;
}
以及此方法来获取轴选项:
private static AxisOptions getAxisOptions() {
AxisOptions ao = AxisOptions.create();
ao.set("viewWindowMode", "explicit");
ao.set("viewWindow.max", max);
return ao;
}
运行此方法,但是我在浏览器中收到运行时错误消息
选项“viewWindowMode”已设置为“explicit”,但未指定“viewWindow”
我似乎找不到指定 viewWindow 的方法 - 我尝试将其设置为一个新的 JavaScriptObject,一个扩展 JavaScriptObject 的对象...
如果有人有任何建议我将不胜感激。
I'm using google visualisations to create a combo chart in a GWT application, and I would like to set the maximum value of the vertical axis manually. I have found posts that tell me how to do this in javascript, for example Setting a hard minimum axis value in Google Charts API, and these say I need to set the viewWindow. I cannot however work out how to do this in Java. I currently have this method to get the chart options:
private static Options createOptionsChart() {
Options options = Options.create();
options.setWidth(800);
options.setHeight(600);
if (max > 0) {
options.setVAxisOptions(getAxisOptions());
}
options.set("isStacked", true);
options.set("legend", "none");
return options;
}
and this method to get the axis options:
private static AxisOptions getAxisOptions() {
AxisOptions ao = AxisOptions.create();
ao.set("viewWindowMode", "explicit");
ao.set("viewWindow.max", max);
return ao;
}
Running this however I get a runtime error message in my browser of
Option "viewWindowMode" was set to "explicit" but "viewWindow" was not specified
I cannot seem to find a way to specify the viewWindow - I have tried setting it to a new JavaScriptObject, a object that extends JavaScriptObject...
If anyone has any suggestions I would be most grateful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该有效:
This should work: