PDA

View Full Version : NullPointer in BarDataProvider



fother
18 Jun 2009, 11:19 AM
change the content of the class for



public class AdvancedChartExample extends LayoutContainer {

public class Example extends BaseModel {

public Example(String month, Integer value) {
setMonth(month);
setValue(value);
}

public String getMonth() {
return get("month");
}

public Integer getValue() {
return get("value");
}

public void setMonth(String month) {
set("month", month);
}

public void setValue(Integer value) {
set("value", value);
}

}

@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);

List<Example> examples = new ArrayList<Example>();
examples.add(new Example("Jan", 6));
examples.add(new Example("Fev", null));

final ListStore<Example> store = new ListStore<Example>();
store.add(examples);

// chart
String url = !Examples.isExplorer() ? "../../" : "";
url += "gxt/chart/open-flash-chart.swf";
final Chart chart = new Chart(url);

ChartModel model = new ChartModel("Title");
model.setBackgroundColour("#fefefe");
model.setLegend(new Legend(Position.TOP, true));
model.setScaleProvider(ScaleProvider.ROUNDED_NEAREST_SCALE_PROVIDER);

BarChart bar = new BarChart(BarStyle.GLASS);
bar.setColour("#00aa00");
BarDataProvider barProvider = new BarDataProvider("value", "month");
barProvider.bind(store);
bar.setDataProvider(barProvider);
model.addChartConfig(bar);

chart.setChartModel(model);

LayoutContainer lc = new LayoutContainer();
RowLayout rl = new RowLayout();
lc.setLayout(rl);
lc.setSize(800, 600);

RowData data;
data = new RowData(1, 300, new Margins(10));
ContentPanel cp = new ContentPanel(new FitLayout());
cp.setHeading("Chart");
cp.add(chart);
cp.setCollapsible(true);
lc.add(cp, data);

add(lc);

}
}


stacktrace


java.lang.NullPointerException: null
at com.extjs.gxt.charts.client.model.BarDataProvider.populateData(BarDataProvider.java:52)
at com.extjs.gxt.charts.client.Chart.processModel(Chart.java:234)
at com.extjs.gxt.charts.client.Chart.setChartModel(Chart.java:168)

fother
19 Jun 2009, 5:09 AM
according to sven this "issue" its fixed in SVN...