Search in sources :

Example 16 with CustomChartSeries

use of org.devgateway.toolkit.web.excelcharts.CustomChartSeries 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

CustomChartSeries (org.devgateway.toolkit.web.excelcharts.CustomChartSeries)16 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)14 CTPlotArea (org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)14 ChartAxis (org.apache.poi.ss.usermodel.charts.ChartAxis)12 CTValAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx)10 CTBarChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart)4 CTCatAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx)4 CTAreaChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart)2 CTBubbleChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTBubbleChart)2 CTLineChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart)2 CTPieChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart)2 CTScatterChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart)2