diff --git a/web/pom.xml b/web/pom.xml
index 88dbd45004..3d06503780 100644
--- a/web/pom.xml
+++ b/web/pom.xml
@@ -20,6 +20,7 @@
1.5
1.2.14
1.13
+ 1.4
@@ -84,6 +85,18 @@
2.0
+
+ org.apache.poi
+ ooxml-schemas
+ ${ooxml-schemas.version}
+
+
+ org.apache.xmlbeans
+ xmlbeans
+
+
+
+
com.github.java-json-tools
json-schema-validator
diff --git a/web/src/main/java/org/devgateway/ocds/web/rest/controller/BudgetStatsController.java b/web/src/main/java/org/devgateway/ocds/web/rest/controller/BudgetStatsController.java
index 25b5a942e8..592291a688 100644
--- a/web/src/main/java/org/devgateway/ocds/web/rest/controller/BudgetStatsController.java
+++ b/web/src/main/java/org/devgateway/ocds/web/rest/controller/BudgetStatsController.java
@@ -11,6 +11,19 @@
*******************************************************************************/
package org.devgateway.ocds.web.rest.controller;
+import io.swagger.annotations.ApiOperation;
+import org.bson.Document;
+import org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+
import static org.devgateway.ocds.persistence.mongo.constants.MongoConstants.FieldNames.CONTRACTS;
import static org.devgateway.ocds.persistence.mongo.constants.MongoConstants.FieldNames.CONTRACTS_VALUE_AMOUNT;
import static org.devgateway.ocds.persistence.mongo.constants.MongoConstants.FieldNames.PLANNING_BUDGETB;
@@ -26,19 +39,6 @@
import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.unwind;
-import io.swagger.annotations.ApiOperation;
-import org.bson.Document;
-import org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.mongodb.core.aggregation.Aggregation;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.validation.Valid;
-import java.util.List;
-
/**
* @author mpostelnicu
*/
@@ -51,13 +51,8 @@ public class BudgetStatsController extends GenericOCDSController {
public List expenditureToDateVsBudget(
@ModelAttribute @Valid final YearFilterPagingRequest filter) {
- YearFilterPagingRequest effectiveFilters = new YearFilterPagingRequest();
- effectiveFilters.setBuyerId(filter.getBuyerId());
- effectiveFilters.setProcuringEntityId(filter.getProcuringEntityId());
- effectiveFilters.setFiscalYear(filter.getFiscalYear());
-
Aggregation agg = newAggregation(
- match(getDefaultFilterCriteria(effectiveFilters)),
+ match(getYearDefaultFilterCriteria(filter, getTenderDateField())),
facet(
unwind(CONTRACTS, true),
group(PLANNING_FISCAL_YEAR)
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFAreaChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFAreaChartData.java
index f51ee97a1d..d732e1707c 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFAreaChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFAreaChartData.java
@@ -3,8 +3,17 @@
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartDataSource;
+import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.xmlbeans.XmlObject;
import org.devgateway.toolkit.web.excelcharts.CustomChartSeries;
+import org.devgateway.toolkit.web.excelcharts.util.XSSFChartUtil;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STCrossBetween;
/**
* @author idobre
@@ -23,50 +32,50 @@ protected CustomChartSeries createNewSerie(final int id, final int order, final
return new AbstractSeries(id, order, categories, values) {
@Override
public void addToChart(final XmlObject ctChart) {
-// final CTAreaChart ctAreaChart = (CTAreaChart) ctChart;
-// final CTAreaSer ctAreaSer = ctAreaChart.addNewSer();
-//
-// ctAreaSer.addNewIdx().setVal(this.id);
-// ctAreaSer.addNewOrder().setVal(this.order);
-//
-// final CTAxDataSource catDS = ctAreaSer.addNewCat();
-// XSSFChartUtil.buildAxDataSource(catDS, this.categories);
-//
-// final CTNumDataSource valueDS = ctAreaSer.addNewVal();
-// XSSFChartUtil.buildNumDataSource(valueDS, this.values);
-//
-// if (isTitleSet()) {
-// ctAreaSer.setTx(getCTSerTx());
-// }
+ final CTAreaChart ctAreaChart = (CTAreaChart) ctChart;
+ final CTAreaSer ctAreaSer = ctAreaChart.addNewSer();
+
+ ctAreaSer.addNewIdx().setVal(this.id);
+ ctAreaSer.addNewOrder().setVal(this.order);
+
+ final CTAxDataSource catDS = ctAreaSer.addNewCat();
+ XSSFChartUtil.buildAxDataSource(catDS, this.categories);
+
+ final CTNumDataSource valueDS = ctAreaSer.addNewVal();
+ XSSFChartUtil.buildNumDataSource(valueDS, this.values);
+
+ if (isTitleSet()) {
+ ctAreaSer.setTx(getCTSerTx());
+ }
}
};
}
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
-// if (!(chart instanceof XSSFChart)) {
-// throw new IllegalArgumentException("Chart must be instance of XSSFChart");
-// }
-//
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTAreaChart areChart = plotArea.addNewAreaChart();
-// areChart.addNewVaryColors().setVal(false);
-//
-// xssfChart.setTitleText(this.title);
-//
-// CTValAx[] ctValAx = plotArea.getValAxArray();
-// if (ctValAx.length != 0) {
-// ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
-// }
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(areChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// areChart.addNewAxId().setVal(ax.getId());
-// }
+ if (!(chart instanceof XSSFChart)) {
+ throw new IllegalArgumentException("Chart must be instance of XSSFChart");
+ }
+
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTAreaChart areChart = plotArea.addNewAreaChart();
+ areChart.addNewVaryColors().setVal(false);
+
+ xssfChart.setTitleText(this.title);
+
+ CTValAx[] ctValAx = plotArea.getValAxArray();
+ if (ctValAx.length != 0) {
+ ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
+ }
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(areChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ areChart.addNewAxId().setVal(ax.getId());
+ }
}
}
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBarChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBarChartData.java
index b4776d4d43..331da5e03a 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBarChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBarChartData.java
@@ -6,6 +6,15 @@
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.xmlbeans.XmlObject;
import org.devgateway.toolkit.web.excelcharts.CustomChartSeries;
+import org.devgateway.toolkit.web.excelcharts.util.XSSFChartUtil;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STBarDir;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STCrossBetween;
/**
* @author idobre
@@ -14,7 +23,7 @@
* Holds data for a XSSF Bar Chart.
*/
public class XSSFBarChartData extends AbstractXSSFChartData {
- //protected STBarDir.Enum barDir = STBarDir.COL;
+ protected STBarDir.Enum barDir = STBarDir.COL;
public XSSFBarChartData(final String title) {
super(title);
@@ -26,21 +35,21 @@ protected CustomChartSeries createNewSerie(final int id, final int order, final
return new AbstractSeries(id, order, categories, values) {
@Override
public void addToChart(final XmlObject ctChart) {
-// final CTBarChart ctBarChart = (CTBarChart) ctChart;
-// final CTBarSer ctBarSer = ctBarChart.addNewSer();
-//
-// ctBarSer.addNewIdx().setVal(this.id);
-// ctBarSer.addNewOrder().setVal(this.order);
-//
-// final CTAxDataSource catDS = ctBarSer.addNewCat();
-// XSSFChartUtil.buildAxDataSource(catDS, this.categories);
-//
-// final CTNumDataSource valueDS = ctBarSer.addNewVal();
-// XSSFChartUtil.buildNumDataSource(valueDS, this.values);
-//
-// if (isTitleSet()) {
-// ctBarSer.setTx(getCTSerTx());
-// }
+ final CTBarChart ctBarChart = (CTBarChart) ctChart;
+ final CTBarSer ctBarSer = ctBarChart.addNewSer();
+
+ ctBarSer.addNewIdx().setVal(this.id);
+ ctBarSer.addNewOrder().setVal(this.order);
+
+ final CTAxDataSource catDS = ctBarSer.addNewCat();
+ XSSFChartUtil.buildAxDataSource(catDS, this.categories);
+
+ final CTNumDataSource valueDS = ctBarSer.addNewVal();
+ XSSFChartUtil.buildNumDataSource(valueDS, this.values);
+
+ if (isTitleSet()) {
+ ctBarSer.setTx(getCTSerTx());
+ }
}
};
}
@@ -50,34 +59,34 @@ public void fillChart(final Chart chart, final ChartAxis... axis) {
if (!(chart instanceof XSSFChart)) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
-//
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTBarChart barChart = plotArea.addNewBarChart();
-//
-// barChart.addNewVaryColors().setVal(false);
-//
-// // set bars orientation
-// barChart.addNewBarDir().setVal(barDir);
-//
-// xssfChart.setTitleText(this.title);
-//
-// CTValAx[] ctValAx = plotArea.getValAxArray();
-// if (ctValAx.length != 0) {
-// ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
-// }
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(barChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// barChart.addNewAxId().setVal(ax.getId());
-// }
+
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTBarChart barChart = plotArea.addNewBarChart();
+
+ barChart.addNewVaryColors().setVal(false);
+
+ // set bars orientation
+ barChart.addNewBarDir().setVal(barDir);
+
+ xssfChart.setTitleText(this.title);
+
+ CTValAx[] ctValAx = plotArea.getValAxArray();
+ if (ctValAx.length != 0) {
+ ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
+ }
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(barChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ barChart.addNewAxId().setVal(ax.getId());
+ }
}
-// public void setBarDir(final STBarDir.Enum barDir) {
-// this.barDir = barDir;
-// }
+ public void setBarDir(final STBarDir.Enum barDir) {
+ this.barDir = barDir;
+ }
}
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBubbleChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBubbleChartData.java
index d37e8fa57e..625b4dee19 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBubbleChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFBubbleChartData.java
@@ -6,6 +6,12 @@
import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.xmlbeans.XmlObject;
import org.devgateway.toolkit.web.excelcharts.CustomChartSeries;
+import org.devgateway.toolkit.web.excelcharts.util.XSSFChartUtil;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
/**
* @author idobre
@@ -24,21 +30,21 @@ protected CustomChartSeries createNewSerie(final int id, final int order, final
return new AbstractSeries(id, order, categories, values) {
@Override
public void addToChart(final XmlObject ctChart) {
-// final CTBubbleChart ctBubbleChart = (CTBubbleChart) ctChart;
-// final CTBubbleSer bubbleSer = ctBubbleChart.addNewSer();
-//
-// bubbleSer.addNewIdx().setVal(this.id);
-// bubbleSer.addNewOrder().setVal(this.order);
-//
-// final CTAxDataSource catDS = bubbleSer.addNewXVal();
-// XSSFChartUtil.buildAxDataSource(catDS, this.categories);
-//
-// final CTNumDataSource valueDS = bubbleSer.addNewBubbleSize();
-// XSSFChartUtil.buildNumDataSource(valueDS, this.values);
-//
-// if (isTitleSet()) {
-// bubbleSer.setTx(getCTSerTx());
-// }
+ final CTBubbleChart ctBubbleChart = (CTBubbleChart) ctChart;
+ final CTBubbleSer bubbleSer = ctBubbleChart.addNewSer();
+
+ bubbleSer.addNewIdx().setVal(this.id);
+ bubbleSer.addNewOrder().setVal(this.order);
+
+ final CTAxDataSource catDS = bubbleSer.addNewXVal();
+ XSSFChartUtil.buildAxDataSource(catDS, this.categories);
+
+ final CTNumDataSource valueDS = bubbleSer.addNewBubbleSize();
+ XSSFChartUtil.buildNumDataSource(valueDS, this.values);
+
+ if (isTitleSet()) {
+ bubbleSer.setTx(getCTSerTx());
+ }
}
};
}
@@ -49,18 +55,18 @@ public void fillChart(final Chart chart, final ChartAxis... axis) {
throw new IllegalArgumentException("Chart must be instance of XSSFChart");
}
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTBubbleChart bubbleChart = plotArea.addNewBubbleChart();
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(bubbleChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// bubbleChart.addNewAxId().setVal(ax.getId());
-// }
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTBubbleChart bubbleChart = plotArea.addNewBubbleChart();
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(bubbleChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ bubbleChart.addNewAxId().setVal(ax.getId());
+ }
-// xssfChart.setTitleText(this.title);
+ xssfChart.setTitleText(this.title);
}
}
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFLineChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFLineChartData.java
index 3c577b4aaf..a76754e18e 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFLineChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFLineChartData.java
@@ -57,34 +57,34 @@ public void addToChart(final XmlObject ctChart) {
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
-// if (!(chart instanceof XSSFChart)) {
-// throw new IllegalArgumentException("Chart must be instance of XSSFChart");
-// }
-//
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTLineChart lineChart = plotArea.addNewLineChart();
-// lineChart.addNewVaryColors().setVal(false);
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(lineChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// lineChart.addNewAxId().setVal(ax.getId());
-// }
-//
-// xssfChart.setTitleText(this.title);
-//
-// // add grid lines
-// CTCatAx[] ctCatAx = plotArea.getCatAxArray();
-// if (ctCatAx.length != 0) {
-// ctCatAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// }
-//
-// CTValAx[] ctValAx = plotArea.getValAxArray();
-// if (ctValAx.length != 0) {
-// ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// }
+ if (!(chart instanceof XSSFChart)) {
+ throw new IllegalArgumentException("Chart must be instance of XSSFChart");
+ }
+
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTLineChart lineChart = plotArea.addNewLineChart();
+ lineChart.addNewVaryColors().setVal(false);
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(lineChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ lineChart.addNewAxId().setVal(ax.getId());
+ }
+
+ xssfChart.setTitleText(this.title);
+
+ // add grid lines
+ CTCatAx[] ctCatAx = plotArea.getCatAxArray();
+ if (ctCatAx.length != 0) {
+ ctCatAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ }
+
+ CTValAx[] ctValAx = plotArea.getValAxArray();
+ if (ctValAx.length != 0) {
+ ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ }
}
}
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFScatterChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFScatterChartData.java
index 3cf028f18a..0dc9d81ad4 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFScatterChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFScatterChartData.java
@@ -3,14 +3,18 @@
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartDataSource;
+import org.apache.poi.xssf.usermodel.XSSFChart;
import org.apache.xmlbeans.XmlObject;
import org.devgateway.toolkit.web.excelcharts.CustomChartSeries;
import org.devgateway.toolkit.web.excelcharts.util.XSSFChartUtil;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterStyle;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.STScatterStyle;
/**
@@ -51,35 +55,35 @@ public void addToChart(final XmlObject ctChart) {
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
-// if (!(chart instanceof XSSFChart)) {
-// throw new IllegalArgumentException("Chart must be instance of XSSFChart");
-// }
-//
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTScatterChart scatterChart = plotArea.addNewScatterChart();
-// addStyle(scatterChart);
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(scatterChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// scatterChart.addNewAxId().setVal(ax.getId());
-// }
-//
-// xssfChart.setTitleText(this.title);
-//
-// // add grid lines
-// CTCatAx[] ctCatAx = plotArea.getCatAxArray();
-// if (ctCatAx.length != 0) {
-// ctCatAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// }
-//
-// CTValAx[] ctValAx = plotArea.getValAxArray();
-// if (ctValAx.length != 0) {
-// ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// }
+ if (!(chart instanceof XSSFChart)) {
+ throw new IllegalArgumentException("Chart must be instance of XSSFChart");
+ }
+
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTScatterChart scatterChart = plotArea.addNewScatterChart();
+ addStyle(scatterChart);
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(scatterChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ scatterChart.addNewAxId().setVal(ax.getId());
+ }
+
+ xssfChart.setTitleText(this.title);
+
+ // add grid lines
+ CTCatAx[] ctCatAx = plotArea.getCatAxArray();
+ if (ctCatAx.length != 0) {
+ ctCatAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ }
+
+ CTValAx[] ctValAx = plotArea.getValAxArray();
+ if (ctValAx.length != 0) {
+ ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ }
}
private static void addStyle(final CTScatterChart ctScatterChart) {
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFStackedBarChartData.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFStackedBarChartData.java
index a67fc495f9..3ee881a108 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFStackedBarChartData.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/data/XSSFStackedBarChartData.java
@@ -2,6 +2,13 @@
import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.devgateway.toolkit.web.excelcharts.CustomChartSeries;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STBarGrouping;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STCrossBetween;
/**
* @author idobre
@@ -10,7 +17,7 @@
* Holds data for a XSSF Stacked Bar Chart.
*/
public class XSSFStackedBarChartData extends XSSFBarChartData {
- //private STBarGrouping.Enum barGrouping = STBarGrouping.STACKED;
+ private STBarGrouping.Enum barGrouping = STBarGrouping.STACKED;
private static final int OVERLAPPERCENTAGE = 100;
@@ -20,41 +27,41 @@ public XSSFStackedBarChartData(final String title) {
@Override
public void fillChart(final Chart chart, final ChartAxis... axis) {
-// if (!(chart instanceof XSSFChart)) {
-// throw new IllegalArgumentException("Chart must be instance of XSSFChart");
-// }
-//
-// final XSSFChart xssfChart = (XSSFChart) chart;
-// final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
-// final CTBarChart barChart = plotArea.addNewBarChart();
-//
-// barChart.addNewVaryColors().setVal(false);
-//
-// // create a stacked bar
-// barChart.addNewGrouping().setVal(barGrouping);
-// barChart.addNewOverlap().setVal((byte) OVERLAPPERCENTAGE);
-//
-// // set bars orientation
-// barChart.addNewBarDir().setVal(barDir);
-//
-// xssfChart.setTitleText(this.title);
-//
-// CTValAx[] ctValAx = plotArea.getValAxArray();
-// if (ctValAx.length != 0) {
-// ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
-// ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
-// }
-//
-// for (CustomChartSeries s : series) {
-// s.addToChart(barChart);
-// }
-//
-// for (ChartAxis ax : axis) {
-// barChart.addNewAxId().setVal(ax.getId());
-// }
+ if (!(chart instanceof XSSFChart)) {
+ throw new IllegalArgumentException("Chart must be instance of XSSFChart");
+ }
+
+ final XSSFChart xssfChart = (XSSFChart) chart;
+ final CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+ final CTBarChart barChart = plotArea.addNewBarChart();
+
+ barChart.addNewVaryColors().setVal(false);
+
+ // create a stacked bar
+ barChart.addNewGrouping().setVal(barGrouping);
+ barChart.addNewOverlap().setVal((byte) OVERLAPPERCENTAGE);
+
+ // set bars orientation
+ barChart.addNewBarDir().setVal(barDir);
+
+ xssfChart.setTitleText(this.title);
+
+ CTValAx[] ctValAx = plotArea.getValAxArray();
+ if (ctValAx.length != 0) {
+ ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
+ ctValAx[0].getCrossBetween().setVal(STCrossBetween.BETWEEN);
+ }
+
+ for (CustomChartSeries s : series) {
+ s.addToChart(barChart);
+ }
+
+ for (ChartAxis ax : axis) {
+ barChart.addNewAxId().setVal(ax.getId());
+ }
}
-// public void setBarGrouping(final STBarGrouping.Enum barGrouping) {
-// this.barGrouping = barGrouping;
-// }
+ public void setBarGrouping(final STBarGrouping.Enum barGrouping) {
+ this.barGrouping = barGrouping;
+ }
}
diff --git a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/util/CustomChartDataFactoryDefault.java b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/util/CustomChartDataFactoryDefault.java
index 3d54190002..38251aaf0a 100644
--- a/web/src/main/java/org/devgateway/toolkit/web/excelcharts/util/CustomChartDataFactoryDefault.java
+++ b/web/src/main/java/org/devgateway/toolkit/web/excelcharts/util/CustomChartDataFactoryDefault.java
@@ -2,6 +2,15 @@
import org.devgateway.toolkit.web.excelcharts.ChartType;
import org.devgateway.toolkit.web.excelcharts.CustomChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFAreaChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFBarChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFBubbleChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFLineChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFPieChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFScatterChartData;
+import org.devgateway.toolkit.web.excelcharts.data.XSSFStackedBarChartData;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STBarDir;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STBarGrouping;
/**
@@ -14,53 +23,53 @@ public class CustomChartDataFactoryDefault implements CustomChartDataFactory {
*/
@Override
public CustomChartData createChartData(final ChartType type, final String title) {
- final CustomChartData chartData = null;
-// switch (type) {
-// case area:
-// chartData = new XSSFAreaChartData(title);
-// break;
-// case bar:
-// XSSFBarChartData barChartData = new XSSFBarChartData(title);
-// barChartData.setBarDir(STBarDir.BAR);
-// chartData = barChartData;
-// break;
-// case barcol:
-// chartData = new XSSFBarChartData(title);
-// break;
-// case stackedcol:
-// chartData = new XSSFStackedBarChartData(title);
-// break;
-// case stackedcolpercentage:
-// XSSFStackedBarChartData stackedColChartData = new XSSFStackedBarChartData(title);
-// stackedColChartData.setBarGrouping(STBarGrouping.PERCENT_STACKED);
-// chartData = stackedColChartData;
-// break;
-// case stackedbar:
-// XSSFStackedBarChartData stackedBarChartData = new XSSFStackedBarChartData(title);
-// stackedBarChartData.setBarDir(STBarDir.BAR);
-// chartData = stackedBarChartData;
-// break;
-// case stackedbarpercentage:
-// XSSFStackedBarChartData stackedBarPercentageChartData = new XSSFStackedBarChartData(title);
-// stackedBarPercentageChartData.setBarGrouping(STBarGrouping.PERCENT_STACKED);
-// stackedBarPercentageChartData.setBarDir(STBarDir.BAR);
-// chartData = stackedBarPercentageChartData;
-// break;
-// case line:
-// chartData = new XSSFLineChartData(title);
-// break;
-// case pie:
-// chartData = new XSSFPieChartData(title);
-// break;
-// case scatter:
-// chartData = new XSSFScatterChartData(title);
-// break;
-// case bubble:
-// chartData = new XSSFBubbleChartData(title);
-// break;
-// default:
-// chartData = null;
-// }
+ CustomChartData chartData = null;
+ switch (type) {
+ case area:
+ chartData = new XSSFAreaChartData(title);
+ break;
+ case bar:
+ XSSFBarChartData barChartData = new XSSFBarChartData(title);
+ barChartData.setBarDir(STBarDir.BAR);
+ chartData = barChartData;
+ break;
+ case barcol:
+ chartData = new XSSFBarChartData(title);
+ break;
+ case stackedcol:
+ chartData = new XSSFStackedBarChartData(title);
+ break;
+ case stackedcolpercentage:
+ XSSFStackedBarChartData stackedColChartData = new XSSFStackedBarChartData(title);
+ stackedColChartData.setBarGrouping(STBarGrouping.PERCENT_STACKED);
+ chartData = stackedColChartData;
+ break;
+ case stackedbar:
+ XSSFStackedBarChartData stackedBarChartData = new XSSFStackedBarChartData(title);
+ stackedBarChartData.setBarDir(STBarDir.BAR);
+ chartData = stackedBarChartData;
+ break;
+ case stackedbarpercentage:
+ XSSFStackedBarChartData stackedBarPercentageChartData = new XSSFStackedBarChartData(title);
+ stackedBarPercentageChartData.setBarGrouping(STBarGrouping.PERCENT_STACKED);
+ stackedBarPercentageChartData.setBarDir(STBarDir.BAR);
+ chartData = stackedBarPercentageChartData;
+ break;
+ case line:
+ chartData = new XSSFLineChartData(title);
+ break;
+ case pie:
+ chartData = new XSSFPieChartData(title);
+ break;
+ case scatter:
+ chartData = new XSSFScatterChartData(title);
+ break;
+ case bubble:
+ chartData = new XSSFBubbleChartData(title);
+ break;
+ default:
+ chartData = null;
+ }
return chartData;
}