]> source.dussan.org Git - poi.git/commitdiff
Added more chart supports.
authorAlain Béarez <abearez@apache.org>
Tue, 21 May 2019 00:13:28 +0000 (00:13 +0000)
committerAlain Béarez <abearez@apache.org>
Tue, 21 May 2019 00:13:28 +0000 (00:13 +0000)
fixed bug while creating chart with bar and line series.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1859589 13f79535-47bb-0310-9956-ffa450edef68

17 files changed:
src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/ChartTypes.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFArea3DChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFAreaChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBar3DChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBarChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLine3DChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLineChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPie3DChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPieChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFRadarChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFScatterChartData.java
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurface3DChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurfaceChartData.java [new file with mode: 0644]
src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java [new file with mode: 0644]

index 1de43cb974342f6abf5eaaedf93a6daed4ca4229..f674a37a38adc0b3fb290e06694ddeb39bcf0dd2 100644 (file)
@@ -134,17 +134,26 @@ public class BarAndLineChart {
             lineCategories.crossAxis(rightValues);
 
             // the bar chart
-            XDDFBarChartData bar = (XDDFBarChartData) chart.createData(ChartTypes.BAR, lineCategories, rightValues);
+            XDDFBarChartData bar = (XDDFBarChartData) chart.createData(ChartTypes.BAR, barCategories, leftValues);
             XDDFBarChartData.Series series1 = (XDDFBarChartData.Series) bar.addSeries(xs, ys1);
             series1.setTitle("Bars", new CellReference("Sheet1!$B$1"));
             bar.setVaryColors(true);
             bar.setBarDirection(BarDirection.COL);
             chart.plot(bar);
 
-            // the line chart
+            // the line chart on secondary axis
             XDDFLineChartData lines = (XDDFLineChartData) chart.createData(ChartTypes.LINE, lineCategories,
                     rightValues);
+            
+            //uncomment below line if only primary axis required and comment above line 
+            // the line chart on primary axis
+            /*XDDFLineChartData lines = (XDDFLineChartData) chart.createData(ChartTypes.LINE, lineCategories,
+                    leftValues);*/
+            
+            
             XDDFLineChartData.Series series2 = (XDDFLineChartData.Series) lines.addSeries(xs, ys2);
+            series2.updateIdXVal(1);
+            series2.updateOrderVal(1);
             series2.setTitle("Lines", new CellReference("Sheet1!$C$1"));
             lines.setVaryColors(true);
             chart.plot(lines);
index 7ecaab06993c86d8e283dab950498f110575bec6..fcec7619331eb17f5f115ef77b1f56491bcb7dc9 100644 (file)
 package org.apache.poi.xddf.usermodel.chart;
 
 public enum ChartTypes {
+    AREA,
+    AREA3D,
     BAR,
+    BAR3D,
     LINE,
+    LINE3D,
     PIE,
+    PIE3D,
     RADAR,
-    SCATTER
+    SCATTER,
+    SURFACE,
+    SURFACE3D
 }
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFArea3DChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFArea3DChartData.java
new file mode 100644 (file)
index 0000000..28ccea3
--- /dev/null
@@ -0,0 +1,169 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTArea3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAreaSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFArea3DChartData extends XDDFChartData {
+    private CTArea3DChart chart;
+
+    public XDDFArea3DChartData(CTArea3DChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        for (CTAreaSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        defineAxes(chart.getAxIdArray(), categories, values);
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    public Grouping getGrouping() {
+        return Grouping.valueOf(chart.getGrouping().getVal());
+    }
+
+   public void setGrouping(Grouping grouping) {
+      if (chart.getGrouping() != null) {
+         chart.getGrouping().setVal(grouping.underlying);
+      } else {
+         chart.addNewGrouping().setVal(grouping.underlying);
+      }
+   }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTAreaSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTAreaSer series;
+
+        protected Series(CTAreaSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTAreaSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFAreaChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFAreaChartData.java
new file mode 100644 (file)
index 0000000..e04d1e4
--- /dev/null
@@ -0,0 +1,172 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+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;
+
+@Beta
+public class XDDFAreaChartData extends XDDFChartData {
+    private CTAreaChart chart;
+
+    public XDDFAreaChartData(CTAreaChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        for (CTAreaSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        defineAxes(chart.getAxIdArray(), categories, values);
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    public Grouping getGrouping() {
+        return Grouping.valueOf(chart.getGrouping().getVal());
+    }
+
+   public void setGrouping(Grouping grouping) {
+      if (chart.getGrouping() != null) {
+         chart.getGrouping().setVal(grouping.underlying);
+      } else {
+         chart.addNewGrouping().setVal(grouping.underlying);
+      }
+   }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTAreaSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTAreaSer series;
+
+        protected Series(CTAreaSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTAreaSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBar3DChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFBar3DChartData.java
new file mode 100644 (file)
index 0000000..1254384
--- /dev/null
@@ -0,0 +1,201 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBar3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBarSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFBar3DChartData extends XDDFChartData {
+    private CTBar3DChart chart;
+
+    public XDDFBar3DChartData(CTBar3DChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        if (chart.getBarDir() == null) {
+            chart.addNewBarDir().setVal(BarDirection.BAR.underlying);
+        }
+        for (CTBarSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        defineAxes(chart.getAxIdArray(), categories, values);
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    public BarDirection getBarDirection() {
+        return BarDirection.valueOf(chart.getBarDir().getVal());
+    }
+
+    public void setBarDirection(BarDirection direction) {
+        chart.getBarDir().setVal(direction.underlying);
+    }
+
+    public BarGrouping getBarGrouping() {
+        if (chart.isSetGrouping()) {
+            return BarGrouping.valueOf(chart.getGrouping().getVal());
+        } else {
+            return BarGrouping.STANDARD;
+        }
+    }
+
+    public void setBarGrouping(BarGrouping grouping) {
+        if (chart.isSetGrouping()) {
+            chart.getGrouping().setVal(grouping.underlying);
+        } else {
+            chart.addNewGrouping().setVal(grouping.underlying);
+        }
+    }
+
+    public int getGapWidth() {
+        if (chart.isSetGapWidth()) {
+            return chart.getGapWidth().getVal();
+        } else {
+            return 0;
+        }
+    }
+
+    public void setGapWidth(int width) {
+        if (chart.isSetGapWidth()) {
+            chart.getGapWidth().setVal(width);
+        } else {
+            chart.addNewGapWidth().setVal(width);
+        }
+    }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTBarSer ctSer = this.chart.addNewSer();
+        ctSer.addNewTx();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTBarSer series;
+
+        protected Series(CTBarSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTBarSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
index ce79733aa85bbac87319505473e67455838048be..ee8c225265d29de62f6814e186c4f5de6600b7d6 100644 (file)
@@ -187,5 +187,15 @@ public class XDDFBarChartData extends XDDFChartData {
         protected CTNumDataSource getNumDS() {
             return series.getVal();
         }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+      @Override
+      public void updateOrderVal(long val) {
+         series.getOrder().setVal(val);
+      }
     }
 }
index e1a7b2e9d3fda9474c4a43ffaf5d7a556c119e59..65140ebbb1cd9f78ee9d72c2f735f01e8fe6fbeb 100644 (file)
@@ -72,6 +72,7 @@ import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerAx;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurface;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTTitle;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
 import org.openxmlformats.schemas.drawingml.x2006.chart.ChartSpaceDocument;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
@@ -301,6 +302,21 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
         }
     }
 
+   /**
+    * Get or Add chart 3D view into chart
+    *
+    * @return this method will add 3D view
+    */
+   public XDDFView3D getOrAddView3D() {
+      CTView3D view3D;
+      if (chart.isSetView3D()) {
+         view3D = chart.getView3D();
+      } else {
+         view3D = chart.addNewView3D();
+      }
+      return new XDDFView3D(view3D);
+   }
+
     /**
      * Get the chart title body if there is one, i.e. title is set and is not a
      * formula.
@@ -436,6 +452,23 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
         return valueAxis;
     }
 
+    /**
+     * this method will return series axis with specified position 
+     *
+     * @param pos axis position Left, Right, Top, Bottom
+     * @return series axis with specified position
+     */
+    public XDDFSeriesAxis createSeriesAxis(AxisPosition pos) {
+        XDDFSeriesAxis seriesAxis = new XDDFSeriesAxis(chart.getPlotArea(), pos);
+        if (axes.size() == 1) {
+            XDDFChartAxis axis = axes.get(0);
+            axis.crossAxis(seriesAxis);
+            seriesAxis.crossAxis(axis);
+        }
+        axes.add(seriesAxis);
+        return seriesAxis;
+    }
+
     public XDDFCategoryAxis createCategoryAxis(AxisPosition pos) {
         XDDFCategoryAxis categoryAxis = new XDDFCategoryAxis(chart.getPlotArea(), pos);
         if (axes.size() == 1) {
@@ -458,21 +491,50 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai
         return dateAxis;
     }
 
+    /**
+     * this method will return specified chart data with category and series values
+     *
+     * @param type chart type
+     * @param category category values of chart
+     * @param values series values of chart
+     * @return specified chart data.
+     */
     public XDDFChartData createData(ChartTypes type, XDDFChartAxis category, XDDFValueAxis values) {
-        Map<Long, XDDFChartAxis> categories = Collections.singletonMap(category.getId(), category);
-        Map<Long, XDDFValueAxis> mapValues = Collections.singletonMap(values.getId(), values);
+        Map<Long, XDDFChartAxis> categories = null;
+        Map<Long, XDDFValueAxis> mapValues = null;
+        
+        if(ChartTypes.PIE != type && ChartTypes.PIE3D != type)
+        {
+            categories = Collections.singletonMap(category.getId(), category);
+            mapValues = Collections.singletonMap(values.getId(), values);
+        }
+        
         final CTPlotArea plotArea = getCTPlotArea();
         switch (type) {
+        case AREA:
+            return new XDDFAreaChartData(plotArea.addNewAreaChart(), categories, mapValues);
+        case AREA3D:
+            return new XDDFArea3DChartData(plotArea.addNewArea3DChart(), categories, mapValues);
         case BAR:
             return new XDDFBarChartData(plotArea.addNewBarChart(), categories, mapValues);
+        case BAR3D:
+            return new XDDFBar3DChartData(plotArea.addNewBar3DChart(), categories, mapValues);
         case LINE:
             return new XDDFLineChartData(plotArea.addNewLineChart(), categories, mapValues);
+        case LINE3D:
+            return new XDDFLine3DChartData(plotArea.addNewLine3DChart(), categories, mapValues);
         case PIE:
             return new XDDFPieChartData(plotArea.addNewPieChart());
+        case PIE3D:
+            return new XDDFPie3DChartData(plotArea.addNewPie3DChart());
         case RADAR:
             return new XDDFRadarChartData(plotArea.addNewRadarChart(), categories, mapValues);
         case SCATTER:
             return new XDDFScatterChartData(plotArea.addNewScatterChart(), categories, mapValues);
+        case SURFACE:
+            return new XDDFSurfaceChartData(plotArea.addNewSurfaceChart(), categories, mapValues);
+        case SURFACE3D:
+            return new XDDFSurface3DChartData(plotArea.addNewSurface3DChart(), categories, mapValues);
         default:
             return null;
         }
index e23b51a46ca8cdb5aa928ea494fbbd91ce7b4891..66753f0aa59cecab8c1601c2092b690359c63e6e 100644 (file)
@@ -98,6 +98,20 @@ public abstract class XDDFChartData {
 
         protected abstract CTNumDataSource getNumDS();
 
+      /**
+       * This method will update series id value
+       *
+       * @param val
+       */
+      public abstract void updateIdXVal(long val);
+
+      /**
+       * this method will update series order value
+       *
+       * @param val
+       */
+      public abstract void updateOrderVal(long val);
+
         protected Series(XDDFDataSource<?> category, XDDFNumericalDataSource<? extends Number> values) {
             replaceData(category, values);
         }
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLine3DChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFLine3DChartData.java
new file mode 100644 (file)
index 0000000..6b95566
--- /dev/null
@@ -0,0 +1,231 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTLine3DChart;
+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;
+
+@Beta
+public class XDDFLine3DChartData extends XDDFChartData {
+    private CTLine3DChart chart;
+
+    public XDDFLine3DChartData(CTLine3DChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        for (CTLineSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        defineAxes(chart.getAxIdArray(), categories, values);
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    public Grouping getGrouping() {
+        return Grouping.valueOf(chart.getGrouping().getVal());
+    }
+
+   public void setGrouping(Grouping grouping) {
+      if (chart.getGrouping() != null) {
+         chart.getGrouping().setVal(grouping.underlying);
+      } else {
+         chart.addNewGrouping().setVal(grouping.underlying);
+      }
+   }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTLineSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTLineSer series;
+
+        protected Series(CTLineSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTLineSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+
+        public Boolean getSmooth() {
+            if (series.isSetSmooth()) {
+                return series.getSmooth().getVal();
+            } else {
+                return null;
+            }
+        }
+
+        /**
+         * @param smooth
+         *        whether or not to smooth lines, if <code>null</code> then reverts to default.
+         *
+         */
+        public void setSmooth(Boolean smooth) {
+            if (smooth == null) {
+                if (series.isSetSmooth()) {
+                    series.unsetSmooth();
+                }
+            } else {
+                if (series.isSetSmooth()) {
+                    series.getSmooth().setVal(smooth);
+                } else {
+                    series.addNewSmooth().setVal(smooth);
+                }
+            }
+        }
+
+        /**
+         * @param size
+         * <dl><dt>Minimum inclusive:</dt><dd>2</dd><dt>Maximum inclusive:</dt><dd>72</dd></dl>
+         */
+        public void setMarkerSize(short size) {
+            if (size < 2 || 72 < size) {
+                throw new IllegalArgumentException("Minimum inclusive: 2; Maximum inclusive: 72");
+            }
+            CTMarker marker = getMarker();
+            if (marker.isSetSize()) {
+                marker.getSize().setVal(size);
+            } else {
+                marker.addNewSize().setVal(size);
+            }
+        }
+
+        public void setMarkerStyle(MarkerStyle style) {
+            CTMarker marker = getMarker();
+            if (marker.isSetSymbol()) {
+                marker.getSymbol().setVal(style.underlying);
+            } else {
+                marker.addNewSymbol().setVal(style.underlying);
+            }
+        }
+
+        private CTMarker getMarker() {
+            if (series.isSetMarker()) {
+                return series.getMarker();
+            } else {
+                return series.addNewMarker();
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
index 4d4f00ce9ae9faefd532258fd74a3d77c8cd9098..32bd02259271e8717fddb4c82330da29154885ab 100644 (file)
@@ -66,9 +66,13 @@ public class XDDFLineChartData extends XDDFChartData {
         return Grouping.valueOf(chart.getGrouping().getVal());
     }
 
-    public void setGrouping(Grouping grouping) {
-        chart.getGrouping().setVal(grouping.underlying);
-    }
+   public void setGrouping(Grouping grouping) {
+      if (chart.getGrouping() != null) {
+         chart.getGrouping().setVal(grouping.underlying);
+      } else {
+         chart.addNewGrouping().setVal(grouping.underlying);
+      }
+   }
 
     @Override
     public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
@@ -215,5 +219,15 @@ public class XDDFLineChartData extends XDDFChartData {
         protected CTNumDataSource getNumDS() {
             return series.getVal();
         }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
     }
 }
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPie3DChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFPie3DChartData.java
new file mode 100644 (file)
index 0000000..7f7ce53
--- /dev/null
@@ -0,0 +1,157 @@
+/* ====================================================================
+   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 org.apache.poi.util.Beta;
+import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumDataSource;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPie3DChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+@Beta
+public class XDDFPie3DChartData extends XDDFChartData {
+    private CTPie3DChart chart;
+
+    public XDDFPie3DChartData(CTPie3DChart chart) {
+        this.chart = chart;
+        for (CTPieSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+    }
+
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        if (chart.isSetVaryColors()) {
+            chart.getVaryColors().setVal(varyColors);
+        } else {
+            chart.addNewVaryColors().setVal(varyColors);
+        }
+    }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTPieSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTPieSer series;
+
+        protected Series(CTPieSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTPieSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+        @Override
+        public void setShowLeaderLines(boolean showLeaderLines) {
+            if (!series.isSetDLbls()) {
+                series.addNewDLbls();
+            }
+            if (series.getDLbls().isSetShowLeaderLines()) {
+                series.getDLbls().getShowLeaderLines().setVal(showLeaderLines);
+            } else {
+                series.getDLbls().addNewShowLeaderLines().setVal(showLeaderLines);
+            }
+        }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        public long getExplosion() {
+            if (series.isSetExplosion()) {
+                return series.getExplosion().getVal();
+            } else {
+                return 0;
+            }
+        }
+
+        public void setExplosion(long explosion) {
+            if (series.isSetExplosion()) {
+                series.getExplosion().setVal(explosion);
+            } else {
+                series.addNewExplosion().setVal(explosion);
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
index 988b48e84cd7db626565c185e935158efea409dc..d31210da7f293068312ee12f78f416af182cac48 100644 (file)
@@ -143,5 +143,15 @@ public class XDDFPieChartData extends XDDFChartData {
         protected CTNumDataSource getNumDS() {
             return series.getVal();
         }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
     }
 }
index a7917c30f95e4864c80ba047891d5d33874ebf2c..4f494b6f2c95e35fe7f44944e3be6a584a6c3ce3 100644 (file)
@@ -156,5 +156,15 @@ public class XDDFRadarChartData extends XDDFChartData {
         protected CTNumDataSource getNumDS() {
             return series.getVal();
         }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+      @Override
+      public void updateOrderVal(long val) {
+         series.getOrder().setVal(val);
+      }
     }
 }
index eec3a3730deab2eccc749ef4e49db7f0e457ffd9..162833b85d0299064b74ca4d15db1ee673713dae 100644 (file)
@@ -228,5 +228,15 @@ public class XDDFScatterChartData extends XDDFChartData {
         protected CTNumDataSource getNumDS() {
             return series.getYVal();
         }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+      @Override
+      public void updateOrderVal(long val) {
+         series.getOrder().setVal(val);
+      }
     }
 }
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurface3DChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurface3DChartData.java
new file mode 100644 (file)
index 0000000..273a77c
--- /dev/null
@@ -0,0 +1,173 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+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;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSurfaceSer;
+
+@Beta
+public class XDDFSurface3DChartData extends XDDFChartData {
+    private CTSurface3DChart chart;
+
+    public XDDFSurface3DChartData(CTSurface3DChart chart, Map<Long, XDDFChartAxis> categories,
+            Map<Long, XDDFValueAxis> values) {
+        this.chart = chart;
+        for (CTSurfaceSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        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);
+       }
+   }
+
+    /**
+     * Surface chart is not supporting vary color property
+     */
+    @Override
+    public void setVaryColors(boolean varyColors) {
+       
+    }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTSurfaceSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTSurfaceSer series;
+
+        protected Series(CTSurfaceSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTSurfaceSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+      /**
+       * Surface chart is not supporting vary show leader lines property
+       */
+      @Override
+      public void setShowLeaderLines(boolean showLeaderLines) {
+
+      }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurfaceChartData.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFSurfaceChartData.java
new file mode 100644 (file)
index 0000000..6454522
--- /dev/null
@@ -0,0 +1,172 @@
+/* ====================================================================
+   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.Map;
+
+import org.apache.poi.util.Beta;
+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;
+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;
+        for (CTSurfaceSer series : chart.getSerList()) {
+            this.series.add(new Series(series, series.getCat(), series.getVal()));
+        }
+        defineAxes(categories, values);
+    }
+    private void defineAxes(Map<Long, XDDFChartAxis> categories, Map<Long, XDDFValueAxis> values) {
+        if (chart.sizeOfAxIdArray() == 0) {
+            for (Long id : categories.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+            for (Long id : values.keySet()) {
+                chart.addNewAxId().setVal(id);
+            }
+        }
+        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);
+       }
+   }
+
+    /**
+     * Surface chart is not supporting vary color property
+     */
+    @Override
+    public void setVaryColors(boolean varyColors) {
+        
+    }
+
+    @Override
+    public XDDFChartData.Series addSeries(XDDFDataSource<?> category,
+            XDDFNumericalDataSource<? extends Number> values) {
+        final int index = this.series.size();
+        final CTSurfaceSer ctSer = this.chart.addNewSer();
+        ctSer.addNewCat();
+        ctSer.addNewVal();
+        ctSer.addNewIdx().setVal(index);
+        ctSer.addNewOrder().setVal(index);
+        final Series added = new Series(ctSer, category, values);
+        this.series.add(added);
+        return added;
+    }
+
+    public class Series extends XDDFChartData.Series {
+        private CTSurfaceSer series;
+
+        protected Series(CTSurfaceSer series, XDDFDataSource<?> category,
+                XDDFNumericalDataSource<? extends Number> values) {
+            super(category, values);
+            this.series = series;
+        }
+
+        protected Series(CTSurfaceSer series, CTAxDataSource category, CTNumDataSource values) {
+            super(XDDFDataSourcesFactory.fromDataSource(category), XDDFDataSourcesFactory.fromDataSource(values));
+            this.series = series;
+        }
+
+        @Override
+        protected CTSerTx getSeriesText() {
+            if (series.isSetTx()) {
+                return series.getTx();
+            } else {
+                return series.addNewTx();
+            }
+        }
+
+      /**
+       * Surface chart is not supporting vary show leader lines property
+       */
+      @Override
+      public void setShowLeaderLines(boolean showLeaderLines) {
+
+      }
+
+        @Override
+        public XDDFShapeProperties getShapeProperties() {
+            if (series.isSetSpPr()) {
+                return new XDDFShapeProperties(series.getSpPr());
+            } else {
+                return null;
+            }
+        }
+
+        @Override
+        public void setShapeProperties(XDDFShapeProperties properties) {
+            if (properties == null) {
+                if (series.isSetSpPr()) {
+                    series.unsetSpPr();
+                }
+            } else {
+                if (series.isSetSpPr()) {
+                    series.setSpPr(properties.getXmlObject());
+                } else {
+                    series.addNewSpPr().set(properties.getXmlObject());
+                }
+            }
+        }
+
+        @Override
+        protected CTAxDataSource getAxDS() {
+            return series.getCat();
+        }
+
+        @Override
+        protected CTNumDataSource getNumDS() {
+            return series.getVal();
+        }
+        
+        @Override
+        public void updateIdXVal(long val) {
+            series.getIdx().setVal(val);
+        }
+        
+        @Override
+        public void updateOrderVal(long val) {
+            series.getOrder().setVal(val);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java
new file mode 100644 (file)
index 0000000..42ad2cd
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ *  ====================================================================
+ *    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 org.openxmlformats.schemas.drawingml.x2006.chart.CTView3D;
+
+
+public class XDDFView3D {
+    private final CTView3D view3D;
+
+    public XDDFView3D(CTView3D view3D) {
+        this.view3D = view3D;
+    }
+    
+    public int getXRotationAngle() {
+        return view3D.getRotX().getVal();
+    }
+    
+   public void setXRotationAngle(int val) {
+      if (view3D.isSetRotY()) {
+         view3D.getRotY().setVal(val);
+      } else {
+         view3D.addNewRotY().setVal(val);
+      }
+   }
+    
+    public int getYRotationAngle() {
+        return view3D.getRotY().getVal();
+    }
+    
+   public void setYRotationAngle(int val) {
+      if (view3D.isSetRotY()) {
+         view3D.getRotY().setVal(val);
+      } else {
+         view3D.addNewRotY().setVal(val);
+      }
+   }
+    
+    public boolean getRightAngleAxes() {
+        return view3D.getRAngAx().getVal();
+    }
+    
+   public void setRightAngleAxes(boolean val) {
+      if (view3D.isSetRAngAx()) {
+         view3D.getRAngAx().setVal(val);
+      } else {
+         view3D.addNewRAngAx().setVal(val);
+      }
+   }
+    
+    public short getPerspectiveAngle() {
+        return view3D.getPerspective().getVal();
+    }
+    
+   public void setPerspectiveAngle(short val) {
+      if (view3D.isSetPerspective()) {
+         view3D.getPerspective().setVal(val);
+      } else {
+         view3D.addNewPerspective().setVal(val);
+      }
+   }
+    
+    public int getDepthPercentVal() {
+        return view3D.getDepthPercent().getVal();
+    }
+    
+   public void setDepthPercent(int val) {
+      if (view3D.isSetDepthPercent()) {
+         view3D.getDepthPercent().setVal(val);
+      } else {
+         view3D.addNewDepthPercent().setVal(val);
+      }
+   }
+    
+    public int getHeightPercent() {
+        return view3D.getHPercent().getVal();
+    }
+    
+   public void setHeightPercent(int val) {
+      if (view3D.isSetHPercent()) {
+         view3D.getHPercent().setVal(val);
+      } else {
+         view3D.addNewHPercent().setVal(val);
+      }
+   }
+}