PDA

View Full Version : Visualizations & GWT 2.1.0 and GXT 2.2.1



ssozonoff
8 Jan 2011, 1:44 PM
Hello All,

I am evaluating GXT and trying to add a chart to a TabItem using GWT Visualizations and not having much luck here. I simply get a an empty TabItem.

calling a <tabItem>.addText() before calling <tabItem>.add(new LineChart(data, options)); and the chart gets displayed!

Anyone have this working ?
I have attached a code example below....

thanks,
Serge



public class ExtGwt implements EntryPoint {
public void onModuleLoad() {

TabPanel folder = new TabPanel();
folder.setWidth("100%");
folder.setAutoHeight(true);

final TabItem dash = new TabItem("Dashboard");
dash.addStyleName("pad-text");
dash.setLayout(new FitLayout());
folder.add(dash);

RootPanel.get().add(folder);

VisualizationUtils.loadVisualizationApi(new Runnable() {
public void run() {
Query query =
Query.create("http://localhost:8080/do/ds");
query.send(new Query.Callback() {

public void onResponse(QueryResponse response) {
if (response.isError()) {
Window.alert("An error occured: " + response.getDetailedMessage());
}

DataTable data = response.getDataTable();
LineChart.Options options = LineChart.Options.create();
options.setHeight(500);
options.setWidth(500);

dash.add(new LineChart(data, options));
dash.layout(true);
}
});
}
}, LineChart.PACKAGE);
}
}

ssozonoff
9 Jan 2011, 9:23 AM
I would like to point out that this exact same test case took under 15 minutes to implement in SmartGWT. I have spent well over this trying to get it to work so far. The fact that adding a dash.addText("") call, before adding the chart, makes the chart at least display seems like there could be some sort of bug or incompatibility.

sven
9 Jan 2011, 9:40 AM
I have not tested it but there is an issue in your code. AutoHeight cannot work with a fitlayout by definition.

public class ExtGwt implements EntryPoint {
public void onModuleLoad() {

TabPanel folder = new TabPanel();


final TabItem dash = new TabItem("Dashboard");
dash.addStyleName("pad-text");
dash.setLayout(new FitLayout());
folder.add(dash);

Viewport v = new Viewport();
v.setLayout(new FitLayout());
v.add(folder);

RootPanel.get().add(v);

VisualizationUtils.loadVisualizationApi(new Runnable() {
public void run() {
Query query =
Query.create("http://localhost:8080/do/ds");
query.send(new Query.Callback() {

public void onResponse(QueryResponse response) {
if (response.isError()) {
Window.alert("An error occured: " + response.getDetailedMessage());
}

DataTable data = response.getDataTable();
LineChart.Options options = LineChart.Options.create();
options.setHeight(500);
options.setWidth(500);

dash.add(new LineChart(data, options));
dash.layout();
}
});
}
}, LineChart.PACKAGE);
}
}

ssozonoff
9 Jan 2011, 11:02 AM
Thanks Sven,

But this does not seem to make any difference.

Kind regards,
Serge

ssozonoff
9 Jan 2011, 11:33 AM
OK seems to work now.

Thanks Sven!