You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2013/11/22 19:26:11 UTC

svn commit: r1544628 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/usermodel/examples/ java/org/apache/poi/ss/usermodel/charts/ ooxml/java/org/apache/poi/xssf/usermodel/charts/ ooxml/testcases/org/apache/poi/xssf/usermodel/charts/

Author: cedricwalter
Date: Fri Nov 22 18:26:11 2013
New Revision: 1544628

URL: http://svn.apache.org/r1544628
Log:
Bug 55768: added Line charts support and setting axis tick marks, title

Added:
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSerie.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSerie.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/TitleType.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/AbstractXSSFChartSerie.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFLineChartData.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java
Modified:
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSerie.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartAxis.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartDataFactory.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFScatterChartData.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFValueAxis.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java

Added: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java (added)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,79 @@
+/* ====================================================================
+   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.xssf.usermodel.examples;
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.charts.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.FileOutputStream;
+
+/**
+ * Line chart example.
+ *
+ * @author Martin Andersson
+ */
+public class LineChart {
+
+    public static void main(String[] args) throws Exception {
+        Workbook wb = new XSSFWorkbook();
+        Sheet sheet = wb.createSheet("linechart");
+        final int NUM_OF_ROWS = 3;
+        final int NUM_OF_COLUMNS = 10;
+
+        // Create a row and put some cells in it. Rows are 0 based.
+        Row row;
+        Cell cell;
+        for (int rowIndex = 0; rowIndex < NUM_OF_ROWS; rowIndex++) {
+            row = sheet.createRow((short) rowIndex);
+            for (int colIndex = 0; colIndex < NUM_OF_COLUMNS; colIndex++) {
+                cell = row.createCell((short) colIndex);
+                cell.setCellValue(colIndex * (rowIndex + 1));
+            }
+        }
+
+        Drawing drawing = sheet.createDrawingPatriarch();
+        ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 10, 15);
+
+        Chart chart = drawing.createChart(anchor);
+        ChartLegend legend = chart.getOrCreateLegend();
+        legend.setPosition(LegendPosition.TOP_RIGHT);
+
+        LineChartData data = chart.getChartDataFactory().createLineChartData();
+
+        // Use a category axis for the bottom axis.
+        ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
+        ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
+        leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);
+
+        ChartDataSource<Number> xs = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1));
+        ChartDataSource<Number> ys1 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1));
+        ChartDataSource<Number> ys2 = DataSources.fromNumericCellRange(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1));
+
+
+        data.addSerie(xs, ys1);
+        data.addSerie(xs, ys2);
+
+        chart.plot(data, bottomAxis, leftAxis);
+
+        // Write the output to a file
+        FileOutputStream fileOut = new FileOutputStream("ooxml-line-chart.xlsx");
+        wb.write(fileOut);
+        fileOut.close();
+    }
+}

Added: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java (added)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/AxisTickMark.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,30 @@
+/* ====================================================================
+   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.ss.usermodel.charts;
+
+/**
+ * Enumeration of possible axis tick marks.
+ *
+ * @author Martin Andersson
+ */
+public enum AxisTickMark {
+    NONE,
+    CROSS,
+    IN,
+    OUT
+}

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartAxis.java Fri Nov 22 18:26:11 2013
@@ -26,7 +26,7 @@ import org.apache.poi.util.Beta;
  */
 @Beta
 public interface ChartAxis {
-	
+
 	/**
 	 * @return axis id
 	 */
@@ -123,4 +123,34 @@ public interface ChartAxis {
 	 * @param axis that this axis should cross
 	 */
 	void crossAxis(ChartAxis axis);
+
+    /**
+     * @return visibility of the axis.
+     */
+    boolean isVisible();
+
+    /**
+     * @param value visibility of the axis.
+     */
+    void setVisible(boolean value);
+
+    /**
+     * @return major tick mark.
+     */
+    AxisTickMark getMajorTickMark();
+
+    /**
+     * @param tickMark major tick mark type.
+     */
+    void setMajorTickMark(AxisTickMark tickMark);
+
+    /**
+     * @return minor tick mark.
+     */
+    AxisTickMark getMinorTickMark();
+
+    /**
+     * @param tickMark minor tick mark type.
+     */
+    void setMinorTickMark(AxisTickMark tickMark);
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartDataFactory.java Fri Nov 22 18:26:11 2013
@@ -22,14 +22,19 @@ import org.apache.poi.util.Beta;
 /**
  * A factory for different charts data types.
  *
- * @author Roman Kashitsyn
+ * @author Roman Kashitsyn, Martin Andersson
  */
 @Beta
 public interface ChartDataFactory {
-	
+
 	/**
 	 * @return an appropriate ScatterChartData instance
 	 */
 	ScatterChartData createScatterChartData();
 
+	/**
+	 * @return a LineChartData instance
+	 */
+	LineChartData createLineChartData();
+
 }

Added: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSerie.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSerie.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSerie.java (added)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ChartSerie.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,57 @@
+/* ====================================================================
+   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.ss.usermodel.charts;
+
+import org.apache.poi.ss.util.CellReference;
+
+/**
+ * Basic settings for all chart series.
+ *
+ * @author Martin Andersson
+ */
+public interface ChartSerie {
+
+    /**
+     * Sets the title of the series as a string literal.
+     *
+     * @param title
+     */
+    void setTitle(String title);
+
+    /**
+     * Sets the title of the series as a cell reference.
+     *
+     * @param titleReference
+     */
+    void setTitle(CellReference titleReference);
+
+    /**
+     * @return title as string literal.
+     */
+    String getTitleString();
+
+    /**
+     * @return title as cell reference.
+     */
+    CellReference getTitleCellReference();
+
+    /**
+     * @return title type.
+     */
+    TitleType getTitleType();
+}

Added: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java (added)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartData.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,41 @@
+/* ====================================================================
+   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.ss.usermodel.charts;
+
+import org.apache.poi.util.Beta;
+
+import java.util.List;
+
+/**
+ * @author Martin Andersson
+ */
+@Beta
+public interface LineChartData extends ChartData {
+
+    /**
+     * @param categories data source for categories.
+     * @param values     data source for values.
+     * @return a new line chart serie.
+     */
+    LineChartSerie addSerie(ChartDataSource<?> categories, ChartDataSource<? extends Number> values);
+
+    /**
+     * @return list of all series.
+     */
+    List<? extends LineChartSerie> getSeries();
+}

Added: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSerie.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSerie.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSerie.java (added)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/LineChartSerie.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,40 @@
+/* ====================================================================
+   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.ss.usermodel.charts;
+
+import org.apache.poi.util.Beta;
+
+/**
+ * Represents a line chart serie.
+ *
+ * @author Martin Andersson
+ */
+@Beta
+public interface LineChartSerie extends ChartSerie {
+
+    /**
+     * @return data source used for category axis data.
+     */
+    ChartDataSource<?> getCategoryAxisData();
+
+    /**
+     * @return data source used for value axis.
+     */
+    ChartDataSource<? extends Number> getValues();
+
+}

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSerie.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSerie.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSerie.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/ScatterChartSerie.java Fri Nov 22 18:26:11 2013
@@ -23,9 +23,10 @@ import org.apache.poi.util.Beta;
  * Represents scatter charts serie.
  *
  * @author Roman Kashitsyn
+ * @author Martin Andersson
  */
 @Beta
-public interface ScatterChartSerie {
+public interface ScatterChartSerie extends ChartSerie {
 
     /**
      * @return data source used for X axis values

Added: poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/TitleType.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/TitleType.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/TitleType.java (added)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/charts/TitleType.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,28 @@
+/* ====================================================================
+   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.ss.usermodel.charts;
+
+/**
+ * Title types for charts.
+ *
+ * @author Martin Andersson
+ */
+public enum TitleType {
+    STRING,
+    CELL_REFERENCE
+}

Added: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/AbstractXSSFChartSerie.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/AbstractXSSFChartSerie.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/AbstractXSSFChartSerie.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/AbstractXSSFChartSerie.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,79 @@
+/* ====================================================================
+   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.xssf.usermodel.charts;
+
+import org.apache.poi.ss.usermodel.charts.ChartSerie;
+import org.apache.poi.ss.usermodel.charts.TitleType;
+import org.apache.poi.ss.util.CellReference;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTSerTx;
+
+/**
+ * @author Martin Andersson
+ */
+public abstract class AbstractXSSFChartSerie implements ChartSerie {
+
+    private String titleValue;
+    private CellReference titleRef;
+    private TitleType titleType;
+
+    public void setTitle(CellReference titleReference) {
+        titleType = TitleType.CELL_REFERENCE;
+        titleRef = titleReference;
+    }
+
+    public void setTitle(String title) {
+        titleType = TitleType.STRING;
+        titleValue = title;
+    }
+
+    public CellReference getTitleCellReference() {
+        if (TitleType.CELL_REFERENCE.equals(titleType)) {
+            return titleRef;
+        }
+        throw new IllegalStateException("Title type is not CellReference.");
+    }
+
+    public String getTitleString() {
+        if (TitleType.STRING.equals(titleType)) {
+            return titleValue;
+        }
+        throw new IllegalStateException("Title type is not String.");
+    }
+
+    public TitleType getTitleType() {
+        return titleType;
+    }
+
+    protected boolean isTitleSet() {
+        return titleType != null;
+    }
+
+    protected CTSerTx getCTSerTx() {
+        CTSerTx tx = CTSerTx.Factory.newInstance();
+        switch (titleType) {
+            case CELL_REFERENCE:
+                tx.addNewStrRef().setF(titleRef.formatAsString());
+                return tx;
+            case STRING:
+                tx.setV(titleValue);
+                return tx;
+            default:
+                throw new IllegalStateException("Unkown title type: " + titleType);
+        }
+    }
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFCategoryAxis.java Fri Nov 22 18:26:11 2013
@@ -17,18 +17,10 @@
 
 package org.apache.poi.xssf.usermodel.charts;
 
-import org.apache.poi.ss.usermodel.charts.AxisCrosses;
-import org.apache.poi.ss.usermodel.charts.AxisOrientation;
-import org.apache.poi.ss.usermodel.charts.AxisPosition;
-import org.apache.poi.ss.usermodel.charts.ChartAxis;
+import org.apache.poi.ss.usermodel.charts.*;
 import org.apache.poi.util.Beta;
 import org.apache.poi.xssf.usermodel.XSSFChart;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTCatAx;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
-import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
-import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.*;
 
 /**
  * Category axis type.
@@ -73,6 +65,21 @@ public class XSSFCategoryAxis extends XS
 		return ctCatAx.getCrosses();
 	}
 
+	@Override
+	protected CTBoolean getDelete() {
+		return ctCatAx.getDelete();
+	}
+
+	@Override
+	protected CTTickMark getMajorCTTickMark() {
+		return ctCatAx.getMajorTickMark();
+	}
+
+	@Override
+	protected CTTickMark getMinorCTTickMark() {
+		return ctCatAx.getMinorTickMark();
+	}
+
 	public void crossAxis(ChartAxis axis) {
 		ctCatAx.getCrossAx().setVal(axis.getId());
 	}
@@ -85,9 +92,15 @@ public class XSSFCategoryAxis extends XS
 		ctCatAx.addNewCrosses();
 		ctCatAx.addNewCrossAx();
 		ctCatAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
+		ctCatAx.addNewDelete();
+		ctCatAx.addNewMajorTickMark();
+		ctCatAx.addNewMinorTickMark();
 
 		setPosition(pos);
 		setOrientation(AxisOrientation.MIN_MAX);
 		setCrosses(AxisCrosses.AUTO_ZERO);
+		setVisible(true);
+		setMajorTickMark(AxisTickMark.CROSS);
+		setMinorTickMark(AxisTickMark.NONE);
 	}
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartAxis.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartAxis.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartAxis.java Fri Nov 22 18:26:11 2013
@@ -21,17 +21,21 @@ import org.apache.poi.ss.usermodel.chart
 import org.apache.poi.ss.usermodel.charts.AxisPosition;
 import org.apache.poi.ss.usermodel.charts.AxisOrientation;
 import org.apache.poi.ss.usermodel.charts.AxisCrosses;
+import org.apache.poi.ss.usermodel.charts.AxisTickMark;
 import org.apache.poi.util.Beta;
 import org.apache.poi.xssf.usermodel.XSSFChart;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTOrientation;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTLogBase;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTickMark;
 import org.openxmlformats.schemas.drawingml.x2006.chart.STOrientation;
 import org.openxmlformats.schemas.drawingml.x2006.chart.STAxPos;
 import org.openxmlformats.schemas.drawingml.x2006.chart.STCrosses;
+import org.openxmlformats.schemas.drawingml.x2006.chart.STTickMark;
 
 /**
  * Base class for all axis types.
@@ -158,10 +162,37 @@ public abstract class XSSFChartAxis impl
 		getCTCrosses().setVal(fromAxisCrosses(crosses));
 	}
 
+	public boolean isVisible() {
+		return !getDelete().getVal();
+	}
+
+	public void setVisible(boolean value) {
+		getDelete().setVal(!value);
+	}
+
+	public AxisTickMark getMajorTickMark() {
+		return toAxisTickMark(getMajorCTTickMark());
+	}
+
+	public void setMajorTickMark(AxisTickMark tickMark) {
+		getMajorCTTickMark().setVal(fromAxisTickMark(tickMark));
+	}
+
+	public AxisTickMark getMinorTickMark() {
+		return toAxisTickMark(getMinorCTTickMark());
+	}
+
+	public void setMinorTickMark(AxisTickMark tickMark) {
+		getMinorCTTickMark().setVal(fromAxisTickMark(tickMark));
+	}
+
 	protected abstract CTAxPos getCTAxPos();
 	protected abstract CTNumFmt getCTNumFmt();
 	protected abstract CTScaling getCTScaling();
 	protected abstract CTCrosses getCTCrosses();
+	protected abstract CTBoolean getDelete();
+	protected abstract CTTickMark getMajorCTTickMark();
+	protected abstract CTTickMark getMinorCTTickMark();
 
 	private static STOrientation.Enum fromAxisOrientation(AxisOrientation orientation) {
 		switch (orientation) {
@@ -221,4 +252,25 @@ public abstract class XSSFChartAxis impl
 			default: return AxisPosition.BOTTOM;
 		}
 	}
+
+	private static STTickMark.Enum fromAxisTickMark(AxisTickMark tickMark) {
+		switch (tickMark) {
+			case NONE: return STTickMark.NONE;
+			case IN: return STTickMark.IN;
+			case OUT: return STTickMark.OUT;
+			case CROSS: return STTickMark.CROSS;
+			default:
+				throw new IllegalArgumentException("Unknown AxisTickMark: " + tickMark);
+		}
+	}
+
+	private static AxisTickMark toAxisTickMark(CTTickMark ctTickMark) {
+		switch (ctTickMark.getVal().intValue()) {
+			case STTickMark.INT_NONE: return AxisTickMark.NONE;
+			case STTickMark.INT_IN: return AxisTickMark.IN;
+			case STTickMark.INT_OUT: return AxisTickMark.OUT;
+			case STTickMark.INT_CROSS: return AxisTickMark.CROSS;
+			default: return AxisTickMark.CROSS;
+		}
+	}
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartDataFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartDataFactory.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartDataFactory.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFChartDataFactory.java Fri Nov 22 18:26:11 2013
@@ -40,6 +40,13 @@ public class XSSFChartDataFactory implem
 	}
 
 	/**
+	 * @return new line charts data instance
+	 */
+	public XSSFLineChartData createLineChartData() {
+		return new XSSFLineChartData();
+	}
+
+	/**
 	 * @return factory instance
 	 */
 	public static XSSFChartDataFactory getInstance() {

Added: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFLineChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFLineChartData.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFLineChartData.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFLineChartData.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,121 @@
+/* ====================================================================
+   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.xssf.usermodel.charts;
+
+import org.apache.poi.ss.usermodel.Chart;
+import org.apache.poi.ss.usermodel.charts.ChartAxis;
+import org.apache.poi.ss.usermodel.charts.ChartDataSource;
+import org.apache.poi.ss.usermodel.charts.LineChartData;
+import org.apache.poi.ss.usermodel.charts.LineChartSerie;
+import org.apache.poi.util.Beta;
+import org.apache.poi.xssf.usermodel.XSSFChart;
+import org.openxmlformats.schemas.drawingml.x2006.chart.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Andersson
+ */
+@Beta
+public class XSSFLineChartData implements LineChartData {
+
+    /**
+     * List of all data series.
+     */
+    private List<Serie> series;
+
+    public XSSFLineChartData() {
+        series = new ArrayList<Serie>();
+    }
+
+    static class Serie extends AbstractXSSFChartSerie implements LineChartSerie {
+        private int id;
+        private int order;
+        private ChartDataSource<?> categories;
+        private ChartDataSource<? extends Number> values;
+
+        protected Serie(int id, int order,
+                        ChartDataSource<?> categories,
+                        ChartDataSource<? extends Number> values) {
+            this.id = id;
+            this.order = order;
+            this.categories = categories;
+            this.values = values;
+        }
+
+        public ChartDataSource<?> getCategoryAxisData() {
+            return categories;
+        }
+
+        public ChartDataSource<? extends Number> getValues() {
+            return values;
+        }
+
+        protected void addToChart(CTLineChart ctLineChart) {
+            CTLineSer ctLineSer = ctLineChart.addNewSer();
+            ctLineSer.addNewIdx().setVal(id);
+            ctLineSer.addNewOrder().setVal(order);
+
+            // No marker symbol on the chart line.
+            ctLineSer.addNewMarker().addNewSymbol().setVal(STMarkerStyle.NONE);
+
+            CTAxDataSource catDS = ctLineSer.addNewCat();
+            XSSFChartUtil.buildAxDataSource(catDS, categories);
+            CTNumDataSource valueDS = ctLineSer.addNewVal();
+            XSSFChartUtil.buildNumDataSource(valueDS, values);
+
+            if (isTitleSet()) {
+                ctLineSer.setTx(getCTSerTx());
+            }
+        }
+    }
+
+    public LineChartSerie addSerie(ChartDataSource<?> categoryAxisData, ChartDataSource<? extends Number> values) {
+        if (!values.isNumeric()) {
+            throw new IllegalArgumentException("Value data source must be numeric.");
+        }
+        int numOfSeries = series.size();
+        Serie newSerie = new Serie(numOfSeries, numOfSeries, categoryAxisData, values);
+        series.add(newSerie);
+        return newSerie;
+    }
+
+    public List<? extends LineChartSerie> getSeries() {
+        return series;
+    }
+
+    public void fillChart(Chart chart, ChartAxis... axis) {
+        if (!(chart instanceof XSSFChart)) {
+            throw new IllegalArgumentException("Chart must be instance of XSSFChart");
+        }
+
+        XSSFChart xssfChart = (XSSFChart) chart;
+        CTPlotArea plotArea = xssfChart.getCTChart().getPlotArea();
+        CTLineChart lineChart = plotArea.addNewLineChart();
+        lineChart.addNewVaryColors().setVal(false);
+
+        for (Serie s : series) {
+            s.addToChart(lineChart);
+        }
+
+        for (ChartAxis ax : axis) {
+            lineChart.addNewAxId().setVal(ax.getId());
+        }
+    }
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFScatterChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFScatterChartData.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFScatterChartData.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFScatterChartData.java Fri Nov 22 18:26:11 2013
@@ -50,7 +50,7 @@ public class XSSFScatterChartData implem
     /**
      * Package private ScatterChartSerie implementation.
      */
-    static class Serie implements ScatterChartSerie {
+    static class Serie extends AbstractXSSFChartSerie implements ScatterChartSerie {
         private int id;
         private int order;
         private ChartDataSource<?> xs;
@@ -92,6 +92,10 @@ public class XSSFScatterChartData implem
 
             CTNumDataSource yVal = scatterSer.addNewYVal();
             XSSFChartUtil.buildNumDataSource(yVal, ys);
+
+			if (isTitleSet()) {
+				scatterSer.setTx(getCTSerTx());
+			}
         }
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFValueAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFValueAxis.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFValueAxis.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/charts/XSSFValueAxis.java Fri Nov 22 18:26:11 2013
@@ -23,14 +23,17 @@ import org.apache.poi.ss.usermodel.chart
 import org.apache.poi.ss.usermodel.charts.AxisOrientation;
 import org.apache.poi.ss.usermodel.charts.AxisCrossBetween;
 import org.apache.poi.ss.usermodel.charts.AxisCrosses;
+import org.apache.poi.ss.usermodel.charts.AxisTickMark;
 
 import org.apache.poi.util.Beta;
 import org.apache.poi.xssf.usermodel.XSSFChart;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTValAx;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTAxPos;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTBoolean;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTNumFmt;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTCrosses;
 import org.openxmlformats.schemas.drawingml.x2006.chart.CTScaling;
+import org.openxmlformats.schemas.drawingml.x2006.chart.CTTickMark;
 import org.openxmlformats.schemas.drawingml.x2006.chart.STCrossBetween;
 import org.openxmlformats.schemas.drawingml.x2006.chart.STTickLblPos;
 
@@ -89,6 +92,21 @@ public class XSSFValueAxis extends XSSFC
 		return ctValAx.getCrosses();
 	}
 
+	@Override
+	protected CTBoolean getDelete() {
+		return ctValAx.getDelete();
+	}
+
+	@Override
+	protected CTTickMark getMajorCTTickMark() {
+		return ctValAx.getMajorTickMark();
+	}
+
+	@Override
+	protected CTTickMark getMinorCTTickMark() {
+		return ctValAx.getMinorTickMark();
+	}
+
 	public void crossAxis(ChartAxis axis) {
 		ctValAx.getCrossAx().setVal(axis.getId());
 	}
@@ -102,11 +120,17 @@ public class XSSFValueAxis extends XSSFC
 		ctValAx.addNewCrosses();
 		ctValAx.addNewCrossAx();
 		ctValAx.addNewTickLblPos().setVal(STTickLblPos.NEXT_TO);
+		ctValAx.addNewDelete();
+		ctValAx.addNewMajorTickMark();
+		ctValAx.addNewMinorTickMark();
 
 		setPosition(pos);
 		setOrientation(AxisOrientation.MIN_MAX);
 		setCrossBetween(AxisCrossBetween.MIDPOINT_CATEGORY);
 		setCrosses(AxisCrosses.AUTO_ZERO);
+		setVisible(true);
+		setMajorTickMark(AxisTickMark.CROSS);
+		setMinorTickMark(AxisTickMark.NONE);
 	}
 
 	private static STCrossBetween.Enum fromCrossBetween(AxisCrossBetween crossBetween) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java?rev=1544628&r1=1544627&r2=1544628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartAxis.java Fri Nov 22 18:26:11 2013
@@ -76,4 +76,39 @@ public final class TestXSSFChartAxis ext
 		assertTrue(Math.abs(axis.getMaximum() - newValue) < EPSILON);
 	}
 
+	public void testVisibleAccessMethods() {
+		axis.setVisible(true);
+		assertTrue(axis.isVisible());
+
+		axis.setVisible(false);
+		assertFalse(axis.isVisible());
+	}
+
+	public void testMajorTickMarkAccessMethods() {
+		axis.setMajorTickMark(AxisTickMark.NONE);
+		assertEquals(AxisTickMark.NONE, axis.getMajorTickMark());
+
+		axis.setMajorTickMark(AxisTickMark.IN);
+		assertEquals(AxisTickMark.IN, axis.getMajorTickMark());
+
+		axis.setMajorTickMark(AxisTickMark.OUT);
+		assertEquals(AxisTickMark.OUT, axis.getMajorTickMark());
+
+		axis.setMajorTickMark(AxisTickMark.CROSS);
+		assertEquals(AxisTickMark.CROSS, axis.getMajorTickMark());
+	}
+
+	public void testMinorTickMarkAccessMethods() {
+		axis.setMinorTickMark(AxisTickMark.NONE);
+		assertEquals(AxisTickMark.NONE, axis.getMinorTickMark());
+
+		axis.setMinorTickMark(AxisTickMark.IN);
+		assertEquals(AxisTickMark.IN, axis.getMinorTickMark());
+
+		axis.setMinorTickMark(AxisTickMark.OUT);
+		assertEquals(AxisTickMark.OUT, axis.getMinorTickMark());
+
+		axis.setMinorTickMark(AxisTickMark.CROSS);
+		assertEquals(AxisTickMark.CROSS, axis.getMinorTickMark());
+	}
 }

Added: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java?rev=1544628&view=auto
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java (added)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFLineChartData.java Fri Nov 22 18:26:11 2013
@@ -0,0 +1,43 @@
+package org.apache.poi.xssf.usermodel.charts;
+
+import junit.framework.TestCase;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.charts.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.SheetBuilder;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+/**
+ * @author Martin Andersson
+ */
+public class TestXSSFLineChartData extends TestCase {
+
+    private static final Object[][] plotData = {
+            {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"},
+            {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
+    };
+
+    public void testOneSeriePlot() throws Exception {
+        Workbook wb = new XSSFWorkbook();
+        Sheet sheet = new SheetBuilder(wb, plotData).build();
+        Drawing drawing = sheet.createDrawingPatriarch();
+        ClientAnchor anchor = drawing.createAnchor(0, 0, 0, 0, 1, 1, 10, 30);
+        Chart chart = drawing.createChart(anchor);
+
+        ChartAxis bottomAxis = chart.getChartAxisFactory().createCategoryAxis(AxisPosition.BOTTOM);
+        ChartAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT);
+
+        LineChartData lineChartData =
+                chart.getChartDataFactory().createLineChartData();
+
+        ChartDataSource<String> xs = DataSources.fromStringCellRange(sheet, CellRangeAddress.valueOf("A1:J1"));
+        ChartDataSource<Number> ys = DataSources.fromNumericCellRange(sheet, CellRangeAddress.valueOf("A2:J2"));
+        LineChartSerie serie = lineChartData.addSerie(xs, ys);
+
+        assertNotNull(serie);
+        assertEquals(1, lineChartData.getSeries().size());
+        assertTrue(lineChartData.getSeries().contains(serie));
+
+        chart.plot(lineChartData, bottomAxis, leftAxis);
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org