[]
        
(Showing Draft Content)

ISeriesCollection

Interface ISeriesCollection

All Superinterfaces:
Iterable<ISeries>

public interface ISeriesCollection extends Iterable<ISeries>
Represents a collection of all ISeries objects in a chart.

Use this interface to access, add, and create chart series returned by IChart.getSeriesCollection().


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Month", "Sales"},
     {"Jan", 10},
     {"Feb", 20}
 });
 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200);
 ISeriesCollection seriesCollection = shape.getChart().getSeriesCollection();
 seriesCollection.add(worksheet.getRange("A1:B3"));
 
  • Method Details

    • getParent

      IChart getParent()
      Gets the parent chart that contains this series collection.

      Use this method to navigate from an ISeriesCollection object back to its owning IChart.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 10},
           {"Feb", 20}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B3"));
       IChart parentChart = chart.getSeriesCollection().getParent();
       
      Returns:
      The parent IChart object that owns this series collection.
    • getCount

      int getCount()
      Gets the number of ISeries objects in the collection.

      Use this method to determine how many data series are currently contained in the parent chart.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 35},
           {"Feb", 120, 40}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"), RowCol.Columns, true, true);
       int count = chart.getSeriesCollection().getCount();
       
      Returns:
      The number of ISeries objects in the collection.
    • add

      void add(IRange source)
      Adds one or more new series to the ISeriesCollection collection.

      The library determines whether the values are taken from rows or columns based on the size and orientation of the selected range.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 35},
           {"Feb", 120, 40},
           {"Mar", 140, 50}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C4"));
       
      Parameters:
      source - The range that provides the source data for the new series. Must not be null.
    • add

      void add(IRange source, RowCol rowCol)
      Adds one or more new series to the ISeriesCollection collection.

      Use rowCol to specify whether each series is created from rows or columns in the source range.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 35},
           {"Feb", 120, 40},
           {"Mar", 140, 50}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C4"), RowCol.Columns);
       
      Parameters:
      source - The range that provides the source data for the new series. Must not be null.
      rowCol - Specifies whether the source data is arranged by RowCol.Rows or RowCol.Columns. Must not be null.
    • add

      void add(IRange source, RowCol rowCol, boolean seriesLabels, boolean categoryLabels)
      Adds one or more series to this ISeriesCollection from the specified range.

      Use rowCol to indicate whether each series is built from rows or columns in source. Use seriesLabels to indicate whether the first row or column contains series names, and use categoryLabels to indicate whether the first row or column contains category labels.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 10, 4},
           {"Feb", 12, 5},
           {"Mar", 15, 6}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C4"), RowCol.Columns, true, true);
       
      Parameters:
      source - The range that provides the source data for the new series.
      rowCol - Specifies whether the source data is arranged by RowCol.Rows or RowCol.Columns.
      seriesLabels - true if the first row or column in source contains series names; otherwise, false.
      categoryLabels - true if the first row or column in source contains category labels; otherwise, false.
    • extend

      void extend(IRange source, RowCol rowcol, boolean categoryLabels)
      Adds data points from the specified range to the existing series in this collection.

      Use this method to extend a chart with additional source data after the initial series have already been added. The rowcol parameter determines whether the new values are read by rows or by columns, and categoryLabels specifies whether the first row or column in source contains category labels.

      
       worksheet.getRange("A1:C3").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 10, 4},
           {"Feb", 12, 5}
       });
       worksheet.getRange("A4:C5").setValue(new Object[][] {
           {"Mar", 15, 6},
           {"Apr", 18, 7}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:C3"), RowCol.Columns, true, true);
       chart.getSeriesCollection().extend(worksheet.getRange("A4:C5"), RowCol.Columns, false);
       
      Parameters:
      source - The range that contains the data points to append to the existing series. null is not supported.
      rowcol - Specifies whether the values in source are arranged by RowCol.Rows or RowCol.Columns.
      categoryLabels - true if the first row or column in source contains category labels; otherwise, false.
    • get

      ISeries get(int index)
      Gets the series at the specified index in the collection.

      Use this method to access an individual chart series after series have been added to the chart.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 10},
           {"Feb", 20},
           {"Mar", 15}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
       shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"));
       ISeries series = shape.getChart().getSeriesCollection().get(0);
       
      Parameters:
      index - The zero-based index of the series to retrieve.
      Returns:
      The ISeries at the specified index.
    • get

      ISeries get(String name)
      Gets the ISeries object with the specified name from the collection.

      Use this method to retrieve an existing chart series by its name.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 120}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
       ISeries series = chart.getSeriesCollection().get(0);
       series.setName("Sales");
       ISeries salesSeries = chart.getSeriesCollection().get("Sales");
       
      Parameters:
      name - The name of the series to retrieve. null is not supported.
      Returns:
      The ISeries object with the specified name.
    • newSeries

      ISeries newSeries()
      Creates a new series in this collection.

      Use the returned ISeries object to configure the newly created chart series.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Q1", 10},
           {"Q2", 20},
           {"Q3", 15}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       ISeries series = chart.getSeriesCollection().newSeries();
       series.setFormula("=SERIES(\"Sales\",,Sheet1!$B$1:$B$3,1)");
       
      Returns:
      The ISeries object that represents the new series.