com.aspose.words
Class ChartSeriesGroupCollection

java.lang.Object
    extended by com.aspose.words.ChartSeriesGroupCollection
All Implemented Interfaces:
java.lang.Iterable

public class ChartSeriesGroupCollection 
extends java.lang.Object

Represents a collection of ChartSeriesGroup objects. To learn more, visit the Working with Charts documentation article.

Example:

Shows how to work with the secondary axis of chart.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.LINE, 450.0, 250.0);
Chart chart = shape.getChart();
ChartSeriesCollection series = chart.getSeries();

// Delete default generated series.
series.clear();

String[] categories = new String[] { "Category 1", "Category 2", "Category 3" };
series.add("Series 1 of primary series group", categories, new double[] { 2.0, 3.0, 4.0 });
series.add("Series 2 of primary series group", categories, new double[] { 5.0, 2.0, 3.0 });

// Create an additional series group, also of the line type.
ChartSeriesGroup newSeriesGroup = chart.getSeriesGroups().add(ChartSeriesType.LINE);
// Specify the use of secondary axes for the new series group.
newSeriesGroup.setAxisGroup(AxisGroup.SECONDARY);
// Hide the secondary X axis.
newSeriesGroup.getAxisX().setHidden(true);
// Define title of the secondary Y axis.
newSeriesGroup.getAxisY().getTitle().setShow(true);
newSeriesGroup.getAxisY().getTitle().setText("Secondary Y axis");

// Add a series to the new series group.
ChartSeries series3 =
        newSeriesGroup.getSeries().add("Series of secondary series group", categories, new double[] { 13.0, 11.0, 16.0 });
series3.getFormat().getStroke().setWeight(3.5);

doc.save(getArtifactsDir() + "Charts.SecondaryAxis.docx");

Property Getters/Setters Summary
intgetCount()
           Returns the number of series groups in this collection.
ChartSeriesGroupget(int index)
           Returns a ChartSeriesGroup at the specified index.
 
Method Summary
ChartSeriesGroupadd(int seriesType)
           Adds a new series group of the specified series type to this collection.
java.util.Iterator<ChartSeriesGroup>iterator()
           Returns an enumerator object.
voidremoveAt(int index)
           Removes a series group at the specified index. All child series will be removed from the chart.
 

Property Getters/Setters Detail

getCount

public int getCount()
Returns the number of series groups in this collection.

Example:

Show how to remove secondary axis.
Document doc = new Document(getMyDir() + "Combo chart.docx");

Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
Chart chart = shape.getChart();
ChartSeriesGroupCollection seriesGroups = chart.getSeriesGroups();

// Find secondary axis and remove from the collection.
for (int i = 0; i < seriesGroups.getCount(); i++)
    if (seriesGroups.get(i).getAxisGroup() == AxisGroup.SECONDARY)
        seriesGroups.removeAt(i);

get

public ChartSeriesGroup get(int index)
Returns a ChartSeriesGroup at the specified index.

Example:

Show how to remove secondary axis.
Document doc = new Document(getMyDir() + "Combo chart.docx");

Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
Chart chart = shape.getChart();
ChartSeriesGroupCollection seriesGroups = chart.getSeriesGroups();

// Find secondary axis and remove from the collection.
for (int i = 0; i < seriesGroups.getCount(); i++)
    if (seriesGroups.get(i).getAxisGroup() == AxisGroup.SECONDARY)
        seriesGroups.removeAt(i);

Method Detail

add

public ChartSeriesGroup add(int seriesType)
                    throws java.lang.Exception
Adds a new series group of the specified series type to this collection. Combo charts can contain series groups only of the following types: area, bar, column, line, pie, scatter, radar and stock types (except the corresponding 3D series types).
Parameters:
seriesType - A ChartSeriesType value.

Example:

Shows how to work with the secondary axis of chart.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.LINE, 450.0, 250.0);
Chart chart = shape.getChart();
ChartSeriesCollection series = chart.getSeries();

// Delete default generated series.
series.clear();

String[] categories = new String[] { "Category 1", "Category 2", "Category 3" };
series.add("Series 1 of primary series group", categories, new double[] { 2.0, 3.0, 4.0 });
series.add("Series 2 of primary series group", categories, new double[] { 5.0, 2.0, 3.0 });

// Create an additional series group, also of the line type.
ChartSeriesGroup newSeriesGroup = chart.getSeriesGroups().add(ChartSeriesType.LINE);
// Specify the use of secondary axes for the new series group.
newSeriesGroup.setAxisGroup(AxisGroup.SECONDARY);
// Hide the secondary X axis.
newSeriesGroup.getAxisX().setHidden(true);
// Define title of the secondary Y axis.
newSeriesGroup.getAxisY().getTitle().setShow(true);
newSeriesGroup.getAxisY().getTitle().setText("Secondary Y axis");

// Add a series to the new series group.
ChartSeries series3 =
        newSeriesGroup.getSeries().add("Series of secondary series group", categories, new double[] { 13.0, 11.0, 16.0 });
series3.getFormat().getStroke().setWeight(3.5);

doc.save(getArtifactsDir() + "Charts.SecondaryAxis.docx");

iterator

public java.util.Iterator<ChartSeriesGroupiterator()
Returns an enumerator object.

removeAt

public void removeAt(int index)
Removes a series group at the specified index. All child series will be removed from the chart.

Example:

Show how to remove secondary axis.
Document doc = new Document(getMyDir() + "Combo chart.docx");

Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
Chart chart = shape.getChart();
ChartSeriesGroupCollection seriesGroups = chart.getSeriesGroups();

// Find secondary axis and remove from the collection.
for (int i = 0; i < seriesGroups.getCount(); i++)
    if (seriesGroups.get(i).getAxisGroup() == AxisGroup.SECONDARY)
        seriesGroups.removeAt(i);

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.