[]
        
(Showing Draft Content)

IChartGroups

Interface IChartGroups

All Superinterfaces:
Iterable<IChartGroup>

public interface IChartGroups extends Iterable<IChartGroup>
Represents a collection of all IChartGroup objects in a specified IChart.

Use this interface to access the chart groups contained in a chart, including charts that contain multiple group types. An IChartGroup represents one or more series plotted with the same format.


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Month", "Sales"},
     {"Jan", 10},
     {"Feb", 15}
 });
 IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 10, 10, 300, 200).getChart();
 chart.getSeriesCollection().add(worksheet.getRange("A1:B3"));
 IChartGroups chartGroups = chart.getChartGroups();
 IChartGroup chartGroup = chartGroups.get(0);
 
  • Method Details

    • getCount

      int getCount()
      Gets the number of chart groups in the collection.

      The returned value indicates how many IChartGroup objects are contained in this IChartGroups collection for the chart.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Target"},
           {"Jan", 100, 120},
           {"Feb", 140, 130},
           {"Mar", 160, 150}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("B1:C4"));
       chart.getSeriesCollection().get(1).setChartType(ChartType.Line);
       int count = chart.getChartGroups().getCount();
       
      Returns:
      The number of chart groups in the collection.
    • getParent

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

      Use this method to navigate from an IChartGroups collection back to the chart that owns it.

      
       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"));
       IChart parentChart = chart.getChartGroups().getParent();
       
      Returns:
      The parent IChart that owns this collection.
    • get

      IChartGroup get(int index)
      Gets the IChartGroup object at the specified index in the collection.

      Use this method to access an individual chart group from the IChartGroups collection returned by IChart.getChartGroups().

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Target"},
           {"Jan", 10, 12},
           {"Feb", 20, 18},
           {"Mar", 15, 16}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("B1:C4"));
       chart.getSeriesCollection().get(1).setChartType(ChartType.Line);
       IChartGroup chartGroup = chart.getChartGroups().get(0);
       
      Parameters:
      index - The zero-based index of the chart group to retrieve.
      Returns:
      The IChartGroup object at the specified index.