开发者

How to reverse y axis in an AreaChart

I am using Google Chart Tools (aka Visualization) 1.1 Library with GWT to display an AreaChart and I would like to know how to reverse the y axis? There is

setReverseAxis(boolean)
when you set the Options but this one reverse the x axis. I don't find ho开发者_Go百科w to set the y axis.

Thank you for your help.


The current version of Google Visualization API that is used in GWT Visualization 1.1.1 doesn't support all available functionalities. Until Google release a new version of its API for GWT, I think a possible workaround is to extend AreaChart.Options class by adding a new native method like this one (I didn't try but it should work, if the version loaded by viz api 1.1.1 support already this option) :

/**
 * Change the vertical alignment.
 * @param align possible values : -1 or 1
 */
public native final void setVerticalAlignment(int align) /*-{
    this.vAxis.direction = align;
}-*/;

EDIT: After digging a little bit with the api, I found that corechart.Options has a method to specify axis properties:

Options options = AreaChart.createOptions();
AxisOptions verticalOptions = AxisOptions.create();
verticalOptions.setDirection(-1);
options.setVAxisOptions(verticalOptions);
...
... 
AreaChart area = new AreaChart(data, options);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜