public class Axis
extends java.lang.Object
Example
From the following codes , you can learn how to set unit, maximum and minimum value of Axis.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a sample value to "A1" cell
worksheet.getCells().get("A1").putValue(50);
//Adding a sample value to "A2" cell
worksheet.getCells().get("A2").putValue(100);
//Adding a sample value to "A3" cell
worksheet.getCells().get("A3").putValue(150);
//Adding a sample value to "B1" cell
worksheet.getCells().get("B1").putValue(4);
//Adding a sample value to "B2" cell
worksheet.getCells().get("B2").putValue(20);
//Adding a sample value to "B3" cell
worksheet.getCells().get("B3").putValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.getNSeries().add("A1:B3", true);
//Set the max value of value axis
chart.getValueAxis().setMaxValue(200);
//Set the min value of value axis
chart.getValueAxis().setMinValue(0);
//Set the major unit
chart.getValueAxis().setMajorUnit(25);
//Category(X) axis crosses at the maxinum value.
chart.getValueAxis().setCrossType(CrossType.MAXIMUM);
//Set he number of categories or series between tick-mark labels.
chart.getCategoryAxis().setTickLabelSpacing(2);
//do your business
//Saving the Excel file
workbook.save("book1.xlsx");
| Modifier and Type | Method and Description |
|---|---|
Area |
getArea()
Gets the
Area. |
boolean |
getAxisBetweenCategories()
Represents if the value axis crosses the category axis between categories.
|
java.util.ArrayList |
getAxisLabels()
Deprecated.
Use Axis.GetAxisTexts method, instead.
|
Line |
getAxisLine()
Gets the appearance of an Axis.
|
java.lang.String[] |
getAxisTexts()
Gets the labels of the axis after call Chart.Calculate() method.
|
int |
getBaseUnitScale()
Represents the base unit scale for the category axis.
|
AxisBins |
getBins()
Represents bins on a chart(Histogram/Pareto) axis
|
int |
getCategoryType()
Represents the category axis type.
|
double |
getCrossAt()
Represents the point on the value axis where the category axis crosses it.
|
int |
getCrossType()
Represents the
getCrossType() on the specified axis where the other axis crosses. |
double |
getCustomDisplayUnit()
Specifies a custom value for the display unit.
|
int |
getCustomUnit()
Deprecated.
Use Axis.CustomDisplayUnit property, instead.
|
int |
getCustUnit()
Deprecated.
Use Axis.CustomUnit property, instead.
|
int |
getDisplayUnit()
Represents the unit label for the specified axis.
|
DisplayUnitLabel |
getDisplayUnitLabel()
Represents a unit label on an axis in the specified chart.
|
double |
getLogBase()
Represents the logarithmic base.
|
Line |
getMajorGridLines()
Represents major gridlines on a chart axis.
|
int |
getMajorTickMark()
Represents the type of major tick mark for the specified axis.
|
double |
getMajorUnit()
Represents the major units for the axis.
|
int |
getMajorUnitScale()
Represents the major unit scale for the category axis.
|
java.lang.Object |
getMaxValue()
Represents the maximum value on the value axis.
|
Line |
getMinorGridLines()
Represents minor gridlines on a chart axis.
|
int |
getMinorTickMark()
Represents the type of minor tick mark for the specified axis.
|
double |
getMinorUnit()
Represents the minor units for the axis.
|
int |
getMinorUnitScale()
Represents the major unit scale for the category axis.
|
java.lang.Object |
getMinValue()
Represents the minimum value on the value axis.
|
int |
getTickLabelPosition()
Represents the position of tick-mark labels on the specified axis.
|
TickLabels |
getTickLabels()
Returns a
getTickLabels() object that represents the tick-mark labels for the specified axis. |
int |
getTickLabelSpacing()
Represents the number of categories or series between tick-mark labels.
|
int |
getTickMarkSpacing()
Returns or sets the number of categories or series between tick marks.
|
Title |
getTitle()
Gets the axis' title.
|
boolean |
hasMultiLevelLabels()
Indicates whether the labels shall be shown as multi level.
|
boolean |
isAutomaticMajorUnit()
Indicates whether the major unit of the axis is automatically assigned.
|
boolean |
isAutomaticMaxValue()
Indicates whether the max value is automatically assigned.
|
boolean |
isAutomaticMinorUnit()
Indicates whether the minor unit of the axis is automatically assigned.
|
boolean |
isAutomaticMinValue()
Indicates whether the min value is automatically assigned.
|
boolean |
isAutoTickLabelSpacing()
Indicates whether the spacing of tick label is automatic
|
boolean |
isBaseUnitAuto()
Represents whether the base unit is automatic.
|
boolean |
isDisplayUnitLabelShown()
Represents if the display unit label is shown on the specified axis.
|
boolean |
isLogarithmic()
Represents if the value axis scale type is logarithmic or not.
|
boolean |
isPlotOrderReversed()
Represents if Microsoft Excel plots data points from last to first.
|
boolean |
isVisible()
Represents if the axis is visible.
|
void |
setAutomaticMajorUnit(boolean value)
Indicates whether the major unit of the axis is automatically assigned.
|
void |
setAutomaticMaxValue(boolean value)
Indicates whether the max value is automatically assigned.
|
void |
setAutomaticMinorUnit(boolean value)
Indicates whether the minor unit of the axis is automatically assigned.
|
void |
setAutomaticMinValue(boolean value)
Indicates whether the min value is automatically assigned.
|
void |
setAutoTickLabelSpacing(boolean value)
Indicates whether the spacing of tick label is automatic
|
void |
setAxisBetweenCategories(boolean value)
Represents if the value axis crosses the category axis between categories.
|
void |
setBaseUnitAuto(boolean value)
Represents whether the base unit is automatic.
|
void |
setBaseUnitScale(int value)
Represents the base unit scale for the category axis.
|
void |
setCategoryType(int value)
Represents the category axis type.
|
void |
setCrossAt(double value)
Represents the point on the value axis where the category axis crosses it.
|
void |
setCrossType(int value)
Represents the
getCrossType() on the specified axis where the other axis crosses. |
void |
setCustomDisplayUnit(double value)
Specifies a custom value for the display unit.
|
void |
setCustomUnit(int value)
Deprecated.
Use Axis.CustomDisplayUnit property, instead.
|
void |
setCustUnit(int value)
Deprecated.
Use Axis.CustomUnit property, instead.
|
void |
setDisplayUnit(int value)
Represents the unit label for the specified axis.
|
void |
setDisplayUnitLabelShown(boolean value)
Represents if the display unit label is shown on the specified axis.
|
void |
setHasMultiLevelLabels(boolean value)
Indicates whether the labels shall be shown as multi level.
|
void |
setLogarithmic(boolean value)
Represents if the value axis scale type is logarithmic or not.
|
void |
setLogBase(double value)
Represents the logarithmic base.
|
void |
setMajorTickMark(int value)
Represents the type of major tick mark for the specified axis.
|
void |
setMajorUnit(double value)
Represents the major units for the axis.
|
void |
setMajorUnitScale(int value)
Represents the major unit scale for the category axis.
|
void |
setMaxValue(java.lang.Object value)
Represents the maximum value on the value axis.
|
void |
setMinorTickMark(int value)
Represents the type of minor tick mark for the specified axis.
|
void |
setMinorUnit(double value)
Represents the minor units for the axis.
|
void |
setMinorUnitScale(int value)
Represents the major unit scale for the category axis.
|
void |
setMinValue(java.lang.Object value)
Represents the minimum value on the value axis.
|
void |
setPlotOrderReversed(boolean value)
Represents if Microsoft Excel plots data points from last to first.
|
void |
setTickLabelPosition(int value)
Represents the position of tick-mark labels on the specified axis.
|
void |
setTickLabelSpacing(int value)
Represents the number of categories or series between tick-mark labels.
|
void |
setTickMarkSpacing(int value)
Returns or sets the number of categories or series between tick marks.
|
void |
setVisible(boolean value)
Represents if the axis is visible.
|
public boolean isAutomaticMinValue()
public void setAutomaticMinValue(boolean value)
public java.lang.Object getMinValue()
Remarks
The minValue type only can be double or DateTimepublic void setMinValue(java.lang.Object value)
Remarks
The minValue type only can be double or DateTimepublic boolean isAutomaticMaxValue()
public void setAutomaticMaxValue(boolean value)
public java.lang.Object getMaxValue()
Remarks
The maxValue type only can be double or DateTimepublic void setMaxValue(java.lang.Object value)
Remarks
The maxValue type only can be double or DateTimepublic boolean isAutomaticMajorUnit()
public void setAutomaticMajorUnit(boolean value)
public double getMajorUnit()
Remarks
The major units must be greater than zero.public void setMajorUnit(double value)
Remarks
The major units must be greater than zero.public boolean isAutomaticMinorUnit()
public void setAutomaticMinorUnit(boolean value)
public double getMinorUnit()
Remarks
The minor units must be greater than zero.public void setMinorUnit(double value)
Remarks
The minor units must be greater than zero.public Line getAxisLine()
public int getMajorTickMark()
See TickMarkType.
public void setMajorTickMark(int value)
See TickMarkType.
public int getMinorTickMark()
See TickMarkType.
public void setMinorTickMark(int value)
See TickMarkType.
public int getTickLabelPosition()
public void setTickLabelPosition(int value)
public double getCrossAt()
Remarks
The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.public void setCrossAt(double value)
Remarks
The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.public int getCrossType()
getCrossType() on the specified axis where the other axis crosses.
See getCrossType().
public void setCrossType(int value)
getCrossType() on the specified axis where the other axis crosses.
See getCrossType().
public double getLogBase()
public void setLogBase(double value)
public boolean isLogarithmic()
public void setLogarithmic(boolean value)
public boolean isPlotOrderReversed()
public void setPlotOrderReversed(boolean value)
public boolean getAxisBetweenCategories()
Remarks
This property applies only to category axes, and it doesn't apply to 3-D charts.public void setAxisBetweenCategories(boolean value)
Remarks
This property applies only to category axes, and it doesn't apply to 3-D charts.public TickLabels getTickLabels()
getTickLabels() object that represents the tick-mark labels for the specified axis.public int getTickLabelSpacing()
Remarks
The number must be between 1 and 31999.public void setTickLabelSpacing(int value)
Remarks
The number must be between 1 and 31999.public boolean isAutoTickLabelSpacing()
public void setAutoTickLabelSpacing(boolean value)
public int getTickMarkSpacing()
Remarks
The number must be between 1 and 31999.public void setTickMarkSpacing(int value)
Remarks
The number must be between 1 and 31999.public int getDisplayUnit()
See DisplayUnitType.
public void setDisplayUnit(int value)
See DisplayUnitType.
public int getCustUnit()
Remarks
NOTE: This property is now obsolete. Instead, please use Axis.CustomUnit property. This property will be removed 12 months later since January 2023. Aspose apologizes for any inconvenience you may have experienced.public void setCustUnit(int value)
Remarks
NOTE: This property is now obsolete. Instead, please use Axis.CustomUnit property. This property will be removed 12 months later since January 2023. Aspose apologizes for any inconvenience you may have experienced.public int getCustomUnit()
Remarks
NOTE: This property is now obsolete. Instead, please use Axis.CustomDisplayUnit property. This property will be removed 12 months later since February 2025. Aspose apologizes for any inconvenience you may have experienced.public void setCustomUnit(int value)
Remarks
NOTE: This property is now obsolete. Instead, please use Axis.CustomDisplayUnit property. This property will be removed 12 months later since February 2025. Aspose apologizes for any inconvenience you may have experienced.public double getCustomDisplayUnit()
public void setCustomDisplayUnit(double value)
public DisplayUnitLabel getDisplayUnitLabel()
public boolean isDisplayUnitLabelShown()
Remarks
The default value is True.public void setDisplayUnitLabelShown(boolean value)
Remarks
The default value is True.public Title getTitle()
public int getCategoryType()
See CategoryType.
public void setCategoryType(int value)
See CategoryType.
public int getBaseUnitScale()
See TimeUnit.
Remarks
Setting this property only takes effect when the CategoryType property is set to TimeScale.public void setBaseUnitScale(int value)
See TimeUnit.
Remarks
Setting this property only takes effect when the CategoryType property is set to TimeScale.public boolean isBaseUnitAuto()
public void setBaseUnitAuto(boolean value)
public int getMajorUnitScale()
See TimeUnit.
Example
chart.getCategoryAxis().setCategoryType(CategoryType.TIME_SCALE);
chart.getCategoryAxis().setMajorUnitScale(TimeUnit.MONTHS);
chart.getCategoryAxis().setMajorUnit(2);
public void setMajorUnitScale(int value)
See TimeUnit.
public int getMinorUnitScale()
See TimeUnit.
Example
chart.getCategoryAxis().setCategoryType(CategoryType.TIME_SCALE);
chart.getCategoryAxis().setMinorUnitScale(TimeUnit.MONTHS);
chart.getCategoryAxis().setMinorUnit(2);
public void setMinorUnitScale(int value)
See TimeUnit.
public boolean isVisible()
public void setVisible(boolean value)
public Line getMajorGridLines()
Example
chart.getValueAxis().getMajorGridLines().setVisible(false);
chart.getCategoryAxis().getMajorGridLines().setVisible(true);
public Line getMinorGridLines()
public boolean hasMultiLevelLabels()
Remarks
Only valid for category axis.public void setHasMultiLevelLabels(boolean value)
Remarks
Only valid for category axis.public java.lang.String[] getAxisTexts()
public java.util.ArrayList getAxisLabels()
Remarks
NOTE: This member is now obsolete. Instead, please use Axis.GetAxisTexts method. This property will be removed 12 months later since November 2023. Aspose apologizes for any inconvenience you may have experienced.public AxisBins getBins()
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.