这段代码(如下)可以毫无意外地在屏幕上显示 1..n LineCharts。我想知道它的效率如何。我VisualizationsUtils.loadVisualizationApi(onLoadCallback, LineChart.PACKAGE)
每次都在打电话。必须以这种方式完成吗?
public void getData(List<GraphWrapper> graphWrapperList) {
for (GraphWrapper graphWrapper : graphWrapperList) {
populateResources.populateResourcesService(graphWrapper.getSeriesWrapperList(),
new AsyncCallback<GraphWrapper>() {
public void onFailure(Throwable caught) {
displayDialogBox("*** An Error Occurred ***", caught.toString());
}
public void onSuccess(final GraphWrapper response) {
Runnable onLoadCallback = new Runnable() {
private Widget chart;
public void run() {
this.chart = new LineChart(createTable(response), createOptions(response));
graphPanel.add(this.chart);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback, LineChart.PACKAGE);
}
});
}
}