Axis

Inheritance: java.lang.Object

public class Axis

Encapsulates the object that represents an axis of chart.

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");

Methods

MethodDescription
equals(Object arg0)
getArea()Gets the Area.
getAxisBetweenCategories()Represents if the value axis crosses the category axis between categories.
getAxisLabels()Gets the labels of the axis after call Chart.Calculate() method.
getAxisLine()Gets the appearance of an Axis.
getAxisTexts()Gets the labels of the axis after call Chart.Calculate() method.
getBaseUnitScale()Represents the base unit scale for the category axis.
getBins()Represents bins on a chart(Histogram/Pareto) axis
getCategoryType()Represents the category axis type.
getClass()
getCrossAt()Represents the point on the value axis where the category axis crosses it.
getCrossType()Represents the getCrossType() on the specified axis where the other axis crosses.
getCustUnit()Specifies a custom value for the display unit.
getCustomUnit()Specifies a custom value for the display unit.
getDisplayUnit()Represents the unit label for the specified axis.
getDisplayUnitLabel()Represents a unit label on an axis in the specified chart.
getLogBase()Represents the logarithmic base.
getMajorGridLines()Represents major gridlines on a chart axis.
getMajorTickMark()Represents the type of major tick mark for the specified axis.
getMajorUnit()Represents the major units for the axis.
getMajorUnitScale()Represents the major unit scale for the category axis.
getMaxValue()Represents the maximum value on the value axis.
getMinValue()Represents the minimum value on the value axis.
getMinorGridLines()Represents minor gridlines on a chart axis.
getMinorTickMark()Represents the type of minor tick mark for the specified axis.
getMinorUnit()Represents the minor units for the axis.
getMinorUnitScale()Represents the major unit scale for the category axis.
getTickLabelPosition()Represents the position of tick-mark labels on the specified axis.
getTickLabelSpacing()Represents the number of categories or series between tick-mark labels.
getTickLabels()Returns a getTickLabels() object that represents the tick-mark labels for the specified axis.
getTickMarkSpacing()Returns or sets the number of categories or series between tick marks.
getTitle()Gets the axis’ title.
hasMultiLevelLabels()Indicates whether the labels shall be shown as multi level.
hashCode()
isAutoTickLabelSpacing()Indicates whether the spacing of tick label is automatic
isAutomaticMajorUnit()Indicates whether the major unit of the axis is automatically assigned.
isAutomaticMaxValue()Indicates whether the max value is automatically assigned.
isAutomaticMinValue()Indicates whether the min value is automatically assigned.
isAutomaticMinorUnit()Indicates whether the minor unit of the axis is automatically assigned.
isBaseUnitAuto()Represents whether the base unit is automatic.
isDisplayUnitLabelShown()Represents if the display unit label is shown on the specified axis.
isLogarithmic()Represents if the value axis scale type is logarithmic or not.
isPlotOrderReversed()Represents if Microsoft Excel plots data points from last to first.
isVisible()Represents if the axis is visible.
notify()
notifyAll()
setAutoTickLabelSpacing(boolean value)Indicates whether the spacing of tick label is automatic
setAutomaticMajorUnit(boolean value)Indicates whether the major unit of the axis is automatically assigned.
setAutomaticMaxValue(boolean value)Indicates whether the max value is automatically assigned.
setAutomaticMinValue(boolean value)Indicates whether the min value is automatically assigned.
setAutomaticMinorUnit(boolean value)Indicates whether the minor unit of the axis is automatically assigned.
setAxisBetweenCategories(boolean value)Represents if the value axis crosses the category axis between categories.
setBaseUnitAuto(boolean value)Represents whether the base unit is automatic.
setBaseUnitScale(int value)Represents the base unit scale for the category axis.
setCategoryType(int value)Represents the category axis type.
setCrossAt(double value)Represents the point on the value axis where the category axis crosses it.
setCrossType(int value)Represents the getCrossType() on the specified axis where the other axis crosses.
setCustUnit(int value)Specifies a custom value for the display unit.
setCustomUnit(int value)Specifies a custom value for the display unit.
setDisplayUnit(int value)Represents the unit label for the specified axis.
setDisplayUnitLabelShown(boolean value)Represents if the display unit label is shown on the specified axis.
setHasMultiLevelLabels(boolean value)Indicates whether the labels shall be shown as multi level.
setLogBase(double value)Represents the logarithmic base.
setLogarithmic(boolean value)Represents if the value axis scale type is logarithmic or not.
setMajorTickMark(int value)Represents the type of major tick mark for the specified axis.
setMajorUnit(double value)Represents the major units for the axis.
setMajorUnitScale(int value)Represents the major unit scale for the category axis.
setMaxValue(Object value)Represents the maximum value on the value axis.
setMinValue(Object value)Represents the minimum value on the value axis.
setMinorTickMark(int value)Represents the type of minor tick mark for the specified axis.
setMinorUnit(double value)Represents the minor units for the axis.
setMinorUnitScale(int value)Represents the major unit scale for the category axis.
setPlotOrderReversed(boolean value)Represents if Microsoft Excel plots data points from last to first.
setTickLabelPosition(int value)Represents the position of tick-mark labels on the specified axis.
setTickLabelSpacing(int value)Represents the number of categories or series between tick-mark labels.
setTickMarkSpacing(int value)Returns or sets the number of categories or series between tick marks.
setVisible(boolean value)Represents if the axis is visible.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getArea()

public Area getArea()

Gets the Area.

Returns: Area

getAxisBetweenCategories()

public boolean getAxisBetweenCategories()

Represents if the value axis crosses the category axis between categories.

Remarks

This property applies only to category axes, and it doesn’t apply to 3-D charts.

Returns: boolean

getAxisLabels()

public ArrayList getAxisLabels()

Gets the labels of the axis after call Chart.Calculate() method.

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.

Returns: java.util.ArrayList

getAxisLine()

public Line getAxisLine()

Gets the appearance of an Axis.

Returns: Line

getAxisTexts()

public String[] getAxisTexts()

Gets the labels of the axis after call Chart.Calculate() method.

Returns: java.lang.String[]

getBaseUnitScale()

public int getBaseUnitScale()

Represents the base unit scale for the category axis.

See TimeUnit.

Remarks

Setting this property only takes effect when the CategoryType property is set to TimeScale.

Returns: int

getBins()

public AxisBins getBins()

Represents bins on a chart(Histogram/Pareto) axis

Returns: AxisBins

getCategoryType()

public int getCategoryType()

Represents the category axis type.

See CategoryType.

Returns: int

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCrossAt()

public double getCrossAt()

Represents the point on the value axis where the category axis crosses it.

Remarks

The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.

Returns: double

getCrossType()

public int getCrossType()

Represents the getCrossType() on the specified axis where the other axis crosses.

See getCrossType().

Returns: int

getCustUnit()

public int getCustUnit()

Specifies a custom value for the display unit.

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.

Returns: int

getCustomUnit()

public int getCustomUnit()

Specifies a custom value for the display unit.

Returns: int

getDisplayUnit()

public int getDisplayUnit()

Represents the unit label for the specified axis.

See DisplayUnitType.

Returns: int

getDisplayUnitLabel()

public DisplayUnitLabel getDisplayUnitLabel()

Represents a unit label on an axis in the specified chart. Unit labels are useful for charting large values\u9225?for example, in the millions or billions.

Returns: DisplayUnitLabel

getLogBase()

public double getLogBase()

Represents the logarithmic base. Default value is 10.Only applies for Excel2007.

Returns: double

getMajorGridLines()

public Line getMajorGridLines()

Represents major gridlines on a chart axis.

Example

         chart.getValueAxis().getMajorGridLines().setVisible(false);
         chart.getCategoryAxis().getMajorGridLines().setVisible(true);

Returns: Line

getMajorTickMark()

public int getMajorTickMark()

Represents the type of major tick mark for the specified axis.

See TickMarkType.

Returns: int

getMajorUnit()

public double getMajorUnit()

Represents the major units for the axis.

Remarks

The major units must be greater than zero.

Returns: double

getMajorUnitScale()

public int getMajorUnitScale()

Represents the major unit scale for the category axis.

See TimeUnit.

Example

         chart.getCategoryAxis().setCategoryType(CategoryType.TIME_SCALE);
         chart.getCategoryAxis().setMajorUnitScale(TimeUnit.MONTHS);
         chart.getCategoryAxis().setMajorUnit(2);

Returns: int

getMaxValue()

public Object getMaxValue()

Represents the maximum value on the value axis.

Remarks

The maxValue type only can be double or DateTime

Returns: java.lang.Object

getMinValue()

public Object getMinValue()

Represents the minimum value on the value axis.

Remarks

The minValue type only can be double or DateTime

Returns: java.lang.Object

getMinorGridLines()

public Line getMinorGridLines()

Represents minor gridlines on a chart axis.

Returns: Line

getMinorTickMark()

public int getMinorTickMark()

Represents the type of minor tick mark for the specified axis.

See TickMarkType.

Returns: int

getMinorUnit()

public double getMinorUnit()

Represents the minor units for the axis.

Remarks

The minor units must be greater than zero.

Returns: double

getMinorUnitScale()

public int getMinorUnitScale()

Represents the major unit scale for the category axis.

See TimeUnit.

Example

         chart.getCategoryAxis().setCategoryType(CategoryType.TIME_SCALE);
         chart.getCategoryAxis().setMinorUnitScale(TimeUnit.MONTHS);
         chart.getCategoryAxis().setMinorUnit(2);

Returns: int

getTickLabelPosition()

public int getTickLabelPosition()

Represents the position of tick-mark labels on the specified axis.

See TickLabelPositionType.

Returns: int

getTickLabelSpacing()

public int getTickLabelSpacing()

Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.

Remarks

The number must be between 1 and 31999.

Returns: int

getTickLabels()

public TickLabels getTickLabels()

Returns a getTickLabels() object that represents the tick-mark labels for the specified axis.

Returns: TickLabels

getTickMarkSpacing()

public int getTickMarkSpacing()

Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.

Remarks

The number must be between 1 and 31999.

Returns: int

getTitle()

public Title getTitle()

Gets the axis’ title.

Returns: Title

hasMultiLevelLabels()

public boolean hasMultiLevelLabels()

Indicates whether the labels shall be shown as multi level.

Remarks

Only valid for category axis.

Returns: boolean

hashCode()

public native int hashCode()

Returns: int

isAutoTickLabelSpacing()

public boolean isAutoTickLabelSpacing()

Indicates whether the spacing of tick label is automatic

Returns: boolean

isAutomaticMajorUnit()

public boolean isAutomaticMajorUnit()

Indicates whether the major unit of the axis is automatically assigned.

Returns: boolean

isAutomaticMaxValue()

public boolean isAutomaticMaxValue()

Indicates whether the max value is automatically assigned.

Returns: boolean

isAutomaticMinValue()

public boolean isAutomaticMinValue()

Indicates whether the min value is automatically assigned.

Returns: boolean

isAutomaticMinorUnit()

public boolean isAutomaticMinorUnit()

Indicates whether the minor unit of the axis is automatically assigned.

Returns: boolean

isBaseUnitAuto()

public boolean isBaseUnitAuto()

Represents whether the base unit is automatic.

Returns: boolean

isDisplayUnitLabelShown()

public boolean isDisplayUnitLabelShown()

Represents if the display unit label is shown on the specified axis.

Remarks

The default value is True.

Returns: boolean

isLogarithmic()

public boolean isLogarithmic()

Represents if the value axis scale type is logarithmic or not.

Returns: boolean

isPlotOrderReversed()

public boolean isPlotOrderReversed()

Represents if Microsoft Excel plots data points from last to first.

Returns: boolean

isVisible()

public boolean isVisible()

Represents if the axis is visible.

Returns: boolean

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setAutoTickLabelSpacing(boolean value)

public void setAutoTickLabelSpacing(boolean value)

Indicates whether the spacing of tick label is automatic

Parameters:

ParameterTypeDescription
valueboolean

setAutomaticMajorUnit(boolean value)

public void setAutomaticMajorUnit(boolean value)

Indicates whether the major unit of the axis is automatically assigned.

Parameters:

ParameterTypeDescription
valueboolean

setAutomaticMaxValue(boolean value)

public void setAutomaticMaxValue(boolean value)

Indicates whether the max value is automatically assigned.

Parameters:

ParameterTypeDescription
valueboolean

setAutomaticMinValue(boolean value)

public void setAutomaticMinValue(boolean value)

Indicates whether the min value is automatically assigned.

Parameters:

ParameterTypeDescription
valueboolean

setAutomaticMinorUnit(boolean value)

public void setAutomaticMinorUnit(boolean value)

Indicates whether the minor unit of the axis is automatically assigned.

Parameters:

ParameterTypeDescription
valueboolean

setAxisBetweenCategories(boolean value)

public void setAxisBetweenCategories(boolean value)

Represents if the value axis crosses the category axis between categories.

Remarks

This property applies only to category axes, and it doesn’t apply to 3-D charts.

Parameters:

ParameterTypeDescription
valueboolean

setBaseUnitAuto(boolean value)

public void setBaseUnitAuto(boolean value)

Represents whether the base unit is automatic.

Parameters:

ParameterTypeDescription
valueboolean

setBaseUnitScale(int value)

public void setBaseUnitScale(int value)

Represents the base unit scale for the category axis.

See TimeUnit.

Remarks

Setting this property only takes effect when the CategoryType property is set to TimeScale.

Parameters:

ParameterTypeDescription
valueint

setCategoryType(int value)

public void setCategoryType(int value)

Represents the category axis type.

See CategoryType.

Parameters:

ParameterTypeDescription
valueint

setCrossAt(double value)

public void setCrossAt(double value)

Represents the point on the value axis where the category axis crosses it.

Remarks

The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.

Parameters:

ParameterTypeDescription
valuedouble

setCrossType(int value)

public void setCrossType(int value)

Represents the getCrossType() on the specified axis where the other axis crosses.

See getCrossType().

Parameters:

ParameterTypeDescription
valueint

setCustUnit(int value)

public void setCustUnit(int value)

Specifies a custom value for the display unit.

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.

Parameters:

ParameterTypeDescription
valueint

setCustomUnit(int value)

public void setCustomUnit(int value)

Specifies a custom value for the display unit.

Parameters:

ParameterTypeDescription
valueint

setDisplayUnit(int value)

public void setDisplayUnit(int value)

Represents the unit label for the specified axis.

See DisplayUnitType.

Parameters:

ParameterTypeDescription
valueint

setDisplayUnitLabelShown(boolean value)

public void setDisplayUnitLabelShown(boolean value)

Represents if the display unit label is shown on the specified axis.

Remarks

The default value is True.

Parameters:

ParameterTypeDescription
valueboolean

setHasMultiLevelLabels(boolean value)

public void setHasMultiLevelLabels(boolean value)

Indicates whether the labels shall be shown as multi level.

Remarks

Only valid for category axis.

Parameters:

ParameterTypeDescription
valueboolean

setLogBase(double value)

public void setLogBase(double value)

Represents the logarithmic base. Default value is 10.Only applies for Excel2007.

Parameters:

ParameterTypeDescription
valuedouble

setLogarithmic(boolean value)

public void setLogarithmic(boolean value)

Represents if the value axis scale type is logarithmic or not.

Parameters:

ParameterTypeDescription
valueboolean

setMajorTickMark(int value)

public void setMajorTickMark(int value)

Represents the type of major tick mark for the specified axis.

See TickMarkType.

Parameters:

ParameterTypeDescription
valueint

setMajorUnit(double value)

public void setMajorUnit(double value)

Represents the major units for the axis.

Remarks

The major units must be greater than zero.

Parameters:

ParameterTypeDescription
valuedouble

setMajorUnitScale(int value)

public void setMajorUnitScale(int value)

Represents the major unit scale for the category axis.

See TimeUnit.

Parameters:

ParameterTypeDescription
valueint

setMaxValue(Object value)

public void setMaxValue(Object value)

Represents the maximum value on the value axis.

Remarks

The maxValue type only can be double or DateTime

Parameters:

ParameterTypeDescription
valuejava.lang.Object

setMinValue(Object value)

public void setMinValue(Object value)

Represents the minimum value on the value axis.

Remarks

The minValue type only can be double or DateTime

Parameters:

ParameterTypeDescription
valuejava.lang.Object

setMinorTickMark(int value)

public void setMinorTickMark(int value)

Represents the type of minor tick mark for the specified axis.

See TickMarkType.

Parameters:

ParameterTypeDescription
valueint

setMinorUnit(double value)

public void setMinorUnit(double value)

Represents the minor units for the axis.

Remarks

The minor units must be greater than zero.

Parameters:

ParameterTypeDescription
valuedouble

setMinorUnitScale(int value)

public void setMinorUnitScale(int value)

Represents the major unit scale for the category axis.

See TimeUnit.

Parameters:

ParameterTypeDescription
valueint

setPlotOrderReversed(boolean value)

public void setPlotOrderReversed(boolean value)

Represents if Microsoft Excel plots data points from last to first.

Parameters:

ParameterTypeDescription
valueboolean

setTickLabelPosition(int value)

public void setTickLabelPosition(int value)

Represents the position of tick-mark labels on the specified axis.

See TickLabelPositionType.

Parameters:

ParameterTypeDescription
valueint

setTickLabelSpacing(int value)

public void setTickLabelSpacing(int value)

Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.

Remarks

The number must be between 1 and 31999.

Parameters:

ParameterTypeDescription
valueint

setTickMarkSpacing(int value)

public void setTickMarkSpacing(int value)

Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.

Remarks

The number must be between 1 and 31999.

Parameters:

ParameterTypeDescription
valueint

setVisible(boolean value)

public void setVisible(boolean value)

Represents if the axis is visible.

Parameters:

ParameterTypeDescription
valueboolean

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int