Search in sources :

Example 1 with CTScatterChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart in project poi by apache.

the class XSSFScatterChartData method fillChart.

public void fillChart(Chart chart, ChartAxis... axis) {
    if (!(chart instanceof XSSFChart)) {
        throw new IllegalArgumentException("Chart must be instance of XSSFChart");
    }
    XSSFChart xssfChart = (XSSFChart) chart;
    CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
    CTScatterChart scatterChart = plotArea.addNewScatterChart();
    addStyle(scatterChart);
    for (Series s : series) {
        s.addToChart(scatterChart);
    }
    for (ChartAxis ax : axis) {
        scatterChart.addNewAxId().setVal(ax.getId());
    }
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) CTScatterChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart) ScatterChartSeries(org.apache.poi.ss.usermodel.charts.ScatterChartSeries) ChartAxis(org.apache.poi.ss.usermodel.charts.ChartAxis) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)

Example 2 with CTScatterChart

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

the class XSSFScatterChartData 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 CTScatterChart scatterChart = plotArea.addNewScatterChart();
    addStyle(scatterChart);
    for (CustomChartSeries s : series) {
        s.addToChart(scatterChart);
    }
    for (ChartAxis ax : axis) {
        scatterChart.addNewAxId().setVal(ax.getId());
    }
    xssfChart.setTitle(this.title);
    // add grid lines
    CTCatAx[] ctCatAx = plotArea.getCatAxArray();
    if (ctCatAx.length != 0) {
        ctCatAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
    }
    CTValAx[] ctValAx = plotArea.getValAxArray();
    if (ctValAx.length != 0) {
        ctValAx[0].addNewMajorGridlines().addNewSpPr().addNewSolidFill();
    }
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) CTScatterChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart) CustomChartSeries(org.devgateway.toolkit.web.excelcharts.CustomChartSeries) ChartAxis(org.apache.poi.ss.usermodel.charts.ChartAxis) CTValAx(org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx) CTPlotArea(org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea) CTCatAx(org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx)

Example 3 with CTScatterChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart in project poi by apache.

the class XSSFScatterChartData method addStyle.

private void addStyle(CTScatterChart ctScatterChart) {
    CTScatterStyle scatterStyle = ctScatterChart.addNewScatterStyle();
    scatterStyle.setVal(STScatterStyle.LINE_MARKER);
}
Also used : CTScatterStyle(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterStyle)

Example 4 with CTScatterChart

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

the class XSSFScatterChartData method addStyle.

private static void addStyle(final CTScatterChart ctScatterChart) {
    final CTScatterStyle scatterStyle = ctScatterChart.addNewScatterStyle();
    scatterStyle.setVal(STScatterStyle.LINE_MARKER);
}
Also used : CTScatterStyle(org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterStyle)

Example 5 with CTScatterChart

use of org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart 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)

Aggregations

CTScatterChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart)3 ChartAxis (org.apache.poi.ss.usermodel.charts.ChartAxis)2 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)2 CTPlotArea (org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea)2 CTScatterStyle (org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterStyle)2 ScatterChartSeries (org.apache.poi.ss.usermodel.charts.ScatterChartSeries)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CustomChartSeries (org.devgateway.toolkit.web.excelcharts.CustomChartSeries)1 CTAxDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource)1 CTCatAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx)1 CTNumDataSource (org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource)1 CTScatterSer (org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterSer)1 CTValAx (org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx)1