code cleanup plus fix for bug 63153

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1859590 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alain Béarez 2019-05-21 00:13:40 +00:00
parent af1dacfe2c
commit 093cbcfcca
23 changed files with 875 additions and 315 deletions

View File

@ -108,7 +108,7 @@ public class BarChartDemo {
values1[6] = 16.0; // if you ever want to change the underlying data
final XDDFNumericalDataSource<? extends Number> valuesData2 = XDDFDataSourcesFactory.fromArray(values2, valuesDataRange2, 2);
XDDFChartData.Series series1 = bar.getSeries().get(0);
XDDFChartData.Series series1 = bar.getSeries(0);
series1.replaceData(categoriesData, valuesData);
series1.setTitle(series[0], chart.setSheetTitle(series[0], 0));
XDDFChartData.Series series2 = bar.addSeries(categoriesData, valuesData2);

View File

@ -98,10 +98,10 @@ public class PieChartDemo {
final XDDFDataSource<?> categoriesData = XDDFDataSourcesFactory.fromArray(categories, categoryDataRange);
final XDDFNumericalDataSource<? extends Number> valuesData = XDDFDataSourcesFactory.fromArray(values, valuesDataRange);
XDDFPieChartData.Series firstSeries = (XDDFPieChartData.Series) pie.getSeries().get(0);
XDDFPieChartData.Series firstSeries = (XDDFPieChartData.Series) pie.getSeries(0);
firstSeries.replaceData(categoriesData, valuesData);
firstSeries.setTitle(chartTitle, chart.setSheetTitle(chartTitle, 0));
firstSeries.setExplosion(25);
firstSeries.setExplosion(25L);
chart.plot(pie);
// save the result

View File

@ -152,8 +152,8 @@ public class BarAndLineChart {
XDDFLineChartData.Series series2 = (XDDFLineChartData.Series) lines.addSeries(xs, ys2);
series2.updateIdXVal(1);
series2.updateOrderVal(1);
series2.setIndex(1);
series2.setOrder(1);
series2.setTitle("Lines", new CellReference("Sheet1!$C$1"));
lines.setVaryColors(true);
chart.plot(lines);

View File

@ -110,7 +110,7 @@ public class BarChartExample {
values1[6] = 16.0; // if you ever want to change the underlying data
final XDDFNumericalDataSource<? extends Number> valuesData2 = XDDFDataSourcesFactory.fromArray(values2, valuesDataRange2, 2);
XDDFChartData.Series series1 = bar.getSeries().get(0);
XDDFChartData.Series series1 = bar.getSeries(0);
series1.replaceData(categoriesData, valuesData);
series1.setTitle(series[0], chart.setSheetTitle(series[0], 0));
XDDFChartData.Series series2 = bar.addSeries(categoriesData, valuesData2);

View File

@ -52,7 +52,7 @@ public class XDDFLinearShadeProperties {
}
}
public Boolean getScaled() {
public Boolean isScaled() {
if (props.isSetScaled()) {
return props.getScaled();
} else {

View File

@ -0,0 +1,48 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xddf.usermodel.chart;
import java.util.HashMap;
import org.openxmlformats.schemas.drawingml.x2006.chart.STShape;
public enum Shape {
BOX(STShape.BOX),
CONE(STShape.CONE),
CONE_TO_MAX(STShape.CONE_TO_MAX),
CYLINDER(STShape.CYLINDER),
PYRAMID(STShape.PYRAMID),
PYRAMID_TO_MAX(STShape.PYRAMID_TO_MAX);
final STShape.Enum underlying;
Shape(STShape.Enum grouping) {
this.underlying = grouping;
}
private final static HashMap<STShape.Enum, Shape> reverse = new HashMap<>();
static {
for (Shape value : values()) {
reverse.put(value.underlying, value);
}
}
static Shape valueOf(STShape.Enum grouping) {
return reverse.get(grouping);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTArea3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
@ -52,26 +53,70 @@ public class XDDFArea3DChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public Grouping getGrouping() {
if (chart.isSetGrouping()) {
return Grouping.valueOf(chart.getGrouping().getVal());
} else {
return null;
}
}
public void setGrouping(Grouping grouping) {
if (chart.getGrouping() != null) {
if (grouping == null) {
if (chart.isSetGrouping()) {
chart.unsetGrouping();
}
} else {
if (chart.isSetGrouping()) {
chart.getGrouping().setVal(grouping.underlying);
} else {
chart.addNewGrouping().setVal(grouping.underlying);
}
}
}
public Integer getGapDepth() {
if (chart.isSetGapDepth()) {
return chart.getGapDepth().getVal();
} else {
return null;
}
}
public void setGapDepth(Integer depth) {
if (depth == null) {
if (chart.isSetGapDepth()) {
chart.unsetGapDepth();
}
} else {
if (chart.isSetGapDepth()) {
chart.getGapDepth().setVal(depth);
} else {
chart.addNewGapDepth().setVal(depth);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -157,12 +202,12 @@ public class XDDFArea3DChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,13 +20,11 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineSer;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTMarker;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
@ -55,26 +53,48 @@ public class XDDFAreaChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public Grouping getGrouping() {
if (chart.isSetGrouping()) {
return Grouping.valueOf(chart.getGrouping().getVal());
} else {
return null;
}
}
public void setGrouping(Grouping grouping) {
if (chart.getGrouping() != null) {
if (grouping == null) {
if (chart.isSetGrouping()) {
chart.unsetGrouping();
}
} else {
if (chart.isSetGrouping()) {
chart.getGrouping().setVal(grouping.underlying);
} else {
chart.addNewGrouping().setVal(grouping.underlying);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -160,12 +180,12 @@ public class XDDFAreaChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBar3DChart;
@ -55,14 +56,26 @@ public class XDDFBar3DChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public BarDirection getBarDirection() {
return BarDirection.valueOf(chart.getBarDir().getVal());
@ -76,33 +89,89 @@ public class XDDFBar3DChartData extends XDDFChartData {
if (chart.isSetGrouping()) {
return BarGrouping.valueOf(chart.getGrouping().getVal());
} else {
return BarGrouping.STANDARD;
return null;
}
}
public void setBarGrouping(BarGrouping grouping) {
if (grouping == null) {
if (chart.isSetGrouping()) {
chart.unsetGrouping();
}
} else {
if (chart.isSetGrouping()) {
chart.getGrouping().setVal(grouping.underlying);
} else {
chart.addNewGrouping().setVal(grouping.underlying);
}
}
}
public int getGapWidth() {
public Integer getGapDepth() {
if (chart.isSetGapDepth()) {
return chart.getGapDepth().getVal();
} else {
return null;
}
}
public void setGapDepth(Integer depth) {
if (depth == null) {
if (chart.isSetGapDepth()) {
chart.unsetGapDepth();
}
} else {
if (chart.isSetGapDepth()) {
chart.getGapDepth().setVal(depth);
} else {
chart.addNewGapDepth().setVal(depth);
}
}
}
public Integer getGapWidth() {
if (chart.isSetGapWidth()) {
return chart.getGapWidth().getVal();
} else {
return 0;
return null;
}
}
public void setGapWidth(int width) {
public void setGapWidth(Integer width) {
if (width == null) {
if (chart.isSetGapWidth()) {
chart.unsetGapWidth();
}
} else {
if (chart.isSetGapWidth()) {
chart.getGapWidth().setVal(width);
} else {
chart.addNewGapWidth().setVal(width);
}
}
}
public Shape getShape() {
if (chart.isSetShape()) {
return Shape.valueOf(chart.getShape().getVal());
} else {
return null;
}
}
public void setShape(Shape shape) {
if (shape == null) {
if (chart.isSetShape()) {
chart.unsetShape();
}
} else {
if (chart.isSetShape()) {
chart.getShape().setVal(shape.underlying);
} else {
chart.addNewShape().setVal(shape.underlying);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -189,12 +258,12 @@ public class XDDFBar3DChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
@ -55,14 +56,26 @@ public class XDDFBarChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public BarDirection getBarDirection() {
return BarDirection.valueOf(chart.getBarDir().getVal());
@ -76,33 +89,76 @@ public class XDDFBarChartData extends XDDFChartData {
if (chart.isSetGrouping()) {
return BarGrouping.valueOf(chart.getGrouping().getVal());
} else {
return BarGrouping.STANDARD;
return null;
}
}
public void setBarGrouping(BarGrouping grouping) {
if (grouping == null) {
if (chart.isSetGrouping()) {
chart.unsetGrouping();
}
} else {
if (chart.isSetGrouping()) {
chart.getGrouping().setVal(grouping.underlying);
} else {
chart.addNewGrouping().setVal(grouping.underlying);
}
}
}
public int getGapWidth() {
public Integer getGapWidth() {
if (chart.isSetGapWidth()) {
return chart.getGapWidth().getVal();
} else {
return 0;
return null;
}
}
public void setGapWidth(int width) {
public void setGapWidth(Integer width) {
if (width == null) {
if (chart.isSetGapWidth()) {
chart.unsetGapWidth();
}
} else {
if (chart.isSetGapWidth()) {
chart.getGapWidth().setVal(width);
} else {
chart.addNewGapWidth().setVal(width);
}
}
}
public Byte getOverlap() {
if (chart.isSetOverlap()) {
return chart.getOverlap().getVal();
} else {
return null;
}
}
/**
* Minimum inclusive: -100
* <br/>
* Maximum inclusive: 100
* @param overlap
*/
public void setOverlap(Byte overlap) {
if (overlap == null) {
if (chart.isSetOverlap()) {
chart.unsetOverlap();
}
} else {
if (overlap < -100 || 100 < overlap) {
return;
}
if (chart.isSetOverlap()) {
chart.getOverlap().setVal(overlap);
} else {
chart.addNewOverlap().setVal(overlap);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -189,13 +245,13 @@ public class XDDFBarChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
series.getIdx().setVal(val);
protected void setIndex(long index) {
series.getIdx().setVal(index);
}
@Override
public void updateOrderVal(long val) {
series.getOrder().setVal(val);
protected void setOrder(long order) {
series.getOrder().setVal(order);
}
}
}

View File

@ -57,19 +57,26 @@ import org.apache.poi.xssf.usermodel.XSSFTable;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTArea3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBar3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTChartSpace;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTDateAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLine3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPie3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPlotArea;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTRadarChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTScatterChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface3DChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceChart;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
@ -390,21 +397,46 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
Map<Long, XDDFChartAxis> categories = getCategoryAxes();
Map<Long, XDDFValueAxis> values = getValueAxes();
for (int i = 0; i < plotArea.sizeOfAreaChartArray(); i++) {
CTAreaChart areaChart = plotArea.getAreaChartArray(i);
series.add(new XDDFAreaChartData(areaChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfArea3DChartArray(); i++) {
CTArea3DChart areaChart = plotArea.getArea3DChartArray(i);
series.add(new XDDFArea3DChartData(areaChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfBarChartArray(); i++) {
CTBarChart barChart = plotArea.getBarChartArray(i);
series.add(new XDDFBarChartData(barChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfBar3DChartArray(); i++) {
CTBar3DChart barChart = plotArea.getBar3DChartArray(i);
series.add(new XDDFBar3DChartData(barChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfLineChartArray(); i++) {
CTLineChart lineChart = plotArea.getLineChartArray(i);
series.add(new XDDFLineChartData(lineChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfLine3DChartArray(); i++) {
CTLine3DChart lineChart = plotArea.getLine3DChartArray(i);
series.add(new XDDFLine3DChartData(lineChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfPieChartArray(); i++) {
CTPieChart pieChart = plotArea.getPieChartArray(i);
series.add(new XDDFPieChartData(pieChart));
}
for (int i = 0; i < plotArea.sizeOfPie3DChartArray(); i++) {
CTPie3DChart pieChart = plotArea.getPie3DChartArray(i);
series.add(new XDDFPie3DChartData(pieChart));
}
for (int i = 0; i < plotArea.sizeOfRadarChartArray(); i++) {
CTRadarChart radarChart = plotArea.getRadarChartArray(i);
series.add(new XDDFRadarChartData(radarChart, categories, values));
@ -415,7 +447,17 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
series.add(new XDDFScatterChartData(scatterChart, categories, values));
}
// TODO repeat above code for all kind of charts
for (int i = 0; i < plotArea.sizeOfSurfaceChartArray(); i++) {
CTSurfaceChart surfaceChart = plotArea.getSurfaceChartArray(i);
series.add(new XDDFSurfaceChartData(surfaceChart, categories, values));
}
for (int i = 0; i < plotArea.sizeOfSurface3DChartArray(); i++) {
CTSurface3DChart surfaceChart = plotArea.getSurface3DChartArray(i);
series.add(new XDDFSurface3DChartData(surfaceChart, categories, values));
}
// TODO repeat above code for missing charts: Bubble, Doughnut, OfPie and Stock
return series;
}
@ -503,8 +545,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
Map<Long, XDDFChartAxis> categories = null;
Map<Long, XDDFValueAxis> mapValues = null;
if(ChartTypes.PIE != type && ChartTypes.PIE3D != type)
{
if (ChartTypes.PIE != type && ChartTypes.PIE3D != type) {
categories = Collections.singletonMap(category.getId(), category);
mapValues = Collections.singletonMap(values.getId(), values);
}

View File

@ -20,10 +20,12 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumData;
@ -75,11 +77,62 @@ public abstract class XDDFChartData {
return valueAxes;
}
/**
* Calls to <code>getSeries().add(series)</code> or to <code>getSeries().remove(series)</code>
* may corrupt the workbook.
*
* <p>
* Instead, use the following methods:
* <ul>
* <li>{@link #getSeriesCount()}</li>
* <li>{@link #getSeries(int)}</li>
* <li>{@link #addSeries(XDDFDataSource,XDDFNumericalDataSource)}</li>
* <li>{@link #removeSeries(int)}</li>
* </ul>
*
* @deprecated since POI 4.1.1
* @return
*/
@Deprecated
public List<Series> getSeries() {
return series;
}
public abstract void setVaryColors(boolean varyColors);
public final int getSeriesCount() {
return series.size();
}
public final Series getSeries(int n) {
return series.get(n);
}
public final void removeSeries(int n) {
final String procName = "removeSeries";
if (n < 0 || series.size() <= n) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "%s(%d): illegal index", procName, n));
}
series.remove(n);
removeCTSeries(n);
}
/**
* This method should be implemented in every class that extends <code>XDDFChartData</code>.
* <p>
* A typical implementation would be
*
* <pre><code>
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
* </code></pre>
*
* @param n
*/
@Internal
protected abstract void removeCTSeries(int n);
public abstract void setVaryColors(Boolean varyColors);
public abstract XDDFChartData.Series addSeries(XDDFDataSource<?> category,
XDDFNumericalDataSource<? extends Number> values);
@ -98,19 +151,9 @@ public abstract class XDDFChartData {
protected abstract CTNumDataSource getNumDS();
/**
* This method will update series id value
*
* @param val
*/
public abstract void updateIdXVal(long val);
protected abstract void setIndex(long index);
/**
* this method will update series order value
*
* @param val
*/
public abstract void updateOrderVal(long val);
protected abstract void setOrder(long order);
protected Series(XDDFDataSource<?> category, XDDFNumericalDataSource<? extends Number> values) {
replaceData(category, values);

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLine3DChart;
@ -53,14 +54,26 @@ public class XDDFLine3DChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public Grouping getGrouping() {
return Grouping.valueOf(chart.getGrouping().getVal());
@ -74,6 +87,28 @@ public class XDDFLine3DChartData extends XDDFChartData {
}
}
public Integer getGapDepth() {
if (chart.isSetGapDepth()) {
return chart.getGapDepth().getVal();
} else {
return null;
}
}
public void setGapDepth(Integer depth) {
if (depth == null) {
if (chart.isSetGapDepth()) {
chart.unsetGapDepth();
}
} else {
if (chart.isSetGapDepth()) {
chart.getGapDepth().setVal(depth);
} else {
chart.addNewGapDepth().setVal(depth);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
XDDFNumericalDataSource<? extends Number> values) {
@ -148,7 +183,7 @@ public class XDDFLine3DChartData extends XDDFChartData {
}
public Boolean getSmooth() {
public Boolean isSmooth() {
if (series.isSetSmooth()) {
return series.getSmooth().getVal();
} else {
@ -219,12 +254,12 @@ public class XDDFLine3DChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTLineChart;
@ -53,14 +54,26 @@ public class XDDFLineChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public Grouping getGrouping() {
return Grouping.valueOf(chart.getGrouping().getVal());
@ -150,7 +163,7 @@ public class XDDFLineChartData extends XDDFChartData {
/**
* @since 4.0.1
*/
public Boolean getSmooth() {
public Boolean isSmooth() {
if (series.isSetSmooth()) {
return series.getSmooth().getVal();
} else {
@ -221,12 +234,12 @@ public class XDDFLineChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.poi.xddf.usermodel.chart;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
@ -36,14 +37,26 @@ public class XDDFPie3DChartData extends XDDFChartData {
}
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -118,21 +131,27 @@ public class XDDFPie3DChartData extends XDDFChartData {
}
}
public long getExplosion() {
public Long getExplosion() {
if (series.isSetExplosion()) {
return series.getExplosion().getVal();
} else {
return 0;
return null;
}
}
public void setExplosion(long explosion) {
public void setExplosion(Long explosion) {
if (explosion == null) {
if (series.isSetExplosion()) {
series.unsetExplosion();
}
} else {
if (series.isSetExplosion()) {
series.getExplosion().setVal(explosion);
} else {
series.addNewExplosion().setVal(explosion);
}
}
}
@Override
protected CTAxDataSource getAxDS() {
@ -145,12 +164,12 @@ public class XDDFPie3DChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -18,6 +18,7 @@
package org.apache.poi.xddf.usermodel.chart;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
@ -36,14 +37,51 @@ public class XDDFPieChartData extends XDDFChartData {
}
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public Integer getFirstSliceAngle() {
if (chart.isSetFirstSliceAng()) {
return chart.getFirstSliceAng().getVal();
} else {
return null;
}
}
public void setFirstSliceAngle(Integer angle) {
if (angle == null) {
if (chart.isSetFirstSliceAng()) {
chart.unsetFirstSliceAng();
}
} else {
if (angle < 0 || 360 < angle) {
throw new IllegalArgumentException("angle must be between 0 and 360");
}
if (chart.isSetFirstSliceAng()) {
chart.getFirstSliceAng().setVal(angle);
} else {
chart.addNewFirstSliceAng().setVal(angle);
}
}
}
@Override
public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@ -118,21 +156,27 @@ public class XDDFPieChartData extends XDDFChartData {
}
}
public long getExplosion() {
public Long getExplosion() {
if (series.isSetExplosion()) {
return series.getExplosion().getVal();
} else {
return 0;
return null;
}
}
public void setExplosion(long explosion) {
public void setExplosion(Long explosion) {
if (explosion == null) {
if (series.isSetExplosion()) {
series.unsetExplosion();
}
} else {
if (series.isSetExplosion()) {
series.getExplosion().setVal(explosion);
} else {
series.addNewExplosion().setVal(explosion);
}
}
}
@Override
protected CTAxDataSource getAxDS() {
@ -145,12 +189,12 @@ public class XDDFPieChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
@ -53,14 +54,26 @@ public class XDDFRadarChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public RadarStyle getStyle() {
return RadarStyle.valueOf(chart.getRadarStyle().getVal());
@ -158,12 +171,12 @@ public class XDDFRadarChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTMarker;
@ -54,14 +55,26 @@ public class XDDFScatterChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
@Internal
@Override
public void setVaryColors(boolean varyColors) {
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
@Override
public void setVaryColors(Boolean varyColors) {
if (varyColors == null) {
if (chart.isSetVaryColors()) {
chart.unsetVaryColors();
}
} else {
if (chart.isSetVaryColors()) {
chart.getVaryColors().setVal(varyColors);
} else {
chart.addNewVaryColors().setVal(varyColors);
}
}
}
public ScatterStyle getStyle() {
CTScatterStyle scatterStyle = chart.getScatterStyle();
@ -119,7 +132,7 @@ public class XDDFScatterChartData extends XDDFChartData {
/**
* @since 4.0.1
*/
public Boolean getSmooth() {
public Boolean isSmooth() {
if (series.isSetSmooth()) {
return series.getSmooth().getVal();
} else {
@ -230,12 +243,12 @@ public class XDDFScatterChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,9 +20,9 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface3DChart;
@ -53,32 +53,44 @@ public class XDDFSurface3DChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
public void setSeriesAxisId(XDDFSeriesAxis seriesAxis) {
chart.addNewAxId().setVal(seriesAxis.getId());
}
public CTBoolean getWireframe() {
if (chart.isSetWireframe()) {
return chart.getWireframe();
} else {
return chart.addNewWireframe();
}
}
public void setWireframe(boolean val) {
if (chart.isSetWireframe()) {
chart.getWireframe().setVal(val);
} else {
chart.addNewWireframe().setVal(val);
}
@Internal
@Override
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
/**
* Surface chart is not supporting vary color property
* Surface chart is not supporting vary color property.
*/
@Override
public void setVaryColors(boolean varyColors) {
public void setVaryColors(Boolean varyColors) {
// nothing to do
}
public void defineSeriesAxis(XDDFSeriesAxis seriesAxis) {
chart.addNewAxId().setVal(seriesAxis.getId());
}
public Boolean isWireframe() {
if (chart.isSetWireframe()) {
return chart.getWireframe().getVal();
} else {
return null;
}
}
public void setWireframe(Boolean show) {
if (show == null) {
if (chart.isSetWireframe()) {
chart.unsetWireframe();
}
} else {
if (chart.isSetWireframe()) {
chart.getWireframe().setVal(show);
} else {
chart.addNewWireframe().setVal(show);
}
}
}
@Override
@ -119,11 +131,11 @@ public class XDDFSurface3DChartData extends XDDFChartData {
}
/**
* Surface chart is not supporting vary show leader lines property
* Surface chart is not supporting show leader lines property
*/
@Override
public void setShowLeaderLines(boolean showLeaderLines) {
// nothing to do
}
@Override
@ -161,12 +173,12 @@ public class XDDFSurface3DChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -20,9 +20,9 @@ package org.apache.poi.xddf.usermodel.chart;
import java.util.Map;
import org.apache.poi.util.Beta;
import org.apache.poi.util.Internal;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceChart;
@ -31,7 +31,6 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceSer;
@Beta
public class XDDFSurfaceChartData extends XDDFChartData {
private CTSurfaceChart chart;
public XDDFSurfaceChartData(CTSurfaceChart chart, Map<Long, XDDFChartAxis> categories,
Map<Long, XDDFValueAxis> values) {
this.chart = chart;
@ -40,6 +39,7 @@ public class XDDFSurfaceChartData extends XDDFChartData {
}
defineAxes(categories, values);
}
private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
if (chart.sizeOfAxIdArray() == 0) {
for (Long id : categories.keySet()) {
@ -52,32 +52,44 @@ public class XDDFSurfaceChartData extends XDDFChartData {
defineAxes(chart.getAxIdArray(), categories, values);
}
public void setSeriesAxisId(XDDFSeriesAxis seriesAxis) {
chart.addNewAxId().setVal(seriesAxis.getId());
}
public CTBoolean getWireframe() {
if (chart.isSetWireframe()) {
return chart.getWireframe();
} else {
return chart.addNewWireframe();
}
}
public void setWireframe(boolean val) {
if (chart.isSetWireframe()) {
chart.getWireframe().setVal(val);
} else {
chart.addNewWireframe().setVal(val);
}
@Internal
@Override
protected void removeCTSeries(int n) {
chart.removeSer(n);
}
/**
* Surface chart is not supporting vary color property
* Surface chart is not supporting vary color property.
*/
@Override
public void setVaryColors(boolean varyColors) {
public void setVaryColors(Boolean varyColors) {
// nothing to do
}
public void defineSeriesAxis(XDDFSeriesAxis seriesAxis) {
chart.addNewAxId().setVal(seriesAxis.getId());
}
public Boolean isWireframe() {
if (chart.isSetWireframe()) {
return chart.getWireframe().getVal();
} else {
return null;
}
}
public void setWireframe(Boolean show) {
if (show == null) {
if (chart.isSetWireframe()) {
chart.unsetWireframe();
}
} else {
if (chart.isSetWireframe()) {
chart.getWireframe().setVal(show);
} else {
chart.addNewWireframe().setVal(show);
}
}
}
@Override
@ -118,11 +130,11 @@ public class XDDFSurfaceChartData extends XDDFChartData {
}
/**
* Surface chart is not supporting vary show leader lines property
* Surface chart is not supporting show leader lines property
*/
@Override
public void setShowLeaderLines(boolean showLeaderLines) {
// nothing to do
}
@Override
@ -160,12 +172,12 @@ public class XDDFSurfaceChartData extends XDDFChartData {
}
@Override
public void updateIdXVal(long val) {
public void setIndex(long val) {
series.getIdx().setVal(val);
}
@Override
public void updateOrderVal(long val) {
public void setOrder(long val) {
series.getOrder().setVal(val);
}
}

View File

@ -19,85 +19,162 @@
package org.apache.poi.xddf.usermodel.chart;
import org.apache.poi.util.Internal;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
public class XDDFView3D {
private final CTView3D view3D;
public XDDFView3D(CTView3D view3D) {
@Internal
protected XDDFView3D(CTView3D view3D) {
this.view3D = view3D;
}
public int getXRotationAngle() {
public Byte getXRotationAngle() {
if (view3D.isSetRotX()) {
return view3D.getRotX().getVal();
}
public void setXRotationAngle(int val) {
if (view3D.isSetRotY()) {
view3D.getRotY().setVal(val);
} else {
view3D.addNewRotY().setVal(val);
return null;
}
}
public int getYRotationAngle() {
public void setXRotationAngle(Byte rotation) {
if (rotation == null) {
if (view3D.isSetRotX()) {
view3D.unsetRotX();
}
} else {
if (rotation < -90 || 90 < rotation) {
throw new IllegalArgumentException("rotation must be between -90 and 90");
}
if (view3D.isSetRotX()) {
view3D.getRotX().setVal(rotation);
} else {
view3D.addNewRotX().setVal(rotation);
}
}
}
public Integer getYRotationAngle() {
if (view3D.isSetRotY()) {
return view3D.getRotY().getVal();
} else {
return null;
}
}
public void setYRotationAngle(int val) {
public void setYRotationAngle(Integer rotation) {
if (rotation == null) {
if (view3D.isSetRotY()) {
view3D.getRotY().setVal(val);
view3D.unsetRotY();
}
} else {
view3D.addNewRotY().setVal(val);
if (rotation < 0 || 360 < rotation) {
throw new IllegalArgumentException("rotation must be between 0 and 360");
}
if (view3D.isSetRotY()) {
view3D.getRotY().setVal(rotation);
} else {
view3D.addNewRotY().setVal(rotation);
}
}
}
public boolean getRightAngleAxes() {
return view3D.getRAngAx().getVal();
}
public void setRightAngleAxes(boolean val) {
public Boolean hasRightAngleAxes() {
if (view3D.isSetRAngAx()) {
view3D.getRAngAx().setVal(val);
return view3D.getRAngAx().getVal();
} else {
view3D.addNewRAngAx().setVal(val);
return null;
}
}
public short getPerspectiveAngle() {
return view3D.getPerspective().getVal();
public void setRightAngleAxes(Boolean rightAngles) {
if (rightAngles == null) {
if (view3D.isSetRAngAx()) {
view3D.unsetRAngAx();
}
} else {
if (view3D.isSetRAngAx()) {
view3D.getRAngAx().setVal(rightAngles);
} else {
view3D.addNewRAngAx().setVal(rightAngles);
}
}
}
public void setPerspectiveAngle(short val) {
public Short getPerspectiveAngle() {
if (view3D.isSetPerspective()) {
view3D.getPerspective().setVal(val);
return view3D.getPerspective().getVal();
} else {
view3D.addNewPerspective().setVal(val);
return null;
}
}
public int getDepthPercentVal() {
return view3D.getDepthPercent().getVal();
public void setPerspectiveAngle(Short perspective) {
if (perspective == null) {
if (view3D.isSetPerspective()) {
view3D.unsetPerspective();
}
} else {
if (perspective < 0 || 240 < perspective) {
throw new IllegalArgumentException("perspective must be between 0 and 240");
}
if (view3D.isSetPerspective()) {
view3D.getPerspective().setVal(perspective);
} else {
view3D.addNewPerspective().setVal(perspective);
}
}
}
public void setDepthPercent(int val) {
public Integer getDepthPercent() {
if (view3D.isSetDepthPercent()) {
view3D.getDepthPercent().setVal(val);
return view3D.getDepthPercent().getVal();
} else {
view3D.addNewDepthPercent().setVal(val);
return null;
}
}
public int getHeightPercent() {
return view3D.getHPercent().getVal();
public void setDepthPercent(Integer percent) {
if (percent == null) {
if (view3D.isSetDepthPercent()) {
view3D.unsetDepthPercent();
}
} else {
if (percent < 20 || 2000 < percent) {
throw new IllegalArgumentException("percent must be between 20 and 2000");
}
if (view3D.isSetDepthPercent()) {
view3D.getDepthPercent().setVal(percent);
} else {
view3D.addNewDepthPercent().setVal(percent);
}
}
}
public void setHeightPercent(int val) {
public Integer getHPercent() {
if (view3D.isSetHPercent()) {
view3D.getHPercent().setVal(val);
return view3D.getHPercent().getVal();
} else {
view3D.addNewHPercent().setVal(val);
return null;
}
}
public void setHPercent(Integer percent) {
if (percent == null) {
if (view3D.isSetHPercent()) {
view3D.unsetHPercent();
}
} else {
if (percent < 5 || 500 < percent) {
throw new IllegalArgumentException("percent must be between 5 and 500");
}
if (view3D.isSetHPercent()) {
view3D.getHPercent().setVal(percent);
} else {
view3D.addNewHPercent().setVal(percent);
}
}
}
}

View File

@ -67,9 +67,9 @@ public class TestXSLFChart {
List<XDDFChartData> data = findChartData(chart);
XDDFPieChartData pie = (XDDFPieChartData) data.get(0);
XDDFPieChartData.Series firstSeries = (XDDFPieChartData.Series) pie.getSeries().get(0);
firstSeries.setExplosion(25);
assertEquals(25, firstSeries.getExplosion());
XDDFPieChartData.Series firstSeries = (XDDFPieChartData.Series) pie.getSeries(0);
firstSeries.setExplosion(25L);
assertEquals(Long.valueOf(25), firstSeries.getExplosion());
fillChartData(chart, pie);
pptx.close();
@ -87,7 +87,7 @@ public class TestXSLFChart {
XDDFBarChartData bar = (XDDFBarChartData) data.get(0);
assertEquals(BarDirection.BAR, bar.getBarDirection());
assertEquals(BarGrouping.CLUSTERED, bar.getBarGrouping());
assertEquals(100, bar.getGapWidth());
assertEquals(Integer.valueOf(100), bar.getGapWidth());
fillChartData(chart, bar);
XDDFBarChartData column = (XDDFBarChartData) findChartData(chart2).get(0);
@ -153,7 +153,7 @@ public class TestXSLFChart {
final String categoryDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, 0, 0));
final String valuesDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, 1, 1));
final XDDFChartData.Series series = data.getSeries().get(0);
final XDDFChartData.Series series = data.getSeries(0);
final XDDFDataSource<?> categoryData = XDDFDataSourcesFactory.fromArray(categories, categoryDataRange);
final XDDFNumericalDataSource<Integer> valuesData = XDDFDataSourcesFactory.fromArray(values, valuesDataRange);
series.replaceData(categoryData, valuesData);

View File

@ -713,7 +713,7 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook {
assertNotNull(read);
assertSheetOrder(read, "Sheet1-Renamed", "Sheet2", "Sheet3");
XSSFSheet sheet = (XSSFSheet) read.getSheet("Sheet1-Renamed");
XDDFChartData.Series series = sheet.getDrawingPatriarch().getCharts().get(0).getChartSeries().get(0).getSeries().get(0);
XDDFChartData.Series series = sheet.getDrawingPatriarch().getCharts().get(0).getChartSeries().get(0).getSeries(0);
assertTrue("should be a bar chart data series", series instanceof XDDFBarChartData.Series);
String formula = ((XDDFBarChartData.Series) series).getCategoryData().getFormula();
assertTrue("should contain new sheet name", formula.startsWith("'Sheet1-Renamed'!"));