0

I am just playing with GWT charts but I am not quite understanding how it works.

I want to draw a simple column chart with Book Names on x-axis and Number of Books on y-axis. Here is the code.

DataTable table = DataTable.create();
ColumnChart columnChart;

table.addColumn(ColumnType.NUMBER, "Book 1");
table.addColumn(ColumnType.NUMBER, "Book 2");
table.addColumn(ColumnType.NUMBER, "Book 3");

table.addRows(3);
table.setValue(0, 0, 23);   
table.setValue(1, 0, 65);
table.setValue(2, 0, 23);

columnChart.draw(table, options);
add(columnChart);

This isn't working and the screen comes blank. I've set the chart size and everything in the optionsvariable. Am I missing something?

CobaltBabyBear
  • 2,188
  • 6
  • 26
  • 47
  • may be you have to set row names too, have you checked example here https://code.google.com/p/gwt-charts/wiki/GettingStarted, called draw after adding widget to the panel – JAVAC Oct 15 '15 at 14:48

1 Answers1

1

Make sure you have loaded the ChartLoader API first.

ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART);
chartLoader.loadApi(new Runnable() {
    // draw your charts in here
}
Baz
  • 36,440
  • 11
  • 68
  • 94
Fabian
  • 403
  • 3
  • 13