Class Axis
Namespace: Aspose.Cells.Charts
Assembly: Aspose.Cells.dll (25.2.0)
Encapsulates the object that represents an axis of chart.
public class Axis
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Examples
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.Worksheets.Add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.Worksheets[sheetIndex];
//Adding a sample value to "A1" cell
worksheet.Cells["A1"].PutValue(50);
//Adding a sample value to "A2" cell
worksheet.Cells["A2"].PutValue(100);
//Adding a sample value to "A3" cell
worksheet.Cells["A3"].PutValue(150);
//Adding a sample value to "B1" cell
worksheet.Cells["B1"].PutValue(4);
//Adding a sample value to "B2" cell
worksheet.Cells["B2"].PutValue(20);
//Adding a sample value to "B3" cell
worksheet.Cells["B3"].PutValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.Charts[chartIndex];
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", true);
//Set the max value of value axis
chart.ValueAxis.MaxValue = 200;
//Set the min value of value axis
chart.ValueAxis.MinValue = 0;
//Set the major unit
chart.ValueAxis.MajorUnit = 25;
//Category(X) axis crosses at the maxinum value.
chart.ValueAxis.CrossType = CrossType.Maximum;
//Set he number of categories or series between tick-mark labels.
chart.CategoryAxis.TickLabelSpacing = 2;
//do your business
//Saving the Excel file
workbook.Save("book1.xlsx");
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Adding a new worksheet to the Excel object
Dim sheetIndex As Int32 = workbook.Worksheets.Add()
'Obtaining the reference of the newly added worksheet by passing its sheet index
Dim worksheet As Worksheet = workbook.Worksheets(sheetIndex)
'Adding a sample value to "A1" cell
worksheet.Cells("A1").PutValue(50)
'Adding a sample value to "A2" cell
worksheet.Cells("A2").PutValue(100)
'Adding a sample value to "A3" cell
worksheet.Cells("A3").PutValue(150)
'Adding a sample value to "B1" cell
worksheet.Cells("B1").PutValue(4)
'Adding a sample value to "B2" cell
worksheet.Cells("B2").PutValue(20)
'Adding a sample value to "B3" cell
worksheet.Cells("B3").PutValue(50)
'Adding a chart to the worksheet
Dim chartIndex As Int32 = worksheet.Charts.Add(ChartType.Column, 5, 0, 25, 5)
'Accessing the instance of the newly added chart
Dim chart As Chart = worksheet.Charts(chartIndex)
'Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.NSeries.Add("A1:B3", True)
'Set the max value of value axis
chart.ValueAxis.MaxValue = 200
'Set the min value of value axis
chart.ValueAxis.MinValue = 0
'Set the major unit
chart.ValueAxis.MajorUnit = 25
'Category(X) axis crosses at the maxinum value.
chart.ValueAxis.CrossType = CrossType.Maximum
'Set he number of categories or series between tick-mark labels.
chart.CategoryAxis.TickLabelSpacing = 2
'Saving the Excel file
workbook.Save("book1.xlsx")
Properties
Area
Gets the Aspose.Cells.Charts.Axis.Area.
public Area Area { get; }
Property Value
AxisBetweenCategories
Represents if the value axis crosses the category axis between categories.
public bool AxisBetweenCategories { get; set; }
Property Value
Remarks
This property applies only to category axes, and it doesn’t apply to 3-D charts.
AxisLine
Gets the appearance of an Axis.
public Line AxisLine { get; }
Property Value
BaseUnitScale
Represents the base unit scale for the category axis.
public TimeUnit BaseUnitScale { get; set; }
Property Value
Remarks
Setting this property only takes effect when the CategoryType property is set to TimeScale.
Bins
Represents bins on a chart(Histogram/Pareto) axis
public AxisBins Bins { get; }
Property Value
CategoryType
Represents the category axis type.
public CategoryType CategoryType { get; set; }
Property Value
CrossAt
Represents the point on the value axis where the category axis crosses it.
public double CrossAt { get; set; }
Property Value
Remarks
The number should be a integer when it applies to category axis. And the value must be between 1 and 31999.
CrossType
Represents the Aspose.Cells.Charts.Axis.CrossType on the specified axis where the other axis crosses.
public CrossType CrossType { get; set; }
Property Value
CustomDisplayUnit
Specifies a custom value for the display unit.
public double CustomDisplayUnit { get; set; }
Property Value
DisplayUnit
Represents the unit label for the specified axis.
public DisplayUnitType DisplayUnit { get; set; }
Property Value
DisplayUnitLabel
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.
public DisplayUnitLabel DisplayUnitLabel { get; }
Property Value
HasMultiLevelLabels
Indicates whether the labels shall be shown as multi level.
public bool HasMultiLevelLabels { get; set; }
Property Value
Remarks
Only valid for category axis.
IsAutoTickLabelSpacing
Indicates whether the spacing of tick label is automatic
public bool IsAutoTickLabelSpacing { get; set; }
Property Value
IsAutomaticMajorUnit
Indicates whether the major unit of the axis is automatically assigned.
public bool IsAutomaticMajorUnit { get; set; }
Property Value
IsAutomaticMaxValue
Indicates whether the max value is automatically assigned.
public bool IsAutomaticMaxValue { get; set; }
Property Value
IsAutomaticMinValue
Indicates whether the min value is automatically assigned.
public bool IsAutomaticMinValue { get; set; }
Property Value
IsAutomaticMinorUnit
Indicates whether the minor unit of the axis is automatically assigned.
public bool IsAutomaticMinorUnit { get; set; }
Property Value
IsDisplayUnitLabelShown
Represents if the display unit label is shown on the specified axis.
public bool IsDisplayUnitLabelShown { get; set; }
Property Value
Remarks
The default value is True.
IsLogarithmic
Represents if the value axis scale type is logarithmic or not.
public bool IsLogarithmic { get; set; }
Property Value
IsPlotOrderReversed
Represents if Microsoft Excel plots data points from last to first.
public bool IsPlotOrderReversed { get; set; }
Property Value
IsVisible
Represents if the axis is visible.
public bool IsVisible { get; set; }
Property Value
LogBase
Represents the logarithmic base. Default value is 10.Only applies for Excel2007.
public double LogBase { get; set; }
Property Value
MajorGridLines
Represents major gridlines on a chart axis.
public Line MajorGridLines { get; }
Property Value
Examples
chart.ValueAxis.MajorGridLines.IsVisible = false;
chart.CategoryAxis.MajorGridLines.IsVisible = true;
chart.ValueAxis.MajorGridLines.IsVisible = false
chart.CategoryAxis.MajorGridLines.IsVisible = true
MajorTickMark
Represents the type of major tick mark for the specified axis.
public TickMarkType MajorTickMark { get; set; }
Property Value
MajorUnit
Represents the major units for the axis.
public double MajorUnit { get; set; }
Property Value
Remarks
The major units must be greater than zero.
MajorUnitScale
Represents the major unit scale for the category axis.
public TimeUnit MajorUnitScale { get; set; }
Property Value
Examples
chart.CategoryAxis.CategoryType = CategoryType.TimeScale;
chart.CategoryAxis.MajorUnitScale = TimeUnit.Months;
chart.CategoryAxis.MajorUnit = 2;
chart.CategoryAxis.CategoryType = CategoryType.TimeScale
chart.CategoryAxis.MajorUnitScale = TimeUnit.Months
chart.CategoryAxis.MajorUnit = 2
MaxValue
Represents the maximum value on the value axis.
public object MaxValue { get; set; }
Property Value
Remarks
The maxValue type only can be double or DateTime
MinValue
Represents the minimum value on the value axis.
public object MinValue { get; set; }
Property Value
Remarks
The minValue type only can be double or DateTime
MinorGridLines
Represents minor gridlines on a chart axis.
public Line MinorGridLines { get; }
Property Value
MinorTickMark
Represents the type of minor tick mark for the specified axis.
public TickMarkType MinorTickMark { get; set; }
Property Value
MinorUnit
Represents the minor units for the axis.
public double MinorUnit { get; set; }
Property Value
Remarks
The minor units must be greater than zero.
MinorUnitScale
Represents the major unit scale for the category axis.
public TimeUnit MinorUnitScale { get; set; }
Property Value
Examples
chart.CategoryAxis.CategoryType = CategoryType.TimeScale;
chart.CategoryAxis.MinorUnitScale = TimeUnit.Months;
chart.CategoryAxis.MinorUnit = 2;
chart.CategoryAxis.CategoryType = CategoryType.TimeScale
chart.CategoryAxis.MinorUnitScale = TimeUnit.Months
chart.CategoryAxis.MinorUnit = 2
TickLabelPosition
Represents the position of tick-mark labels on the specified axis.
public TickLabelPositionType TickLabelPosition { get; set; }
Property Value
TickLabelSpacing
Represents the number of categories or series between tick-mark labels. Applies only to category and series axes.
public int TickLabelSpacing { get; set; }
Property Value
Remarks
The number must be between 1 and 31999.
TickLabels
Returns a Aspose.Cells.Charts.Axis.TickLabels object that represents the tick-mark labels for the specified axis.
public TickLabels TickLabels { get; }
Property Value
TickMarkSpacing
Returns or sets the number of categories or series between tick marks. Applies only to category and series axes.
public int TickMarkSpacing { get; set; }
Property Value
Remarks
The number must be between 1 and 31999.
Title
Gets the axis’ title.
public Title Title { get; }
Property Value
Methods
GetAxisTexts()
Gets the labels of the axis after call Chart.Calculate() method.
public string[] GetAxisTexts()
Returns
string[]