GWT线图选项 [英] GWT Linechart options

查看:86
本文介绍了GWT线图选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在图表中为不同的系列设置不同的线宽。这可以使用系列选项在这里 http://code.google.com/intl/sv-SE/apis/chart/interactive/docs/gallery/linechart.html#Configuration_Options 。但是这个选项在GWT中不可用,这导致了我的问题。



我可以:


  1. 为GWT编写一个包装器。 http://code.google.com/p/gwt-google-apis / wiki / VisualizationNewWrapper

  2. 使用Options.set(...)方法。 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

这两个替代方案的问题在于,当系列选项需要一个对象时,我不知道该怎么做:

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

如何做到这一点?

解决方案

方法2更简单:

<您可以使用 Options.set()并传递另一个 Options 实例。



至少为第二个选项类型。
系列:{0:{color:'black',visibleInLegend:false},3:{color:'red',visibleInLegend:false}} 使用以下代码:

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


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?

解决方案

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);

这篇关于GWT线图选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆