I don't understand how this code compiles. you define tempColumnChart inside the run() method of onLoadCallback, and then you refer to it later, outside of that lexical scope. the Java compiler should complain of an undefined variable.
On Thu, Mar 4, 2010 at 11:12 PM, Anky <[email protected]> wrote: > Hi, > > Is there any way to fetch server side data and render it to the > charting components in a GWT-VIZ API enabled app? I tried something > unsure from my side but it did not worked for me. > Scenario: Display some server data on a column chart. > This is what I tried : > <code> > public class ChartPOC implements EntryPoint{ > > public ArrayList<PaymentObject> plciObj = new > ArrayList<PaymentObject>(); > public ColumnChart columnChart ; > public DataTable data ; > > public void onModuleLoad() { > Runnable onLoadCallback = new Runnable() { > public void run() { // this is my debug point > > ColumnChart.Options options = > ColumnChart.Options.create(); > ColumnChart tempColumnChart = new > ColumnChart(createColTable(), > createColumnOptions(options)); // this creates a column chart > columnChart = tempColumnChart;// set it to > the class level chart > // Set up the callback object. > } > }; > // Load the visualization api, passing the onLoadCallback to > be > called > // when loading is done. > VisualizationUtils.loadVisualizationApi(onLoadCallback, > ColumnChart.PACKAGE); > RootPanel rp = RootPanel.get("sampleCharting"); > //rp.add(new HTML("hello")); > rp.add(tempColumnChart); > > > } > > private ColumnChart.Options createColumnOptions(ColumnChart.Options > options) { > //ColumnChart.Options options = > ColumnChart.Options.create(); > options.setWidth(600); > options.setHeight(400); > options.setColors("#F778A1", "#D16587"); > options.setTitle("Earning Analysis"); > options.setLegend(LegendPosition.BOTTOM); > options.setShowCategories(true); > options.setTitleX("PLCI"); > options.setTitleY("Amount"); > options.setTitle("COLUMN CHART WIDGET"); > return options; > } > > private AbstractDataTable createColTable() { > PLCIServiceAsync service = GWT.create(PLCIService.class);// > This is > an Async interface > data = DataTable.create(); > data.addColumn(ColumnType.STRING, "PLCI"); > data.addColumn(ColumnType.NUMBER, "Payment"); > // data.addColumn(ColumnType.NUMBER, "PLCI"); > data.addRows(3); > > AsyncCallback<ArrayList<PaymentPLCIObject>> callback = new > AsyncCallback<ArrayList<PaymentPLCIObject>>() {// implement > AsyncCallback methods > public void onFailure(Throwable caught) { > // TODO: Do something with errors. > } > > public void onSuccess(ArrayList<PaymentPLCIObject> > result) { > updateTable(result);// update the DataTable with > server > response > } > }; > service.getPLCIs(callback);// call the server side > service > class's method > return data; > } > > private void updateTable(ArrayList<PaymentPLCIObject> result){ > for(int index=0; index<result.size(); index++){ > PaymentPLCIObject obj = > (PaymentPLCIObject)result.get(index); > data.setValue(index, 0,obj.getPlciCode()); > data.setValue(index, 1, obj.getPayment()); > columnChart.draw(data); > } > } > } > > </code> > > > when I try to debug the app, the app fails when reaches "public void > run() {". > Any help would be appreciated > > Thanks > Ankit > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To post to this group, send email to > [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-visualization-api%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
