[]
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);
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();
IChart that contains this axes collection.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();
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");
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");