136 lines
3.8 KiB
Java
136 lines
3.8 KiB
Java
package org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.logging.Logger;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.client.application.mainarea.report.chartjs.Chart;
|
|
import org.gcube.portlets.user.accountingdashboard.client.resources.AppResources;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.RecordData;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportData;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.ReportElementData;
|
|
import org.gcube.portlets.user.accountingdashboard.shared.data.SeriesData;
|
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
import com.gwtplatform.mvp.client.ViewWithUiHandlers;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*/
|
|
public class ReportAreaView extends ViewWithUiHandlers<ReportAreaPresenter>
|
|
implements ReportAreaPresenter.ReportAreaView {
|
|
|
|
private static Logger logger = java.util.logging.Logger.getLogger("");
|
|
|
|
interface Binder extends UiBinder<Widget, ReportAreaView> {
|
|
}
|
|
|
|
@UiField
|
|
HTMLPanel reportPanel;
|
|
|
|
private AppResources resources;
|
|
|
|
@Inject
|
|
ReportAreaView(Binder uiBinder, AppResources resources) {
|
|
this.resources = resources;
|
|
init();
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
//
|
|
RecordData recordData1 = new RecordData();
|
|
recordData1.setX("Gennaio");
|
|
recordData1.setY(3d);
|
|
|
|
RecordData recordData2 = new RecordData();
|
|
recordData2.setX("Febbraio");
|
|
recordData2.setY(2d);
|
|
|
|
RecordData[] dataRow1 = new RecordData[2];
|
|
dataRow1[0] = recordData1;
|
|
dataRow1[1] = recordData2;
|
|
|
|
RecordData recordData3 = new RecordData();
|
|
recordData3.setX("Gennaio");
|
|
recordData3.setY(1d);
|
|
|
|
RecordData recordData4 = new RecordData();
|
|
recordData4.setX("Febbraio");
|
|
recordData4.setY(5d);
|
|
|
|
RecordData[] dataRow2 = new RecordData[2];
|
|
dataRow2[0] = recordData3;
|
|
dataRow2[1] = recordData4;
|
|
|
|
SeriesData seriesData1 = new SeriesData();
|
|
seriesData1.setLabel("Series1");
|
|
seriesData1.setDataRow(dataRow1);
|
|
|
|
SeriesData seriesData2 = new SeriesData();
|
|
seriesData2.setLabel("Series2");
|
|
seriesData2.setDataRow(dataRow2);
|
|
|
|
SeriesData[] serieses = new SeriesData[2];
|
|
serieses[0] = seriesData1;
|
|
serieses[1] = seriesData2;
|
|
|
|
ReportData rData = new ReportData();
|
|
ArrayList<ReportElementData> elements = new ArrayList<>();
|
|
|
|
ReportElementData reportElementData1 = new ReportElementData();
|
|
reportElementData1.setxAxis("XAxis");
|
|
reportElementData1.setyAxis("YAxis");
|
|
reportElementData1.setCategory("Category");
|
|
reportElementData1.setLabel("Label1");
|
|
reportElementData1.setSerieses(serieses);
|
|
elements.add(reportElementData1);
|
|
|
|
ReportElementData reportElementData2 = new ReportElementData();
|
|
reportElementData2.setxAxis("XAxis");
|
|
reportElementData2.setyAxis("YAxis");
|
|
reportElementData2.setCategory("Category");
|
|
reportElementData2.setLabel("Label2");
|
|
reportElementData2.setSerieses(serieses);
|
|
elements.add(reportElementData2);
|
|
|
|
rData.setElements(elements);
|
|
|
|
displayReportData(rData);
|
|
}
|
|
|
|
private void init() {
|
|
|
|
}
|
|
|
|
/**
|
|
* LABEL | | _ yaxis | _ | | | | || |_ | | || | |
|
|
* ---------------------------------------------------
|
|
*
|
|
*
|
|
* *Series_label1 *Series_label2 *Series_label3
|
|
*
|
|
* xAxis
|
|
*
|
|
*/
|
|
|
|
@Override
|
|
public void displayReportData(ReportData reportData) {
|
|
if (reportData == null) {
|
|
reportPanel.clear();
|
|
} else {
|
|
reportPanel.clear();
|
|
for (int i = 0; i < reportData.getElements().size(); i++) {
|
|
Chart chart = new Chart(resources, "report_" + i, reportData.getElements().get(i));
|
|
reportPanel.add(chart);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|