use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project oc-explorer by devgateway.
the class TotalCancelledTendersExcelControllerTest method cancelledFundingExcelChart.
@Test
public void cancelledFundingExcelChart() throws Exception {
LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
totalCancelledTendersExcelController.cancelledFundingExcelChart(filter, mockHttpServletResponse);
final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
Assert.assertNotNull(workbook);
final Sheet sheet = workbook.getSheet(ChartType.area.toString());
Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet);
final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch();
final List<XSSFChart> charts = drawing.getCharts();
Assert.assertEquals("number of charts", 1, charts.size());
final XSSFChart chart = charts.get(0);
Assert.assertEquals("chart title", translationService.getValue(filter.getLanguage(), "charts:cancelledAmounts:title"), chart.getTitle().getString());
final List<? extends XSSFChartAxis> axis = chart.getAxis();
Assert.assertEquals("number of axis", 2, axis.size());
final CTChart ctChart = chart.getCTChart();
Assert.assertEquals("Check if we have 1 area chart", 1, ctChart.getPlotArea().getAreaChartArray().length);
}
use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project oc-explorer by devgateway.
the class TenderPercentagesExcelControllerTest method cancelledFundingPercentageExcelChart.
@Test
public void cancelledFundingPercentageExcelChart() throws Exception {
LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
tenderPercentagesExcelController.cancelledFundingPercentageExcelChart(filter, mockHttpServletResponse);
final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
Assert.assertNotNull(workbook);
final Sheet sheet = workbook.getSheet(ChartType.area.toString());
Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet);
final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch();
final List<XSSFChart> charts = drawing.getCharts();
Assert.assertEquals("number of charts", 1, charts.size());
final XSSFChart chart = charts.get(0);
Assert.assertEquals("chart title", translationService.getValue(filter.getLanguage(), "charts:cancelledPercents:title"), chart.getTitle().getString());
final List<? extends XSSFChartAxis> axis = chart.getAxis();
Assert.assertEquals("number of axis", 2, axis.size());
final CTChart ctChart = chart.getCTChart();
Assert.assertEquals("Check if we have 1 area chart", 1, ctChart.getPlotArea().getAreaChartArray().length);
}
use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project oc-explorer by devgateway.
the class TenderPercentagesExcelControllerTest method tendersWithLinkedProcurementPlanExcelChart.
@Test
public void tendersWithLinkedProcurementPlanExcelChart() throws Exception {
LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
tenderPercentagesExcelController.tendersWithLinkedProcurementPlanExcelChart(filter, mockHttpServletResponse);
final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
Assert.assertNotNull(workbook);
final Sheet sheet = workbook.getSheet(ChartType.area.toString());
Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet);
final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch();
final List<XSSFChart> charts = drawing.getCharts();
Assert.assertEquals("number of charts", 1, charts.size());
final XSSFChart chart = charts.get(0);
Assert.assertEquals("chart title", translationService.getValue(filter.getLanguage(), "charts:percentWithTenders:title"), chart.getTitle().getString());
final List<? extends XSSFChartAxis> axis = chart.getAxis();
Assert.assertEquals("number of axis", 2, axis.size());
final CTChart ctChart = chart.getCTChart();
Assert.assertEquals("Check if we have 1 area chart", 1, ctChart.getPlotArea().getAreaChartArray().length);
}
use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project oc-explorer by devgateway.
the class XSSFAreaChartData method createNewSerie.
@Override
protected CustomChartSeries createNewSerie(final int id, final int order, final ChartDataSource<?> categories, final ChartDataSource<? extends Number> values) {
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());
}
}
};
}
use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project oc-explorer by devgateway.
the class XSSFLineChartData method createNewSerie.
@Override
protected CustomChartSeries createNewSerie(final int id, final int order, final ChartDataSource<?> categories, final ChartDataSource<? extends Number> values) {
return new AbstractSeries(id, order, categories, values) {
@Override
public void addToChart(final XmlObject ctChart) {
final CTLineChart ctLineChart = (CTLineChart) ctChart;
final CTLineSer ctLineSer = ctLineChart.addNewSer();
ctLineSer.addNewIdx().setVal(this.id);
ctLineSer.addNewOrder().setVal(this.order);
// No marker symbol on the chart line.
ctLineSer.addNewMarker().addNewSymbol().setVal(STMarkerStyle.CIRCLE);
final CTAxDataSource catDS = ctLineSer.addNewCat();
XSSFChartUtil.buildAxDataSource(catDS, this.categories);
final CTNumDataSource valueDS = ctLineSer.addNewVal();
XSSFChartUtil.buildNumDataSource(valueDS, this.values);
if (isTitleSet()) {
ctLineSer.setTx(getCTSerTx());
}
}
};
}
Aggregations