GWT Linechart options

给你一囗甜甜゛ 提交于 2020-01-11 10:14:13

问题


I need to set different line width to different series in a chart. This can be done using the series option here http://code.google.com/intl/sv-SE/apis/chart/interactive/docs/gallery/linechart.html#Configuration_Options . However this option is not available in GWT which leads to my question.

I could:

  1. Write a wrapper for GWT. http://code.google.com/p/gwt-google-apis/wiki/VisualizationNewWrapper
  2. Use the Options.set(...) method. http://gwt-google-apis.googlecode.com/svn/javadoc/visualization/1.1/com/google/gwt/ajaxloader/client/Properties.html#set%28java.lang.String,%20com.google.gwt.core.client.JavaScriptObject%29

The problem for both those alternatives is that I don't know how to do either when the series option takes an object:

series: [{color: 'black', visibleInLegend: false},{}, {}, {color: 'red', visibleInLegend: false}]
series: {0:{color: 'black', visibleInLegend: false}, 3:{color: 'red', visibleInLegend: false}}

How do I do this?


回答1:


Method 2 is easier:

You can use Options.set() and pass another Options instance.

At least for the second option type. series: {0:{color: 'black', visibleInLegend: false}, 3:{color: 'red', visibleInLegend: false}} you can use following code:

Options options = Options.create();
options.setTitle(title);
Options series_options = Options.create();
series1_options = Options.create();
series1_options.set("color","black");
series_options.set("0",series1_options);
options.set("series",series_options);


来源:https://stackoverflow.com/questions/9020465/gwt-linechart-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!