Search in sources :

Example 1 with CTBarChart

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

the class XSSFStackedBarChartData 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 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.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(barChart);
    }
    for (ChartAxis ax : axis) {
        barChart.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) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) CTBarChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart)

Example 2 with CTBarChart

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

the class XSSFBarChartData 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 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());
            }
        }
    };
}
Also used : CTNumDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource) CTBarSer(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer) XmlObject(org.apache.xmlbeans.XmlObject) CTBarChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart) CTAxDataSource(org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)

Example 3 with CTBarChart

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

the class XSSFBarChartData 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 CTBarChart barChart = plotArea.addNewBarChart();
    barChart.addNewVaryColors().setVal(false);
    // set bars orientation
    barChart.addNewBarDir().setVal(barDir);
    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(barChart);
    }
    for (ChartAxis ax : axis) {
        barChart.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) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) CTBarChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart)

Example 4 with CTBarChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart in project oc-explorer by devgateway.

the class XSSFStackedBarChartData 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 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());
    }
}
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) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) CTBarChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart)

Example 5 with CTBarChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart in project oc-explorer by devgateway.

the class XSSFBarChartData 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 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());
    }
}
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) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) CTBarChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart)

Aggregations

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