Axis
Axis class
Encapsulates the object that represents an axis of chart.
class Axis;
Example
const { Workbook, ChartType, CrossType } = require("aspose.cells.node");
//Instantiating a Workbook object
var workbook = new Workbook();
//Adding a new worksheet to the Excel object
var sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var 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
var chartIndex = worksheet.getCharts().add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
var 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);
//Saving the Excel file
workbook.save("output/ChartsAxis.xlsx");
Methods
Method | Description |
---|---|
getArea() | Gets the Area. |
isAutomaticMinValue() | Indicates whether the min value is automatically assigned. |
setIsAutomaticMinValue(boolean) | Indicates whether the min value is automatically assigned. |
getMinValue() | Represents the minimum value on the value axis. |
setMinValue(object) | Represents the minimum value on the value axis. |
isAutomaticMaxValue() | Indicates whether the max value is automatically assigned. |
setIsAutomaticMaxValue(boolean) | Indicates whether the max value is automatically assigned. |
getMaxValue() | Represents the maximum value on the value axis. |
setMaxValue(object) | Represents the maximum value on the value axis. |
isAutomaticMajorUnit() | Indicates whether the major unit of the axis is automatically assigned. |
setIsAutomaticMajorUnit(boolean) | Indicates whether the major unit of the axis is automatically assigned. |
getMajorUnit() | Represents the major units for the axis. |
setMajorUnit(number) | Represents the major units for the axis. |
isAutomaticMinorUnit() | Indicates whether the minor unit of the axis is automatically assigned. |
setIsAutomaticMinorUnit(boolean) | Indicates whether the minor unit of the axis is automatically assigned. |
getMinorUnit() | Represents the minor units for the axis. |
setMinorUnit(number) | Represents the minor units for the axis. |
getAxisLine() | Gets the appearance of an Axis. |
getMajorTickMark() | Represents the type of major tick mark for the specified axis. |
setMajorTickMark(TickMarkType) | Represents the type of major tick mark for the specified axis. |
getMinorTickMark() | Represents the type of minor tick mark for the specified axis. |
setMinorTickMark(TickMarkType) | Represents the type of minor tick mark for the specified axis. |
getTickLabelPosition() | Represents the position of tick-mark labels on the specified axis. |
setTickLabelPosition(TickLabelPositionType) | Represents the position of tick-mark labels on the specified axis. |
getCrossAt() | Represents the point on the value axis where the category axis crosses it. |
setCrossAt(number) | Represents the point on the value axis where the category axis crosses it. |
getCrossType() | Represents the CrossType on the specified axis where the other axis crosses. |
setCrossType(CrossType) | Represents the CrossType on the specified axis where the other axis crosses. |
getLogBase() | Represents the logarithmic base. Default value is 10.Only applies for Excel2007. |
setLogBase(number) | Represents the logarithmic base. Default value is 10.Only applies for Excel2007. |
isLogarithmic() | Represents if the value axis scale type is logarithmic or not. |
setIsLogarithmic(boolean) | Represents if the value axis scale type is logarithmic or not. |
isPlotOrderReversed() | Represents if Microsoft Excel plots data points from last to first. |
setIsPlotOrderReversed(boolean) | Represents if Microsoft Excel plots data points from last to first. |
getAxisBetweenCategories() | Represents if the value axis crosses the category axis between categories. |
setAxisBetweenCategories(boolean) | Represents if the value axis crosses the category axis between categories. |
getTickLabels() | Returns a TickLabels object that represents the tick-mark labels for the specified axis. |
getTickLabelSpacing() | Represents the number of categories or series between tick-mark labels. Applies only to category and series axes. |
setTickLabelSpacing(number) | Represents the number of categories or series between tick-mark labels. Applies only to category and series axes. |
isAutoTickLabelSpacing() | Indicates whether the spacing of tick label is automatic |
setIsAutoTickLabelSpacing(boolean) | Indicates whether the spacing of tick label is automatic |
getTickMarkSpacing() | Returns or sets the number of categories or series between tick marks. Applies only to category and series axes. |
setTickMarkSpacing(number) | Returns or sets the number of categories or series between tick marks. Applies only to category and series axes. |
getDisplayUnit() | Represents the unit label for the specified axis. |
setDisplayUnit(DisplayUnitType) | Represents the unit label for the specified axis. |
getCustomUnit() | Specifies a custom value for the display unit. |
setCustomUnit(number) | Specifies a custom value for the display unit. |
getDisplayUnitLabel() | Represents a unit label on an axis in the specified chart. Unit labels are useful for charting large values— for example, in the millions or billions. |
isDisplayUnitLabelShown() | Represents if the display unit label is shown on the specified axis. |
setIsDisplayUnitLabelShown(boolean) | Represents if the display unit label is shown on the specified axis. |
getTitle() | Gets the axis’ title. |
getCategoryType() | Represents the category axis type. |
setCategoryType(CategoryType) | Represents the category axis type. |
getBaseUnitScale() | Represents the base unit scale for the category axis. |
setBaseUnitScale(TimeUnit) | Represents the base unit scale for the category axis. |
getMajorUnitScale() | Represents the major unit scale for the category axis. |
setMajorUnitScale(TimeUnit) | Represents the major unit scale for the category axis. |
getMinorUnitScale() | Represents the major unit scale for the category axis. |
setMinorUnitScale(TimeUnit) | Represents the major unit scale for the category axis. |
isVisible() | Represents if the axis is visible. |
setIsVisible(boolean) | Represents if the axis is visible. |
getMajorGridLines() | Represents major gridlines on a chart axis. |
getMinorGridLines() | Represents minor gridlines on a chart axis. |
getHasMultiLevelLabels() | Indicates whether the labels shall be shown as multi level. |
setHasMultiLevelLabels(boolean) | Indicates whether the labels shall be shown as multi level. |
getBins() | Represents bins on a chart(Histogram/Pareto) axis |
getAxisTexts() | Gets the labels of the axis after call Chart.Calculate() method. |
isNull() | Checks whether the implementation object is null. |
getArea()
Gets the Area.
getArea() : Area;
Returns
isAutomaticMinValue()
Indicates whether the min value is automatically assigned.
isAutomaticMinValue() : boolean;
setIsAutomaticMinValue(boolean)
Indicates whether the min value is automatically assigned.
setIsAutomaticMinValue(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getMinValue()
Represents the minimum value on the value axis.
getMinValue() : object;
Remarks
The minValue type only can be double or DateTime
setMinValue(object)
Represents the minimum value on the value axis.
setMinValue(value: object) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | object | The value to set. |
Remarks
The minValue type only can be double or DateTime
isAutomaticMaxValue()
Indicates whether the max value is automatically assigned.
isAutomaticMaxValue() : boolean;
setIsAutomaticMaxValue(boolean)
Indicates whether the max value is automatically assigned.
setIsAutomaticMaxValue(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getMaxValue()
Represents the maximum value on the value axis.
getMaxValue() : object;
Remarks
The maxValue type only can be double or DateTime
setMaxValue(object)
Represents the maximum value on the value axis.
setMaxValue(value: object) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | object | The value to set. |
Remarks
The maxValue type only can be double or DateTime
isAutomaticMajorUnit()
Indicates whether the major unit of the axis is automatically assigned.
isAutomaticMajorUnit() : boolean;
setIsAutomaticMajorUnit(boolean)
Indicates whether the major unit of the axis is automatically assigned.
setIsAutomaticMajorUnit(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getMajorUnit()
Represents the major units for the axis.
getMajorUnit() : number;
Remarks
The major units must be greater than zero.
setMajorUnit(number)
Represents the major units for the axis.
setMajorUnit(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
The major units must be greater than zero.
isAutomaticMinorUnit()
Indicates whether the minor unit of the axis is automatically assigned.
isAutomaticMinorUnit() : boolean;
setIsAutomaticMinorUnit(boolean)
Indicates whether the minor unit of the axis is automatically assigned.
setIsAutomaticMinorUnit(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getMinorUnit()
Represents the minor units for the axis.
getMinorUnit() : number;
Remarks
The minor units must be greater than zero.
setMinorUnit(number)
Represents the minor units for the axis.
setMinorUnit(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
The minor units must be greater than zero.
getAxisLine()
Gets the appearance of an Axis.
getAxisLine() : Line;
Returns
getMajorTickMark()
Represents the type of major tick mark for the specified axis.
getMajorTickMark() : TickMarkType;
Returns
setMajorTickMark(TickMarkType)
Represents the type of major tick mark for the specified axis.
setMajorTickMark(value: TickMarkType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TickMarkType | The value to set. |
getMinorTickMark()
Represents the type of minor tick mark for the specified axis.
getMinorTickMark() : TickMarkType;
Returns
setMinorTickMark(TickMarkType)
Represents the type of minor tick mark for the specified axis.
setMinorTickMark(value: TickMarkType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TickMarkType | The value to set. |
getTickLabelPosition()
Represents the position of tick-mark labels on the specified axis.
getTickLabelPosition() : TickLabelPositionType;
Returns
setTickLabelPosition(TickLabelPositionType)
Represents the position of tick-mark labels on the specified axis.
setTickLabelPosition(value: TickLabelPositionType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TickLabelPositionType | The value to set. |
getCrossAt()
Represents the point on the value axis where the category axis crosses it.
getCrossAt() : number;
Remarks
The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.
setCrossAt(number)
Represents the point on the value axis where the category axis crosses it.
setCrossAt(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.
getCrossType()
Represents the CrossType on the specified axis where the other axis crosses.
getCrossType() : CrossType;
Returns
setCrossType(CrossType)
Represents the CrossType on the specified axis where the other axis crosses.
setCrossType(value: CrossType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | CrossType | The value to set. |
getLogBase()
Represents the logarithmic base. Default value is 10.Only applies for Excel2007.
getLogBase() : number;
setLogBase(number)
Represents the logarithmic base. Default value is 10.Only applies for Excel2007.
setLogBase(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
isLogarithmic()
Represents if the value axis scale type is logarithmic or not.
isLogarithmic() : boolean;
setIsLogarithmic(boolean)
Represents if the value axis scale type is logarithmic or not.
setIsLogarithmic(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
isPlotOrderReversed()
Represents if Microsoft Excel plots data points from last to first.
isPlotOrderReversed() : boolean;
setIsPlotOrderReversed(boolean)
Represents if Microsoft Excel plots data points from last to first.
setIsPlotOrderReversed(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getAxisBetweenCategories()
Represents if the value axis crosses the category axis between categories.
getAxisBetweenCategories() : boolean;
Remarks
This property applies only to category axes, and it doesn’t apply to 3-D charts.
setAxisBetweenCategories(boolean)
Represents if the value axis crosses the category axis between categories.
setAxisBetweenCategories(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
Remarks
This property applies only to category axes, and it doesn’t apply to 3-D charts.
getTickLabels()
Returns a TickLabels object that represents the tick-mark labels for the specified axis.
getTickLabels() : TickLabels;
Returns
getTickLabelSpacing()
Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.
getTickLabelSpacing() : number;
Remarks
The number must be between 1 and 31999.
setTickLabelSpacing(number)
Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.
setTickLabelSpacing(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
The number must be between 1 and 31999.
isAutoTickLabelSpacing()
Indicates whether the spacing of tick label is automatic
isAutoTickLabelSpacing() : boolean;
setIsAutoTickLabelSpacing(boolean)
Indicates whether the spacing of tick label is automatic
setIsAutoTickLabelSpacing(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getTickMarkSpacing()
Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.
getTickMarkSpacing() : number;
Remarks
The number must be between 1 and 31999.
setTickMarkSpacing(number)
Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.
setTickMarkSpacing(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
The number must be between 1 and 31999.
getDisplayUnit()
Represents the unit label for the specified axis.
getDisplayUnit() : DisplayUnitType;
Returns
setDisplayUnit(DisplayUnitType)
Represents the unit label for the specified axis.
setDisplayUnit(value: DisplayUnitType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | DisplayUnitType | The value to set. |
getCustomUnit()
Specifies a custom value for the display unit.
getCustomUnit() : number;
setCustomUnit(number)
Specifies a custom value for the display unit.
setCustomUnit(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
getDisplayUnitLabel()
Represents a unit label on an axis in the specified chart. Unit labels are useful for charting large values— for example, in the millions or billions.
getDisplayUnitLabel() : DisplayUnitLabel;
Returns
isDisplayUnitLabelShown()
Represents if the display unit label is shown on the specified axis.
isDisplayUnitLabelShown() : boolean;
Remarks
The default value is True.
setIsDisplayUnitLabelShown(boolean)
Represents if the display unit label is shown on the specified axis.
setIsDisplayUnitLabelShown(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
Remarks
The default value is True.
getTitle()
Gets the axis’ title.
getTitle() : Title;
Returns
getCategoryType()
Represents the category axis type.
getCategoryType() : CategoryType;
Returns
setCategoryType(CategoryType)
Represents the category axis type.
setCategoryType(value: CategoryType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | CategoryType | The value to set. |
getBaseUnitScale()
Represents the base unit scale for the category axis.
getBaseUnitScale() : TimeUnit;
Returns
Remarks
Setting this property only takes effect when the CategoryType property is set to TimeScale.
setBaseUnitScale(TimeUnit)
Represents the base unit scale for the category axis.
setBaseUnitScale(value: TimeUnit) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TimeUnit | The value to set. |
Remarks
Setting this property only takes effect when the CategoryType property is set to TimeScale.
getMajorUnitScale()
Represents the major unit scale for the category axis.
getMajorUnitScale() : TimeUnit;
Returns
setMajorUnitScale(TimeUnit)
Represents the major unit scale for the category axis.
setMajorUnitScale(value: TimeUnit) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TimeUnit | The value to set. |
Example
const { Workbook, ChartType, CategoryType, TimeUnit } = require("aspose.cells.node");
var workbook = new Workbook();
//Adding a new worksheet to the Excel object
var sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var 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
var chartIndex = worksheet.getCharts().add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
var chart = worksheet.getCharts().get(chartIndex);
chart.getCategoryAxis().setCategoryType(CategoryType.TimeScale);
chart.getCategoryAxis().setMajorUnitScale(TimeUnit.Months);
chart.getCategoryAxis().setMajorUnit(2);
getMinorUnitScale()
Represents the major unit scale for the category axis.
getMinorUnitScale() : TimeUnit;
Returns
setMinorUnitScale(TimeUnit)
Represents the major unit scale for the category axis.
setMinorUnitScale(value: TimeUnit) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TimeUnit | The value to set. |
Example
const { Workbook, ChartType, CategoryType, TimeUnit } = require("aspose.cells.node");
var workbook = new Workbook();
//Adding a new worksheet to the Excel object
var sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var 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
var chartIndex = worksheet.getCharts().add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
var chart = worksheet.getCharts().get(chartIndex);
chart.getCategoryAxis().setCategoryType(CategoryType.TimeScale);
chart.getCategoryAxis().setMinorUnitScale(TimeUnit.Months);
chart.getCategoryAxis().setMinorUnit(2);
isVisible()
Represents if the axis is visible.
isVisible() : boolean;
setIsVisible(boolean)
Represents if the axis is visible.
setIsVisible(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getMajorGridLines()
Represents major gridlines on a chart axis.
getMajorGridLines() : Line;
Returns
Example
const { Workbook, ChartType } = require("aspose.cells.node");
var workbook = new Workbook();
//Adding a new worksheet to the Excel object
var sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var 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
var chartIndex = worksheet.getCharts().add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
var chart = worksheet.getCharts().get(chartIndex);
chart.getValueAxis().getMajorGridLines().setIsVisible(false);
chart.getCategoryAxis().getMajorGridLines().setIsVisible(true);
getMinorGridLines()
Represents minor gridlines on a chart axis.
getMinorGridLines() : Line;
Returns
getHasMultiLevelLabels()
Indicates whether the labels shall be shown as multi level.
getHasMultiLevelLabels() : boolean;
Remarks
Only valid for category axis.
setHasMultiLevelLabels(boolean)
Indicates whether the labels shall be shown as multi level.
setHasMultiLevelLabels(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
Remarks
Only valid for category axis.
getBins()
Represents bins on a chart(Histogram/Pareto) axis
getBins() : AxisBins;
Returns
getAxisTexts()
Gets the labels of the axis after call Chart.Calculate() method.
getAxisTexts() : string[];
Returns
string[]
isNull()
Checks whether the implementation object is null.
isNull() : boolean;