2

I am using the 1.1.1 release of gwt-visualization. Here is what I got so far:

final DataTable dataTable;
// creation of the data table left out ..

final Options options = Options.create();

final HorizontalAxisOptions horizontalAxisOptions = HorizontalAxisOptions.create();
horizontalAxisOptions.setShowTextEvery(1);

// ... ?

options.setHAxisOptions(horizontalAxisOptions);

LineChart lineChart = new LineChart(dataTable, options);
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
  • 1
    Your question is quite unclear as to what you mean by "change grid size". You may be better off showing your current results, and what you actually want, then perhaps people can help. – jmac Apr 23 '13 at 01:17
  • @jmac: By grid size I mean the grid resolution or step width. It should be adjustable for both axis. I only found a method for changing the grid color (`Options.setGridlineColor()`). Is there a generic way to use the javascript API via Java to define further options? – Jens Piegsa Apr 24 '13 at 10:16
  • I tried stuff like `options.set("hAxis.gridlines.count", "42");`, but that hasn't any effect. – Jens Piegsa Apr 24 '13 at 10:36

2 Answers2

2

The Options.set(key, value)-method(s) generally does the job. However, instead of using the dot notation, one must create nested Options objects (or create wrapper classes like HorizontalAxisOptions).

But: There's an issue for date values.

A workaround for this might be the usage of minorGridlines. I suspect that I'll end up in an ugly date calculation. :-(

Other suggestions?

Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
2

You need to use the set method but nest options. For example

    Options options = Options.create()  //Main option
    Options Haxis = Options.create();
    Options Hgrid = Options.create();
    Hgrid.set("count", 12d);
    Haxis.set("gridlines", Hgrid);
    options.set("hAxis", Haxis);

    Options series_options = Options.create();
    Options series1_options = Options.create();
    series1_options.set("color","#CE5C0A");
    Options series2_options = Options.create();
    series2_options.set("color","blue");
    Options series3_options = Options.create();
    series3_options.set("color","#6600CC");
    Options series4_options = Options.create();
    series4_options.set("color","#00FF00");
    series_options.set("0",series1_options);
    series_options.set("1",series2_options);
    series_options.set("2",series3_options);
    series_options.set("3",series4_options);
    options.set("series",series_options);

The first block I nested options to set the hAxis.gridlines.count parameter to 12.

The second block I nested a lot of options to set the color of the series.

Michael
  • 1,321
  • 1
  • 13
  • 27