[]
An IAxis provides access to axis settings such as the axis group, title, scaling, crossing behavior, tick labels, and gridlines for category, value, and series axes.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
axis.getAxisTitle().setText("Month");
booleanbooleanString[]doubledoubleIDisplayUnitLabel object for this axis.booleanbooleanbooleanbooleandoubledoublebooleangetCategoryType() is CategoryType.TimeScale.doublebooleandoublebooleanIGridlines object that represents the minor gridlines for the specified axis.doublebooleangetCategoryType() is CategoryType.TimeScale.IAxes collection that contains this axis.booleanintbooleanintgetType()booleanvoidsetAxisBetweenCategories(boolean value) voidsetBaseUnit(TimeUnit value) voidsetBaseUnitIsAuto(boolean value) voidsetCategoryNames(String[] value) voidsetCategoryType(CategoryType value) voidsetCrosses(AxisCrosses value) voidsetCrossesAt(double value) voidsetDisplayUnit(DisplayUnit value) voidsetDisplayUnitCustom(double value) voidsetHasDisplayUnitLabel(boolean value) voidsetHasMajorGridlines(boolean value) voidsetHasMinorGridlines(boolean value) voidsetHasTitle(boolean value) voidsetLogBase(double value) voidsetMajorTickMark(TickMark value) voidsetMajorUnit(double value) voidsetMajorUnitIsAuto(boolean value) voidsetMajorUnitScale(TimeUnit value) getCategoryType() is CategoryType.TimeScale.voidsetMaximumScale(double value) voidsetMaximumScaleIsAuto(boolean value) voidsetMinimumScale(double value) voidsetMinimumScaleIsAuto(boolean value) voidsetMinorTickMark(TickMark value) voidsetMinorUnit(double value) voidsetMinorUnitIsAuto(boolean value) voidsetMinorUnitScale(TimeUnit value) CategoryType.TimeScale.voidsetReversePlotOrder(boolean value) voidsetScaleType(ScaleType value) voidvoidsetTickLabelSpacing(int value) voidsetTickLabelSpacingIsAuto(boolean value) voidsetTickMarkSpacing(int value) voidsetVisible(boolean value) This property applies to a category axis. A value of true indicates that the value axis crosses the category axis between categories instead of at the category marks.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 200},
{"Mar", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 150, 0, 250, 250).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
boolean axisBetweenCategories = axis.getAxisBetweenCategories();
true if the value axis crosses the category axis between categories; otherwise, false.This property applies to a category axis. A value of true indicates that the value axis crosses the category axis between categories instead of at the category marks.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 200},
{"Mar", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 150, 0, 250, 250).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setAxisBetweenCategories(true);
value - true if the value axis crosses the category axis between categories; otherwise, false.The returned AxisGroup indicates whether the axis belongs to the primary axis group or the secondary axis group.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
AxisGroup axisGroup = axis.getAxisGroup();
AxisGroup of the axis.Use the returned IAxisTitle object to access and configure the axis title, such as its text and formatting.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasTitle(true);
IAxisTitle title = axis.getAxisTitle();
title.setText("Sales");
IAxisTitle object that represents the title of the axis.For a time-scale category axis, the base unit specifies whether the axis is based on days, months, or years.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{new GregorianCalendar(2024, Calendar.JANUARY, 1).getTime(), 12},
{new GregorianCalendar(2024, Calendar.FEBRUARY, 1).getTime(), 18},
{new GregorianCalendar(2024, Calendar.MARCH, 1).getTime(), 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setBaseUnit(TimeUnit.Months);
TimeUnit baseUnit = axis.getBaseUnit();
For a time-scale category axis, the base unit determines whether the axis is based on days, months, or years.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{new GregorianCalendar(2024, Calendar.JANUARY, 1).getTime(), 12},
{new GregorianCalendar(2024, Calendar.FEBRUARY, 1).getTime(), 18},
{new GregorianCalendar(2024, Calendar.MARCH, 1).getTime(), 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setBaseUnit(TimeUnit.Months);
value - The base unit to use for the category axis.If this property is true, Microsoft Excel chooses an appropriate base unit for the category axis automatically. The default value is true.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setBaseUnitIsAuto(false);
boolean autoBaseUnit = axis.getBaseUnitIsAuto();
true if the base unit is selected automatically; otherwise, false.If this property is true, Microsoft Excel chooses an appropriate base unit for the category axis automatically. The default value is true.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setBaseUnitIsAuto(false);
value - true if the base unit is selected automatically; otherwise, false.Returns the category labels currently used by the axis.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Q1", 120},
{"Q2", 150},
{"Q3", 180}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
String[] categoryNames = axis.getCategoryNames();
Sets the category labels currently used by the axis.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Q1", 120},
{"Q2", 150},
{"Q3", 180}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryNames(100);
value - The category names for the axis as a text array.This method returns the CategoryType configured for the axis. If you need the effective category axis type after automatic resolution, use getActualCategoryType().
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
CategoryType type = axis.getCategoryType();
Use this method to control how categories on a category axis are grouped, such as by categories or by a time scale. To get the effective category axis type after automatic resolution, use getActualCategoryType().
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryType(CategoryType.TimeScale);
value - The category axis type to set.This method returns the effective CategoryType used by the axis. If the category axis type is set to CategoryType.AutomaticScale, the returned value reflects the type resolved from the chart data and chart type.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{42374d, 100},
{42394d, 200},
{42410d, 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 150, 0, 250, 250).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
CategoryType type = axis.getActualCategoryType();
Returns the current axis crossing mode, such as AxisCrosses.Automatic, AxisCrosses.Custom, AxisCrosses.Maximum, or AxisCrosses.Minimum. If the crossing mode is AxisCrosses.Custom, use getCrossesAt() to get the exact crossing position.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCrosses(AxisCrosses.Maximum);
AxisCrosses crosses = axis.getCrosses();
Use an AxisCrosses value to control whether the axis crosses automatically or at the minimum or maximum value. To specify an exact crossing position, use setCrossesAt(double).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCrosses(AxisCrosses.Maximum);
value - The axis crossing mode. Use AxisCrosses.Custom with setCrossesAt(double) to specify an exact crossing point.This property applies only to the value axis. To use a custom crossing point, set the axis crosses mode to AxisCrosses.Custom.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setCrosses(AxisCrosses.Custom);
axis.setCrossesAt(5.0);
double crossesAt = axis.getCrossesAt();
This property applies only to the value axis. To use a custom crossing point, set the axis crosses mode to AxisCrosses.Custom.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setCrosses(AxisCrosses.Custom);
axis.setCrossesAt(5.0);
value - The point on the value axis where the category axis crosses it.Use this property to determine how values on the value axis are scaled for display, such as thousands or millions.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Thousands);
DisplayUnit displayUnit = axis.getDisplayUnit();
DisplayUnit applied to the value axis.Use this method to show axis values in a scaled unit such as thousands or millions. To use a custom display unit value, set this property to DisplayUnit.Custom and then call setDisplayUnitCustom(double).
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Thousands);
value - The display unit for the value axis.This property returns the displayed unit value when setDisplayUnit(DisplayUnit) is set to DisplayUnit.Custom. The value is from 0 through 10E307.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Custom);
axis.setDisplayUnitCustom(1000d);
double displayUnitCustom = axis.getDisplayUnitCustom();
This property Sets the displayed unit value when setDisplayUnit(DisplayUnit) is set to DisplayUnit.Custom. The value is from 0 through 10E307.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Custom);
axis.setDisplayUnitCustom(1000d);
value - The custom display unit value for the value axis.IDisplayUnitLabel object for this axis.The display unit label shows the unit specified by setDisplayUnit(DisplayUnit) or setDisplayUnitCustom(double) on the axis. Returns null if getHasDisplayUnitLabel() is false.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Thousands);
IDisplayUnitLabel displayUnitLabel = axis.getDisplayUnitLabel();
IDisplayUnitLabel object for this axis, or null if the display unit label is not shown.Use the returned IChartFormat object to access the fill and line formatting settings of the axis.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
IChartFormat format = axis.getFormat();
format.getLine().getColor().setRGB(Color.GetBlue());
IChartFormat object that represents the axis formatting.Returns true if the label specified by the getDisplayUnit() or getDisplayUnitCustom() property is displayed on the axis.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Thousands);
boolean hasDisplayUnitLabel = axis.getHasDisplayUnitLabel();
true if the display unit label is displayed on the axis; otherwise, false.Set this property to true to display the label specified by the getDisplayUnit() or getDisplayUnitCustom() property, or false to hide it.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setDisplayUnit(DisplayUnit.Thousands);
axis.setHasDisplayUnitLabel(true);
value - true if the display unit label is displayed on the axis; otherwise, false.This property applies only to axes in the primary axis group.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasMajorGridlines(true);
boolean hasMajorGridlines = axis.getHasMajorGridlines();
true if the axis displays major gridlines; otherwise, false.This property applies only to axes in the primary axis group.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasMajorGridlines(true);
value - true if the axis displays major gridlines; otherwise, false.This property indicates whether minor gridlines are enabled for the axis. Only axes in the primary axis group can have gridlines.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasMinorGridlines(true);
boolean hasMinorGridlines = axis.getHasMinorGridlines();
true if the axis has minor gridlines; otherwise, false. This property applies only to axes in the primary axis group.Set this property to true to enable minor gridlines for the axis, or false to disable them. Only axes in the primary axis group can have gridlines.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasMinorGridlines(true);
value - true if the axis has minor gridlines; otherwise, false. This property applies only to axes in the primary axis group.This property indicates whether the axis title is displayed. Use getAxisTitle() to access and configure the title when this property is true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasTitle(true);
boolean hasTitle = axis.getHasTitle();
true if the axis has a visible title; otherwise, false.Set this property to true to display the axis title, or false to hide it. Use getAxisTitle() to access and configure the title when this property is true.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasTitle(true);
value - true if the axis has a visible title; otherwise, false.Use this method with getScaleType() to read the logarithmic base of a value axis configured with ScaleType.Logarithmic.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setScaleType(ScaleType.Logarithmic);
axis.setLogBase(20d);
double logBase = axis.getLogBase();
Use this method with setScaleType(ScaleType) to set the logarithmic base of a value axis configured with ScaleType.Logarithmic.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setScaleType(ScaleType.Logarithmic);
axis.setLogBase(20d);
value - The logarithmic base used by the axis.The returned IGridlines object represents the major gridlines on the specified axis. Only axes in the primary axis group can have gridlines.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setHasMajorGridlines(true);
IGridlines gridlines = axis.getMajorGridlines();
IGridlines object that represents the major gridlines for the axis.This property determines whether major tick marks are displayed inside the axis, outside the axis, across the axis, or not displayed.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setMajorTickMark(TickMark.Outside);
TickMark tickMark = axis.getMajorTickMark();
This property determines whether major tick marks are displayed inside the axis, outside the axis, across the axis, or not displayed.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setMajorTickMark(TickMark.Outside);
value - The major tick mark type to apply to the axis.The major unit determines the interval between major tick marks and major gridlines on the value axis.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMajorUnit(5d);
double majorUnit = axis.getMajorUnit();
The major unit determines the interval between major tick marks and major gridlines on the value axis.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMajorUnit(5d);
value - The major unit for the value axis.This method returns true when the major unit is determined automatically by Excel, and false when a custom major unit is used.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMajorUnitIsAuto(true);
boolean isAuto = axis.getMajorUnitIsAuto();
true if Excel automatically calculates the major unit for the value axis; otherwise, false.Set value to true to let Excel determine the major unit automatically, or false to use a custom major unit.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMajorUnitIsAuto(true);
value - true if Excel automatically calculates the major unit for the value axis; otherwise, false.getCategoryType() is CategoryType.TimeScale. If the major unit is calculated automatically, this method returns the current base unit.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryType(CategoryType.TimeScale);
axis.setMajorUnitScale(TimeUnit.Months);
TimeUnit majorUnitScale = axis.getMajorUnitScale();
getCategoryType() is CategoryType.TimeScale. Use this method to specify the time unit used between major tick marks on a date-based category axis.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryType(CategoryType.TimeScale);
axis.setMajorUnitScale(TimeUnit.Months);
value - The major unit scale for the category axis.Use getMaximumScaleIsAuto() to determine whether this value is calculated automatically by Excel or set explicitly with setMaximumScale(double).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMaximumScale(20);
double maximumScale = axis.getMaximumScale();
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMaximumScale(20);
value - The maximum value on the value axis.When this method returns true, the maximum scale is determined by Excel. When it returns false, the maximum scale is set explicitly.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
boolean maximumScaleIsAuto = axis.getMaximumScaleIsAuto();
true if Excel calculates the maximum value for the value axis automatically; otherwise, false.When value is true, the maximum scale is determined by Excel. When value is false, the maximum scale is set explicitly.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMaximumScaleIsAuto(true);
value - true if Excel calculates the maximum value for the value axis automatically; otherwise, false.Use getMinimumScaleIsAuto() to determine whether this value is calculated automatically by Excel or set explicitly with setMinimumScale(double).
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
double minimumScale = axis.getMinimumScale();
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinimumScale(100.0);
value - The minimum value on the value axis.When this method returns true, the minimum scale is determined by Excel. When it returns false, the minimum scale is set explicitly.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinimumScaleIsAuto(false);
boolean minimumScaleIsAuto = axis.getMinimumScaleIsAuto();
true if Excel calculates the minimum value for the value axis automatically; otherwise, false.When value is true, the minimum scale is determined by Excel. When value is false, the minimum scale is set explicitly.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 12},
{"Feb", 18},
{"Mar", 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinimumScaleIsAuto(false);
value - true if Excel calculates the minimum value for the value axis automatically; otherwise, false.IGridlines object that represents the minor gridlines for the specified axis.Only axes in the primary axis group can have gridlines. You can use the returned object to configure the appearance of minor gridlines after enabling them with setHasMinorGridlines(boolean).
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 10},
{"Feb", 20}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis valueAxis = shape.getChart().getAxes().item(AxisType.Value);
valueAxis.setHasMinorGridlines(true);
IGridlines minorGridlines = valueAxis.getMinorGridlines();
minorGridlines.getFormat().getLine().getColor().setRGB(Color.GetLightGray());
IGridlines object that represents the minor gridlines for the specified axis.Use this property to determine whether minor tick marks are displayed inside the axis, outside the axis, across the axis, or not displayed.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinorTickMark(TickMark.Inside);
TickMark tickMark = axis.getMinorTickMark();
Use this method to control how minor tick marks are displayed on the axis.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinorTickMark(TickMark.Inside);
value - The minor tick mark type.This property returns the interval between minor tick marks on a value axis. If getMinorUnitIsAuto() is true, the returned value is calculated automatically.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 10},
{"B", 30}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinorUnit(5d);
double minorUnit = axis.getMinorUnit();
This property sets the interval between minor tick marks on a value axis. If getMinorUnitIsAuto() is true, Excel calculates the minor unit automatically.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 10},
{"B", 30}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setMinorUnit(5d);
value - The minor unit value on the value axis.Returns true if the minor unit for the value axis is determined automatically by Excel.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 10},
{"B", 20}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3"));
IAxis axis = shape.getChart().getAxes().item(AxisType.Value);
boolean autoMinorUnit = axis.getMinorUnitIsAuto();
true if Excel calculates the minor units for the value axis; otherwise, false.Set value to true to let Excel determine the minor unit for the value axis automatically.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Name", "Value"},
{"A", 10},
{"B", 20}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3"));
IAxis axis = shape.getChart().getAxes().item(AxisType.Value);
axis.setMinorUnitIsAuto(true);
value - true if Excel calculates the minor units for the value axis; otherwise, false.getCategoryType() is CategoryType.TimeScale. If the minor unit is calculated automatically, this method returns the current base unit.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Date", "Sales"},
{45292d, 12},
{45323d, 18},
{45352d, 15}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryType(CategoryType.TimeScale);
axis.setMinorUnitScale(TimeUnit.Months);
TimeUnit minorUnitScale = axis.getMinorUnitScale();
CategoryType.TimeScale. Use this method together with setCategoryType(CategoryType) and setMinorUnit(double) to control how minor units are interpreted on a time-scaled category axis.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{null, "Sales"},
{new GregorianCalendar(2024, 0, 1), 10},
{new GregorianCalendar(2024, 0, 15), 18},
{new GregorianCalendar(2024, 1, 1), 25}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setCategoryType(CategoryType.TimeScale);
axis.setMinorUnitScale(TimeUnit.Days);
value - The time unit used as the minor unit scale on a time-scaled category axis. Should not be null.IAxes collection that contains this axis.Use this method to access the parent axes collection of the current axis when you need to work with other axes on the same chart.
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);
IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
IAxes axes = axis.getParent();
IAxes collection that contains this axis.This property returns true when the axis uses reverse plot order. Use setReversePlotOrder(boolean) to change the plot direction.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150},
{"Mar", 90}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
axis.setReversePlotOrder(true);
boolean reversePlotOrder = axis.getReversePlotOrder();
true if Excel plots data points from last to first; otherwise, false.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150},
{"Mar", 90}
});
IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 230);
shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B4"), RowCol.Columns, true, true);
IAxis axis = shape.getChart().getAxes().item(AxisType.Category);
axis.setReversePlotOrder(true);
value - true if Excel plots data points from last to first; otherwise, false.Use this method to determine whether the value axis uses a linear or logarithmic scale.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Item", "Value"},
{"A", 10},
{"B", 100},
{"C", 1000}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 10, 10, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setScaleType(ScaleType.Logarithmic);
ScaleType scaleType = axis.getScaleType();
Use this method to switch the value axis between linear and logarithmic scaling.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setScaleType(ScaleType.Logarithmic);
value - The scale type to apply to the value axis.Use this method to determine whether axis labels are displayed on the low side, high side, next to the axis, or hidden.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3")).getChart();
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
axis.setTickLabelPosition(TickLabelPosition.High);
TickLabelPosition position = axis.getTickLabelPosition();
TickLabelPosition value that specifies where tick-mark labels are displayed on the axis.Use TickLabelPosition to place tick-mark labels at the low side, high side, next to the axis, or hide them.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setTickLabelPosition(TickLabelPosition.High);
value - The tick-label position to apply.The returned ITickLabels object provides access to label formatting and layout settings for the axis, such as number format, text direction, and label offset.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 1200},
{"Feb", 1500},
{"Mar", 1100}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Value, AxisGroup.Primary);
ITickLabels tickLabels = axis.getTickLabels();
tickLabels.setNumberFormat("$#,##0");
ITickLabels object that represents the tick-mark labels for this axis.This property applies only to category and series axes. When tick label spacing is automatic, this method returns 1.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setTickLabelSpacing(2);
int spacing = axis.getTickLabelSpacing();
1 if tick label spacing is automatic.This property applies only to category and series axes. When tick label spacing is automatic, this method Sets 1.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setTickLabelSpacing(2);
value - The number of categories or series between tick-mark labels. Sets 1 if tick label spacing is automatic.When this property is true, the axis automatically calculates the spacing between tick-mark labels. When it is false, the spacing can be controlled by setTickLabelSpacing(int).
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3")).getChart();
IAxis axis = chart.getAxes().item(AxisType.Category);
boolean isAuto = axis.getTickLabelSpacingIsAuto();
true if tick label spacing is calculated automatically; otherwise, false.When this property is true, the axis automatically calculates the spacing between tick-mark labels. When it is false, the spacing can be controlled by setTickLabelSpacing(int).
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 120},
{"Feb", 150}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, worksheet.getRange("A1:B3")).getChart();
IAxis axis = chart.getAxes().item(AxisType.Category);
axis.setTickLabelSpacingIsAuto(true);
value - true if tick label spacing is calculated automatically; otherwise, false.This property applies only to category and series axes.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setTickMarkSpacing(2);
int spacing = axis.getTickMarkSpacing();
This property applies only to category and series axes.
worksheet.getRange("A1:B4").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 120},
{"Mar", 140}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B4"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setTickMarkSpacing(2);
value - The number of categories or series between tick marks.The returned AxisType indicates whether this axis is a category axis, value axis, or series axis.
worksheet.getRange("A1:B3").setValue(new Object[][] {
{"Month", "Sales"},
{"Jan", 100},
{"Feb", 200}
});
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 360, 220).getChart();
chart.getSeriesCollection().add(worksheet.getRange("A1:B3"));
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
AxisType type = axis.getType();
This property indicates whether the axis is displayed in the chart.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setVisible(false);
boolean visible = axis.getVisible();
true if the axis is visible; otherwise, false.Set this property to true to display the axis in the chart, or false to hide it.
IChart chart = worksheet.getShapes().addChart(ChartType.ColumnClustered, 20, 20, 300, 200).getChart();
IAxis axis = chart.getAxes().item(AxisType.Category, AxisGroup.Primary);
axis.setVisible(false);
value - true if the axis is visible; otherwise, false.