Search in sources :

Example 16 with CTChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project ocvn by devgateway.

the class XSSFScatterChartData 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 CTScatterChart ctScatterChart = (CTScatterChart) ctChart;
            final CTScatterSer scatterSer = ctScatterChart.addNewSer();
            scatterSer.addNewIdx().setVal(this.id);
            scatterSer.addNewOrder().setVal(this.order);
            final CTAxDataSource catDS = scatterSer.addNewXVal();
            XSSFChartUtil.buildAxDataSource(catDS, this.categories);
            final CTNumDataSource valueDS = scatterSer.addNewYVal();
            XSSFChartUtil.buildNumDataSource(valueDS, this.values);
            if (isTitleSet()) {
                scatterSer.setTx(getCTSerTx());
            }
        }
    };
}
Also used : CTScatterChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart) CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) CTScatterSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer) XmlObject(org.apache.xmlbeans.XmlObject) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 17 with CTChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project ocvn 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);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Example 18 with CTChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project ocvn by devgateway.

the class AverageNumberOfTenderersExcelControllerTest method averageNumberBidsExcelChart.

@Test
public void averageNumberBidsExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    averageNumberOfTenderersExcelController.averageNumberBidsExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.barcol.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:avgNrBids: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 bar chart", 1, ctChart.getPlotArea().getBarChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Example 19 with CTChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project ocvn by devgateway.

the class AverageTenderAndAwardsExcelControllerTest method bidTimelineExcelChart.

@Test
public void bidTimelineExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    averageTenderAndAwardsExcelController.bidTimelineExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.stackedbar.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:bidPeriod: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 bar chart", 1, ctChart.getPlotArea().getBarChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Example 20 with CTChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTChart in project ocvn by devgateway.

the class CostEffectivenessExcelControllerTest method costEffectivenessExcelChart.

@Test
public void costEffectivenessExcelChart() throws Exception {
    LangGroupingFilterPagingRequest filter = getLangGroupingFilterMockRequest();
    costEffectivenessExcelController.costEffectivenessExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.stackedcol.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:costEffectiveness: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 bar chart", 1, ctChart.getPlotArea().getBarChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) LangGroupingFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Aggregations

CTChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTChart)18 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)16 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)16 Test (org.junit.Test)16 Sheet (org.apache.poi.ss.usermodel.Sheet)15 Workbook (org.apache.poi.ss.usermodel.Workbook)15 XSSFDrawing (org.apache.poi.xssf.usermodel.XSSFDrawing)15 ByteArrayInputStream (java.io.ByteArrayInputStream)14 LangYearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest)13 CTAxDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)9 CTNumDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource)9 XmlObject (org.apache.xmlbeans.XmlObject)6 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)3 CTPieChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart)3 CTPieSer (org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer)3 CTPlotArea (org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)3 OutputStream (java.io.OutputStream)2 POIXMLDocumentPart (org.apache.poi.POIXMLDocumentPart)2 Pair (android.util.Pair)1 AddTrace (com.google.firebase.perf.metrics.AddTrace)1