[]
        
(Showing Draft Content)

IAxes

Interface IAxes

All Superinterfaces:
Iterable<IAxis>

public interface IAxes extends Iterable<IAxis>
Represents a collection of IAxis objects in a chart.

Use this interface to access the axes that belong to a chart, retrieve a specific axis by its type, and iterate through the available axes.


 worksheet.getRange("A1:B4").setValue(new Object[][] {
     {"Month", "Sales"},
     {"Jan", 10},
     {"Feb", 20},
     {"Mar", 15}
 });
 IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200);
 shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
 IAxes axes = shape.getChart().getAxes();
 IAxis categoryAxis = axes.item(AxisType.Category);
 
  • Method Details

    • getParent

      IChart getParent()
      Gets the parent chart of this axes collection.

      The returned IChart is the chart that owns these axes.

      
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 10, 10, 300, 200);
       IChart chart = shape.getChart();
       IAxes axes = chart.getAxes();
       IChart parentChart = axes.getParent();
       
      Returns:
      The parent IChart that contains this axes collection.
    • getCount

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

      Use this method to determine how many axes are available in the chart represented by this IAxes collection.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 200}
       });
       IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
       shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
       int axisCount = shape.getChart().getAxes().getCount();
       
      Returns:
      The number of objects in the collection.
    • item

      IAxis item(AxisType Type)
      Returns a single IAxis object from this IAxes collection.

      Use this overload to retrieve an axis from the primary axis group by its axis type.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Month", "Sales"},
           {"Jan", 100},
           {"Feb", 120},
           {"Mar", 140}
       });
       IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
       chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
       IAxis valueAxis = chart.getAxes().item(AxisType.Value);
       valueAxis.setHasTitle(true);
       valueAxis.getAxisTitle().setText("Sales");
       
      Parameters:
      Type - The AxisType of the axis to retrieve.
      Returns:
      The IAxis object.
    • item

      IAxis item(AxisType type, AxisGroup axisGroup)
      Returns a single IAxis object from this IAxes collection.

      Use this overload to retrieve an axis by both axis type and axis group, such as a primary category axis or a secondary value axis.

      
       worksheet.getRange("A1:C4").setValue(new Object[][] {
           {"Month", "Sales", "Profit"},
           {"Jan", 100, 30},
           {"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, true, true);
       chart.getSeriesCollection().get(1).setAxisGroup(AxisGroup.Secondary);
       IAxis secondaryValueAxis = chart.getAxes().item(AxisType.Value, AxisGroup.Secondary);
       secondaryValueAxis.setHasTitle(true);
       secondaryValueAxis.getAxisTitle().setText("Profit");
       
      Parameters:
      type - The AxisType of the axis to retrieve.
      axisGroup - The AxisGroup of the axis to retrieve.
      Returns:
      The IAxis object.