Search in sources :

Example 1 with CTAreaChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart in project ocvn 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());
            }
        }
    };
}
Also used : CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) CTAreaChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart) CTAreaSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer) XmlObject(org.apache.xmlbeans.XmlObject) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 2 with CTAreaChart

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

the class XSSFAreaChartData method fillChart.

@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.setTitle(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());
    }
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) CTValAx(org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx) CustomChartSeries(org.devgateway.toolkit.web.excelcharts.CustomChartSeries) ChartAxis(org.apache.poi.ss.usermodel.charts.ChartAxis) CTAreaChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)

Aggregations

CTAreaChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart)2 ChartAxis (org.apache.poi.ss.usermodel.charts.ChartAxis)1 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CustomChartSeries (org.devgateway.toolkit.web.excelcharts.CustomChartSeries)1 CTAreaSer (org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer)1 CTAxDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)1 CTNumDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource)1 CTPlotArea (org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)1 CTValAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx)1