Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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


 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!