Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

GWT Viz API application using server data to render charts

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic