2016-02-15 14:35:02 +01:00
|
|
|
package org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
2016-06-09 16:26:02 +02:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.event.ExportRequestEvent;
|
2016-02-15 14:35:02 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.ChartTimeMeasure;
|
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.DownloadConstants;
|
2016-02-18 13:08:47 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.JobChartMeasure;
|
2016-02-19 16:21:27 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.maindata.charts.utils.TimeUnitMeasure;
|
2016-02-15 14:35:02 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.resource.AccountingManagerResources;
|
2016-05-31 15:50:31 +02:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.client.state.AccountingClientStateData;
|
2016-02-15 14:35:02 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.SeriesJob;
|
2016-02-18 13:08:47 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobBasic;
|
2016-02-17 16:57:02 +01:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.shared.data.response.job.SeriesJobData;
|
2016-06-09 16:26:02 +02:00
|
|
|
import org.gcube.portlets.admin.accountingmanager.shared.export.ExportType;
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
|
|
import com.github.highcharts4gwt.client.view.widget.HighchartsLayoutPanel;
|
|
|
|
import com.github.highcharts4gwt.model.array.api.ArrayNumber;
|
|
|
|
import com.github.highcharts4gwt.model.array.api.ArrayString;
|
|
|
|
import com.github.highcharts4gwt.model.factory.api.HighchartsOptionFactory;
|
|
|
|
import com.github.highcharts4gwt.model.factory.jso.JsoHighchartsOptionFactory;
|
|
|
|
import com.github.highcharts4gwt.model.highcharts.option.api.ChartOptions;
|
|
|
|
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesArea;
|
|
|
|
import com.github.highcharts4gwt.model.highcharts.option.api.SeriesColumn;
|
|
|
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
2016-05-30 18:51:08 +02:00
|
|
|
import com.google.gwt.event.shared.EventBus;
|
2016-02-15 14:35:02 +01:00
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
|
|
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
|
|
|
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
|
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
|
|
|
import com.sencha.gxt.widget.core.client.button.ToggleButton;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|
|
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
|
|
|
import com.sencha.gxt.widget.core.client.menu.Menu;
|
|
|
|
import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
|
|
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author giancarlo email: <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
*
|
|
|
|
*/
|
2016-02-18 13:08:47 +01:00
|
|
|
public class JobChartBasicPanel extends SimpleContainer {
|
2016-02-19 16:21:27 +01:00
|
|
|
private DateTimeFormat dtf = DateTimeFormat
|
|
|
|
.getFormat(PredefinedFormat.YEAR_MONTH_DAY);
|
|
|
|
private static final String TIME_UNIT = "Time Unit";
|
2016-02-15 14:35:02 +01:00
|
|
|
private static final String SINGLE_AXIS = "Single Axis";
|
2016-02-19 16:21:27 +01:00
|
|
|
|
2016-05-31 15:50:31 +02:00
|
|
|
private AccountingClientStateData accountingStateData;
|
2016-02-15 14:35:02 +01:00
|
|
|
private HighchartsLayoutPanel highchartsLayoutPanel;
|
|
|
|
|
2016-02-19 13:00:05 +01:00
|
|
|
// Download Menu
|
2016-05-30 18:51:08 +02:00
|
|
|
private MenuItem downloadCSVItem;
|
2016-06-09 16:26:02 +02:00
|
|
|
private MenuItem downloadXMLItem;
|
|
|
|
private MenuItem downloadJSONItem;
|
2016-02-15 14:35:02 +01:00
|
|
|
private MenuItem downloadPNGItem;
|
|
|
|
private MenuItem downloadJPGItem;
|
|
|
|
private MenuItem downloadPDFItem;
|
|
|
|
private MenuItem downloadSVGItem;
|
2016-02-19 16:21:27 +01:00
|
|
|
|
|
|
|
// Time Unit Menu
|
|
|
|
private MenuItem msItem;
|
|
|
|
private MenuItem sItem;
|
|
|
|
private MenuItem mItem;
|
|
|
|
private MenuItem hItem;
|
|
|
|
|
2016-02-19 13:00:05 +01:00
|
|
|
private ChartOptions options;
|
2016-02-19 16:21:27 +01:00
|
|
|
private VerticalLayoutContainer vert;
|
|
|
|
|
|
|
|
private long unitMeasure = TimeUnitMeasure.getMilliseconds();
|
|
|
|
private String unitMeasureLabel = TimeUnitMeasure.MS;
|
|
|
|
private TextButton unitButton;
|
|
|
|
private ToggleButton toggleButton;
|
2016-05-30 18:51:08 +02:00
|
|
|
private EventBus eventBus;
|
2016-02-15 14:35:02 +01:00
|
|
|
|
2016-05-31 15:50:31 +02:00
|
|
|
public JobChartBasicPanel(EventBus eventBus,
|
|
|
|
AccountingClientStateData accountingStateData) {
|
|
|
|
this.eventBus = eventBus;
|
2016-02-15 14:35:02 +01:00
|
|
|
this.accountingStateData = accountingStateData;
|
|
|
|
forceLayoutOnResize = true;
|
|
|
|
create();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void create() {
|
|
|
|
ToolBar toolBar = new ToolBar();
|
|
|
|
toolBar.setSpacing(2);
|
|
|
|
// Download
|
2016-02-19 16:21:27 +01:00
|
|
|
final TextButton downloadButton = new TextButton(
|
|
|
|
DownloadConstants.DOWNLOAD,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingDownload24());
|
2016-02-15 14:35:02 +01:00
|
|
|
// downloadButton.setScale(ButtonScale.MEDIUM);
|
|
|
|
downloadButton.setIconAlign(IconAlign.RIGHT);
|
|
|
|
downloadButton.setArrowAlign(ButtonArrowAlign.RIGHT);
|
|
|
|
downloadButton.setMenu(createDownloadMenu());
|
|
|
|
|
2016-02-19 16:21:27 +01:00
|
|
|
unitButton = new TextButton(TIME_UNIT,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingUnitms24());
|
|
|
|
unitButton.setIconAlign(IconAlign.RIGHT);
|
|
|
|
unitButton.setArrowAlign(ButtonArrowAlign.RIGHT);
|
|
|
|
unitButton.setMenu(createUnitMenu());
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
// Single Axis
|
2016-02-19 16:21:27 +01:00
|
|
|
toggleButton = new ToggleButton(SINGLE_AXIS);
|
2016-02-15 14:35:02 +01:00
|
|
|
toggleButton.setIcon(AccountingManagerResources.INSTANCE
|
|
|
|
.accountingChartVariableAxis24());
|
|
|
|
toggleButton.setIconAlign(IconAlign.RIGHT);
|
|
|
|
toggleButton.setValue(false);
|
|
|
|
|
|
|
|
toggleButton.addSelectHandler(new SelectHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelect(SelectEvent event) {
|
2016-02-19 16:21:27 +01:00
|
|
|
updateChart();
|
2016-02-15 14:35:02 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-19 16:21:27 +01:00
|
|
|
toolBar.add(downloadButton, new BoxLayoutData(new Margins(0)));
|
|
|
|
toolBar.add(unitButton, new BoxLayoutData(new Margins(0)));
|
|
|
|
toolBar.add(toggleButton, new BoxLayoutData(new Margins(0)));
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
createMultiAxisChart();
|
2016-02-19 16:21:27 +01:00
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
highchartsLayoutPanel = new HighchartsLayoutPanel();
|
|
|
|
highchartsLayoutPanel.renderChart(options);
|
|
|
|
|
|
|
|
//
|
2016-02-19 16:21:27 +01:00
|
|
|
vert = new VerticalLayoutContainer();
|
2016-02-15 14:35:02 +01:00
|
|
|
vert.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
|
|
|
vert.add(highchartsLayoutPanel, new VerticalLayoutData(1, 1,
|
|
|
|
new Margins(0)));
|
|
|
|
|
|
|
|
add(vert, new MarginData(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-19 16:21:27 +01:00
|
|
|
private void updateChart() {
|
|
|
|
if (toggleButton.getValue()) {
|
|
|
|
createSingleAxisChart();
|
|
|
|
highchartsLayoutPanel.renderChart(options);
|
|
|
|
} else {
|
|
|
|
createMultiAxisChart();
|
|
|
|
highchartsLayoutPanel.renderChart(options);
|
|
|
|
}
|
|
|
|
forceLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
private Menu createUnitMenu() {
|
|
|
|
Menu menuUnit = new Menu();
|
|
|
|
msItem = new MenuItem(TimeUnitMeasure.MILLISECONDS,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingUnitms24());
|
|
|
|
msItem.setHeight(30);
|
|
|
|
sItem = new MenuItem(TimeUnitMeasure.SECONDS,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingUnits24());
|
|
|
|
sItem.setHeight(30);
|
|
|
|
mItem = new MenuItem(TimeUnitMeasure.MINUTES,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingUnitm24());
|
|
|
|
mItem.setHeight(30);
|
|
|
|
hItem = new MenuItem(TimeUnitMeasure.HOURS,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingUnith24());
|
|
|
|
hItem.setHeight(30);
|
|
|
|
|
|
|
|
msItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
unitMeasure = TimeUnitMeasure.getMilliseconds();
|
|
|
|
unitMeasureLabel = TimeUnitMeasure.MS;
|
|
|
|
unitButton.setIcon(AccountingManagerResources.INSTANCE
|
|
|
|
.accountingUnitms24());
|
|
|
|
updateChart();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
sItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
unitMeasure = TimeUnitMeasure.getSeconds();
|
|
|
|
unitMeasureLabel = TimeUnitMeasure.S;
|
|
|
|
unitButton.setIcon(AccountingManagerResources.INSTANCE
|
|
|
|
.accountingUnits24());
|
|
|
|
updateChart();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
unitMeasure = TimeUnitMeasure.getMinutes();
|
|
|
|
unitMeasureLabel = TimeUnitMeasure.M;
|
|
|
|
unitButton.setIcon(AccountingManagerResources.INSTANCE
|
|
|
|
.accountingUnitm24());
|
|
|
|
updateChart();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
hItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
unitMeasure = TimeUnitMeasure.getHours();
|
|
|
|
unitMeasureLabel = TimeUnitMeasure.H;
|
|
|
|
unitButton.setIcon(AccountingManagerResources.INSTANCE
|
|
|
|
.accountingUnith24());
|
|
|
|
updateChart();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
menuUnit.add(msItem);
|
|
|
|
menuUnit.add(sItem);
|
|
|
|
menuUnit.add(mItem);
|
|
|
|
menuUnit.add(hItem);
|
|
|
|
return menuUnit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
private Menu createDownloadMenu() {
|
|
|
|
|
|
|
|
Menu menuDownload = new Menu();
|
2016-05-30 18:51:08 +02:00
|
|
|
downloadCSVItem = new MenuItem(DownloadConstants.DOWNLOAD_CSV,
|
2016-05-31 15:50:31 +02:00
|
|
|
AccountingManagerResources.INSTANCE.accountingFileCSV24());
|
|
|
|
downloadCSVItem.setHeight(30);
|
2016-06-09 16:26:02 +02:00
|
|
|
downloadXMLItem = new MenuItem(DownloadConstants.DOWNLOAD_XML,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingFileXML24());
|
|
|
|
downloadXMLItem.setHeight(30);
|
|
|
|
downloadJSONItem = new MenuItem(DownloadConstants.DOWNLOAD_JSON,
|
|
|
|
AccountingManagerResources.INSTANCE.accountingFileJSON24());
|
|
|
|
downloadJSONItem.setHeight(30);
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadPNGItem = new MenuItem(DownloadConstants.DOWNLOAD_PNG,
|
2016-02-19 16:21:27 +01:00
|
|
|
AccountingManagerResources.INSTANCE.accountingFilePNG24());
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadPNGItem.setHeight(30);
|
|
|
|
downloadJPGItem = new MenuItem(DownloadConstants.DOWNLOAD_JPG,
|
2016-02-19 16:21:27 +01:00
|
|
|
AccountingManagerResources.INSTANCE.accountingFileJPG24());
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadJPGItem.setHeight(30);
|
|
|
|
downloadPDFItem = new MenuItem(DownloadConstants.DOWNLOAD_PDF,
|
2016-02-19 16:21:27 +01:00
|
|
|
AccountingManagerResources.INSTANCE.accountingFilePDF24());
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadPDFItem.setHeight(30);
|
|
|
|
downloadSVGItem = new MenuItem(DownloadConstants.DOWNLOAD_SVG,
|
2016-02-19 16:21:27 +01:00
|
|
|
AccountingManagerResources.INSTANCE.accountingFileSVG24());
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadSVGItem.setHeight(30);
|
|
|
|
|
2016-05-30 18:51:08 +02:00
|
|
|
downloadCSVItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
onDownloadCSV();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2016-06-09 16:26:02 +02:00
|
|
|
|
|
|
|
downloadXMLItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
onDownloadXML();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
downloadJSONItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
onDownloadJSON();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-05-30 18:51:08 +02:00
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
downloadPNGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
String id = highchartsLayoutPanel.getElement().getId();
|
|
|
|
onDownloadPNG(id);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
downloadJPGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
String id = highchartsLayoutPanel.getElement().getId();
|
|
|
|
onDownloadJPG(id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
downloadPDFItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
String id = highchartsLayoutPanel.getElement().getId();
|
|
|
|
onDownloadPDF(id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
downloadSVGItem.addSelectionHandler(new SelectionHandler<Item>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelection(SelectionEvent<Item> event) {
|
|
|
|
String id = highchartsLayoutPanel.getElement().getId();
|
|
|
|
onDownloadSVG(id);
|
|
|
|
}
|
|
|
|
});
|
2016-05-31 15:50:31 +02:00
|
|
|
|
2016-05-30 18:51:08 +02:00
|
|
|
menuDownload.add(downloadCSVItem);
|
2016-06-09 16:26:02 +02:00
|
|
|
menuDownload.add(downloadXMLItem);
|
|
|
|
menuDownload.add(downloadJSONItem);
|
2016-02-15 14:35:02 +01:00
|
|
|
menuDownload.add(downloadPNGItem);
|
|
|
|
menuDownload.add(downloadJPGItem);
|
|
|
|
menuDownload.add(downloadPDFItem);
|
|
|
|
menuDownload.add(downloadSVGItem);
|
|
|
|
return menuDownload;
|
|
|
|
|
|
|
|
}
|
2016-05-30 18:51:08 +02:00
|
|
|
|
|
|
|
private void onDownloadCSV() {
|
2016-06-09 16:26:02 +02:00
|
|
|
ExportRequestEvent event = new ExportRequestEvent(
|
|
|
|
ExportType.CSV, accountingStateData.getAccountingType());
|
|
|
|
eventBus.fireEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onDownloadXML() {
|
|
|
|
ExportRequestEvent event = new ExportRequestEvent(
|
|
|
|
ExportType.XML, accountingStateData.getAccountingType());
|
|
|
|
eventBus.fireEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onDownloadJSON() {
|
|
|
|
ExportRequestEvent event = new ExportRequestEvent(
|
|
|
|
ExportType.JSON, accountingStateData.getAccountingType());
|
2016-05-30 18:51:08 +02:00
|
|
|
eventBus.fireEvent(event);
|
|
|
|
}
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
// chart.options.exporting.buttons.contextButton.menuItems[0].onclick();
|
|
|
|
|
|
|
|
public static native void onDownloadPNG(String id) /*-{
|
|
|
|
console.log(id);
|
|
|
|
var chart = $wnd
|
|
|
|
.jQuery('#' + id)
|
|
|
|
.highcharts(
|
2016-02-18 13:08:47 +01:00
|
|
|
this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel::options);
|
2016-02-15 14:35:02 +01:00
|
|
|
console.log(chart);
|
|
|
|
chart.exportChart();
|
|
|
|
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
public static native void onDownloadJPG(String id) /*-{
|
|
|
|
console.log(id);
|
|
|
|
var chart = $wnd
|
|
|
|
.jQuery('#' + id)
|
|
|
|
.highcharts(
|
2016-02-18 13:08:47 +01:00
|
|
|
this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel::options);
|
2016-02-15 14:35:02 +01:00
|
|
|
console.log(chart);
|
|
|
|
chart.exportChart({
|
|
|
|
type : 'image/jpeg'
|
|
|
|
});
|
|
|
|
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
public static native void onDownloadPDF(String id) /*-{
|
|
|
|
console.log(id);
|
|
|
|
var chart = $wnd
|
|
|
|
.jQuery('#' + id)
|
|
|
|
.highcharts(
|
2016-02-18 13:08:47 +01:00
|
|
|
this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel::options);
|
2016-02-15 14:35:02 +01:00
|
|
|
console.log(chart);
|
|
|
|
chart.exportChart({
|
|
|
|
type : 'application/pdf'
|
|
|
|
});
|
|
|
|
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
public static native void onDownloadSVG(String id) /*-{
|
|
|
|
console.log(id);
|
|
|
|
var chart = $wnd
|
|
|
|
.jQuery('#' + id)
|
|
|
|
.highcharts(
|
2016-02-18 13:08:47 +01:00
|
|
|
this.@org.gcube.portlets.admin.accountingmanager.client.maindata.charts.job.JobChartBasicPanel::options);
|
2016-02-15 14:35:02 +01:00
|
|
|
console.log(chart);
|
|
|
|
chart.exportChart({
|
|
|
|
type : 'image/svg+xml'
|
|
|
|
});
|
|
|
|
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
private void createMultiAxisChart() {
|
|
|
|
SeriesJob seriesJob = (SeriesJob) accountingStateData
|
|
|
|
.getSeriesResponse();
|
2016-02-19 16:21:27 +01:00
|
|
|
|
|
|
|
if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobBasic)) {
|
|
|
|
Log.error("Invalid SeriesJobBasic!");
|
2016-02-18 13:08:47 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-02-19 16:21:27 +01:00
|
|
|
SeriesJobBasic seriesJobBasic = (SeriesJobBasic) seriesJob
|
|
|
|
.getSeriesJobDefinition();
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
double minRange = ChartTimeMeasure
|
|
|
|
.calculateMinRange(accountingStateData.getSeriesRequest()
|
|
|
|
.getAccountingPeriod());
|
|
|
|
|
|
|
|
double interval = ChartTimeMeasure
|
|
|
|
.calculateInterval(accountingStateData.getSeriesRequest()
|
|
|
|
.getAccountingPeriod());
|
2016-02-19 16:21:27 +01:00
|
|
|
|
|
|
|
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
|
2016-02-15 14:35:02 +01:00
|
|
|
.getAccountingPeriod().getStartDate());
|
2016-02-19 16:21:27 +01:00
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
dateStart.setTime(dateStart.getTime()
|
|
|
|
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
|
|
|
|
|
|
|
Log.debug("BuildChart DateStart: "
|
|
|
|
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
|
|
|
|
.format(dateStart));
|
|
|
|
|
|
|
|
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
|
|
|
options = highchartsFactory.createChartOptions();
|
2016-02-19 16:21:27 +01:00
|
|
|
options.chart().zoomType("xy");
|
2016-02-15 14:35:02 +01:00
|
|
|
options.navigation().buttonOptions().enabled(false);
|
2016-02-18 13:08:47 +01:00
|
|
|
options.exporting().filename("AccountingJobBasic");
|
2016-02-15 14:35:02 +01:00
|
|
|
options.title().text("Accounting Job");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* options.subtitle().text("Click and drag in the plot area to zoom in");
|
|
|
|
*/
|
|
|
|
|
|
|
|
ArrayString colors = options.colors();
|
|
|
|
// colors.setValue(0, "#cc0038");
|
|
|
|
// colors.setValue(1, "#32cd32");
|
|
|
|
|
|
|
|
// xAxis
|
|
|
|
options.xAxis().type("datetime").minRange(minRange);
|
|
|
|
|
|
|
|
// yAxis
|
2016-02-19 16:21:27 +01:00
|
|
|
String multiAxis = "[{" + " \"id\": \""
|
|
|
|
+ JobChartMeasure.OperationCount.name() + "\","
|
2016-02-15 14:35:02 +01:00
|
|
|
+ " \"labels\": { " + " \"format\": \"{value}\","
|
2016-02-19 16:21:27 +01:00
|
|
|
+ " \"style\": { " + " \"color\": \"" + colors.get(1)
|
|
|
|
+ "\"" + " }" + " }," + " \"title\": { "
|
|
|
|
+ " \"text\": \""
|
|
|
|
+ JobChartMeasure.OperationCount.getLabel() + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(1)
|
|
|
|
+ "\"" + " }" + " }" + "} , {" + " \"id\": \""
|
2016-05-31 15:50:31 +02:00
|
|
|
+ JobChartMeasure.Duration.name() + "\", " + " \"title\": {"
|
|
|
|
+ " \"text\": \"" + JobChartMeasure.Duration.getLabel()
|
|
|
|
+ "\"," + " \"style\": {" + " \"color\": \""
|
|
|
|
+ colors.get(0) + "\"" + " }" + " }," + " \"labels\": {"
|
2016-02-19 16:21:27 +01:00
|
|
|
+ " \"format\": \"{value} " + unitMeasureLabel + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(0)
|
|
|
|
+ "\"" + " }" + " }," + " \"opposite\": \"true\""
|
|
|
|
+ ", \"showFirstLabel\": \"false\"" + "} , {" + " \"id\": \""
|
|
|
|
+ JobChartMeasure.MaxInvocationTime.name() + "\", "
|
|
|
|
+ " \"title\": {" + " \"text\": \""
|
|
|
|
+ JobChartMeasure.MaxInvocationTime.getLabel() + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(2)
|
|
|
|
+ "\"" + " }" + " }," + " \"labels\": {"
|
|
|
|
+ " \"format\": \"{value} " + unitMeasureLabel + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(2)
|
|
|
|
+ "\"" + " }" + " }," + " \"opposite\": \"true\""
|
|
|
|
+ ", \"showFirstLabel\": \"false\"" + "} , {" + " \"id\": \""
|
|
|
|
+ JobChartMeasure.MinInvocationTime.name() + "\", "
|
|
|
|
+ " \"title\": {" + " \"text\": \""
|
|
|
|
+ JobChartMeasure.MinInvocationTime.getLabel() + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(3)
|
|
|
|
+ "\"" + " }" + " }," + " \"labels\": {"
|
|
|
|
+ " \"format\": \"{value} " + unitMeasureLabel + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(3)
|
|
|
|
+ "\"" + " }" + " }," + " \"opposite\": \"true\""
|
2016-02-15 14:35:02 +01:00
|
|
|
+ ", \"showFirstLabel\": \"false\"" + "}]"
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
options.setFieldAsJsonObject("yAxis", multiAxis);
|
|
|
|
|
|
|
|
// does not seem to be working
|
|
|
|
String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0,"
|
|
|
|
+ "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "},"
|
|
|
|
+ "\"stops\": [" + "[" + "0, \"#058DC7\"" + "]," + "["
|
|
|
|
+ "1, \"#FFFFFF\"" + "]" + "]" + "}";
|
|
|
|
|
|
|
|
options.plotOptions().area()
|
|
|
|
.setFieldAsJsonObject("fillColor", fillcolor).marker()
|
|
|
|
.radius(2).lineWidth(1).states().hover().lineWidth(1);
|
|
|
|
|
|
|
|
SeriesColumn seriesOperationCount = highchartsFactory
|
|
|
|
.createSeriesColumn();
|
2016-05-31 15:50:31 +02:00
|
|
|
seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesOperationCount.color(colors.get(1));
|
|
|
|
seriesOperationCount.type("column");
|
|
|
|
|
|
|
|
ArrayNumber dataOperationCount = seriesOperationCount
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesOperationCount.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
|
2016-02-18 13:08:47 +01:00
|
|
|
seriesDuration.name(JobChartMeasure.Duration.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesDuration.color(colors.get(0));
|
2016-02-18 13:08:47 +01:00
|
|
|
seriesDuration.yAxisAsString(JobChartMeasure.Duration.name());
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesDuration.pointInterval(interval).pointStart(dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesMaxInvocationTime = highchartsFactory
|
|
|
|
.createSeriesArea();
|
2016-02-19 16:21:27 +01:00
|
|
|
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
|
|
|
|
.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesMaxInvocationTime.color(colors.get(2));
|
2016-05-31 15:50:31 +02:00
|
|
|
seriesMaxInvocationTime.yAxisAsString(JobChartMeasure.MaxInvocationTime
|
|
|
|
.name());
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesMaxInvocationTime.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesMinInvocationTime = highchartsFactory
|
|
|
|
.createSeriesArea();
|
2016-02-19 16:21:27 +01:00
|
|
|
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
|
|
|
|
.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesMinInvocationTime.color(colors.get(3));
|
2016-05-31 15:50:31 +02:00
|
|
|
seriesMinInvocationTime.yAxisAsString(JobChartMeasure.MinInvocationTime
|
|
|
|
.name());
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesMinInvocationTime.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
2016-05-31 15:50:31 +02:00
|
|
|
for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
|
2016-02-19 16:21:27 +01:00
|
|
|
dataOperationCount.push(seriesJobData.getOperationCount());
|
|
|
|
dataDuration.push(seriesJobData.getDuration() / unitMeasure);
|
|
|
|
dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime()
|
|
|
|
/ unitMeasure);
|
|
|
|
dataMinInvocationTime.push(seriesJobData.getMinInvocationTime()
|
|
|
|
/ unitMeasure);
|
2016-02-15 14:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
options.series().addToEnd(seriesOperationCount);
|
|
|
|
options.series().addToEnd(seriesDuration);
|
|
|
|
options.series().addToEnd(seriesMaxInvocationTime);
|
|
|
|
options.series().addToEnd(seriesMinInvocationTime);
|
|
|
|
|
|
|
|
options.chart().showAxes(true);
|
|
|
|
|
|
|
|
options.legend().enabled(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createSingleAxisChart() {
|
2016-02-18 13:08:47 +01:00
|
|
|
SeriesJob seriesJob = (SeriesJob) accountingStateData
|
2016-02-15 14:35:02 +01:00
|
|
|
.getSeriesResponse();
|
2016-02-19 16:21:27 +01:00
|
|
|
|
|
|
|
if (!(seriesJob.getSeriesJobDefinition() instanceof SeriesJobBasic)) {
|
|
|
|
Log.debug("Invalid SeriesJobBasic!");
|
2016-02-18 13:08:47 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-02-19 16:21:27 +01:00
|
|
|
SeriesJobBasic seriesJobBasic = (SeriesJobBasic) seriesJob
|
|
|
|
.getSeriesJobDefinition();
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
double minRange = ChartTimeMeasure
|
|
|
|
.calculateMinRange(accountingStateData.getSeriesRequest()
|
|
|
|
.getAccountingPeriod());
|
|
|
|
|
|
|
|
double interval = ChartTimeMeasure
|
|
|
|
.calculateInterval(accountingStateData.getSeriesRequest()
|
|
|
|
.getAccountingPeriod());
|
2016-02-19 16:21:27 +01:00
|
|
|
|
|
|
|
Date dateStart = dtf.parse(accountingStateData.getSeriesRequest()
|
2016-02-15 14:35:02 +01:00
|
|
|
.getAccountingPeriod().getStartDate());
|
2016-02-19 16:21:27 +01:00
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
dateStart.setTime(dateStart.getTime()
|
|
|
|
+ ChartTimeMeasure.timeZoneOffset() * ChartTimeMeasure.MINUTE);
|
|
|
|
|
|
|
|
Log.debug("BuildChart DateStart: "
|
|
|
|
+ DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_FULL)
|
|
|
|
.format(dateStart));
|
|
|
|
|
|
|
|
HighchartsOptionFactory highchartsFactory = new JsoHighchartsOptionFactory();
|
|
|
|
options = highchartsFactory.createChartOptions();
|
2016-02-19 16:21:27 +01:00
|
|
|
|
2016-02-15 14:35:02 +01:00
|
|
|
options.navigation().buttonOptions().enabled(false);
|
2016-02-19 16:21:27 +01:00
|
|
|
options.exporting().filename("AccountingJob");
|
2016-02-15 14:35:02 +01:00
|
|
|
options.chart().zoomType("xy");
|
|
|
|
|
2016-02-19 16:21:27 +01:00
|
|
|
options.title().text("Accounting Job");
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* options.subtitle().text("Click and drag in the plot area to zoom in");
|
|
|
|
*/
|
|
|
|
|
|
|
|
ArrayString colors = options.colors();
|
|
|
|
// colors.setValue(0, "#cc0038");
|
|
|
|
// colors.setValue(1, "#32cd32");
|
|
|
|
|
|
|
|
// xAxis
|
|
|
|
options.xAxis().type("datetime").minRange(minRange);
|
|
|
|
|
|
|
|
// yAxis
|
|
|
|
// options.yAxis().title().text("Exchange rate");
|
|
|
|
// Highcharts.getOptions().colors[0]
|
|
|
|
|
2016-02-19 16:21:27 +01:00
|
|
|
String multiAxis = "[{" + " \"id\": \""
|
|
|
|
+ JobChartMeasure.OperationCount.name() + "\","
|
2016-02-15 14:35:02 +01:00
|
|
|
+ " \"labels\": { " + " \"format\": \"{value}\","
|
2016-02-19 16:21:27 +01:00
|
|
|
+ " \"style\": { " + " \"color\": \"" + colors.get(1)
|
|
|
|
+ "\"" + " }" + " }," + " \"title\": { "
|
|
|
|
+ " \"text\": \""
|
|
|
|
+ JobChartMeasure.OperationCount.getLabel() + "\","
|
|
|
|
+ " \"style\": {" + " \"color\": \"" + colors.get(1)
|
2016-05-31 15:50:31 +02:00
|
|
|
+ "\"" + " }" + " }" + "} , {" + " \"id\": \"JobData\", "
|
|
|
|
+ " \"linkedTo\": \"0\"," + " \"gridLineWidth\": \"0\","
|
|
|
|
+ " \"title\": {" + " \"text\": \"\"," + " \"style\": {"
|
2016-02-19 16:21:27 +01:00
|
|
|
+ " \"color\": \"" + colors.get(1) + "\"" + " }"
|
|
|
|
+ " }," + " \"labels\": {" + " \"format\": \"{value} "
|
|
|
|
+ unitMeasureLabel + "\"," + " \"style\": {"
|
|
|
|
+ " \"color\": \"" + colors.get(1) + "\"" + " }"
|
|
|
|
+ " }," + " \"opposite\": \"true\"" + // +
|
|
|
|
// ", \"showFirstLabel\": \"false\""
|
|
|
|
// +
|
2016-02-15 14:35:02 +01:00
|
|
|
"}]";
|
|
|
|
|
|
|
|
options.setFieldAsJsonObject("yAxis", multiAxis);
|
|
|
|
|
|
|
|
// does not seem to be working
|
|
|
|
String fillcolor = "{" + "\"linearGradient\": {" + "\"x1\": 0,"
|
|
|
|
+ "\"y1\": 0," + "\"x2\": 0," + "\"y2\": 1" + "},"
|
|
|
|
+ "\"stops\": [" + "[" + "0, \"#058DC7\"" + "]," + "["
|
|
|
|
+ "1, \"#FFFFFF\"" + "]" + "]" + "}";
|
|
|
|
|
|
|
|
options.plotOptions().area()
|
|
|
|
.setFieldAsJsonObject("fillColor", fillcolor).marker()
|
|
|
|
.radius(2).lineWidth(1).states().hover().lineWidth(1);
|
|
|
|
|
|
|
|
SeriesColumn seriesOperationCount = highchartsFactory
|
|
|
|
.createSeriesColumn();
|
2016-05-31 15:50:31 +02:00
|
|
|
seriesOperationCount.name(JobChartMeasure.OperationCount.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesOperationCount.color(colors.get(1));
|
|
|
|
seriesOperationCount.type("column");
|
|
|
|
|
|
|
|
ArrayNumber dataOperationCount = seriesOperationCount
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesOperationCount.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesDuration = highchartsFactory.createSeriesArea();
|
2016-02-18 13:08:47 +01:00
|
|
|
seriesDuration.name(JobChartMeasure.Duration.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesDuration.color(colors.get(0));
|
2016-05-31 15:50:31 +02:00
|
|
|
// seriesDuration.yAxisAsString("JobData");
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataDuration = seriesDuration.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesDuration.pointInterval(interval).pointStart(dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesMaxInvocationTime = highchartsFactory
|
|
|
|
.createSeriesArea();
|
2016-02-19 16:21:27 +01:00
|
|
|
seriesMaxInvocationTime.name(JobChartMeasure.MaxInvocationTime
|
|
|
|
.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesMaxInvocationTime.color(colors.get(2));
|
2016-05-31 15:50:31 +02:00
|
|
|
// seriesMaxInvocationTime.yAxisAsString("JobData");
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataMaxInvocationTime = seriesMaxInvocationTime
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesMaxInvocationTime.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
|
|
|
SeriesArea seriesMinInvocationTime = highchartsFactory
|
|
|
|
.createSeriesArea();
|
2016-02-19 16:21:27 +01:00
|
|
|
seriesMinInvocationTime.name(JobChartMeasure.MinInvocationTime
|
|
|
|
.getLabel());
|
2016-02-15 14:35:02 +01:00
|
|
|
seriesMinInvocationTime.color(colors.get(3));
|
2016-05-31 15:50:31 +02:00
|
|
|
// seriesMinInvocationTime.yAxisAsString("JobData");
|
2016-02-15 14:35:02 +01:00
|
|
|
|
|
|
|
ArrayNumber dataMinInvocationTime = seriesMinInvocationTime
|
|
|
|
.dataAsArrayNumber();
|
|
|
|
|
|
|
|
seriesMinInvocationTime.pointInterval(interval).pointStart(
|
|
|
|
dateStart.getTime());
|
|
|
|
|
2016-05-31 15:50:31 +02:00
|
|
|
for (SeriesJobData seriesJobData : seriesJobBasic.getSeries()) {
|
2016-02-18 13:08:47 +01:00
|
|
|
dataOperationCount.push(seriesJobData.getOperationCount());
|
2016-02-19 16:21:27 +01:00
|
|
|
dataDuration.push(seriesJobData.getDuration() / unitMeasure);
|
|
|
|
dataMaxInvocationTime.push(seriesJobData.getMaxInvocationTime()
|
|
|
|
/ unitMeasure);
|
|
|
|
dataMinInvocationTime.push(seriesJobData.getMinInvocationTime()
|
|
|
|
/ unitMeasure);
|
2016-02-15 14:35:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
options.series().addToEnd(seriesOperationCount);
|
|
|
|
options.series().addToEnd(seriesDuration);
|
|
|
|
options.series().addToEnd(seriesMaxInvocationTime);
|
|
|
|
options.series().addToEnd(seriesMinInvocationTime);
|
|
|
|
|
|
|
|
options.chart().showAxes(true);
|
|
|
|
|
|
|
|
options.legend().enabled(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|