Table of Contents

Class XlsChartAxis

Namespace
Spire.Xls.Core.Spreadsheet.Charts
Assembly
Spire.XLS.dll
public class XlsChartAxis : XlsObject, IExcelApplication, IDisposable, IChartAxis
Inheritance
XlsChartAxis
Implements
Derived
Inherited Members

Properties

Alignment

Represents alignment for the tick label.

public AxisTextDirectionType Alignment { get; set; }

Property Value

AxisTextDirectionType

AutoTickLabelSpacing

public bool AutoTickLabelSpacing { get; set; }

Property Value

bool

AutoTickMarkSpacing

public bool AutoTickMarkSpacing { get; set; }

Property Value

bool

AxisId

Gets axis id.

public int AxisId { get; }

Property Value

int

AxisType

Type of the axis.

public AxisType AxisType { get; set; }

Property Value

AxisType

Border

Represents chart border. Read only. The following code illustrates how to set color to IChart.PrimaryCategoryAxis's border using Border property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart category axisIChartAxis categoryAxis = chart.PrimaryCategoryAxis;//Set border and colorIChartBorder border = categoryAxis.Border;border.Color = Color.Red;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public ChartBorder Border { get; }

Property Value

ChartBorder

Chart3DOptions

public IFormat3D Chart3DOptions { get; }

Property Value

IFormat3D

Chart3DProperties

public IFormat3D Chart3DProperties { get; }

Property Value

IFormat3D

Deleted

public bool Deleted { get; set; }

Property Value

bool

Font

Returns font used for axis text displaying. Read-only. The following code illustrates how to set font color to the IChart.PrimaryCategoryAxis's category labels using Font property:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart axisIChartAxis chartAxis =  chart.PrimaryCategoryAxis;//Set font colorchartAxis.Font.Color = Color.Red;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public IFont Font { get; }

Property Value

IFont

FrameFormat

Return frame format of Axis. Read-only.

public IChartFrameFormat FrameFormat { get; }

Property Value

IChartFrameFormat

Has3dProperties

public bool Has3dProperties { get; }

Property Value

bool

HasAxisTitle

Indicates wheather the axis has title

public bool HasAxisTitle { get; }

Property Value

bool

HasMajorGridLines

True if the axis has major gridlines. Only axes in the primary axis group can have gridlines.

public bool HasMajorGridLines { get; set; }

Property Value

bool

HasMinorGridLines

True if the axis has minor gridlines. Only axes in the primary axis group can have gridlines.

public bool HasMinorGridLines { get; set; }

Property Value

bool

IsAutoTextRotation

public bool IsAutoTextRotation { get; }

Property Value

bool

IsPrimary

True if this is primary axis.

public bool IsPrimary { get; }

Property Value

bool

IsReversed

True if plots data points from last to first.

public bool IsReversed { get; set; }

Property Value

bool

IsSourceLinked

public bool IsSourceLinked { get; set; }

Property Value

bool

MajorGridLines

Represents major gridLines. Read-only. The following code illustrates how to access MajorGridLines of IChart.PrimaryCategoryAxis and set colors to it:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart axisIChartAxis chartAxis =  chart.PrimaryCategoryAxis;//Set visibilitychartAxis.HasMajorGridLines = true;//Set grid linesIChartGridLine gridLine = chartAxis.MajorGridLines;gridLine.LineProperties.Color = Color.Red;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public IChartGridLine MajorGridLines { get; }

Property Value

IChartGridLine

MajorTickMark

Represents major tick marks. The following code illustrates how to set TickMarkType.TickMarkCross to MajorTickMark:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart category axisIChartAxis categoryAxis = chart.PrimaryCategoryAxis;//Set category minor tick typecategoryAxis.MajorTickMark = TickMarkType.TickMarkCross;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public TickMarkType MajorTickMark { get; set; }

Property Value

TickMarkType

MinorGridLines

Represents minor gridLines. Read-only. The following code illustrates how to access MinorGridLines of IChart.PrimaryCategoryAxis and set colors to it:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart axisIChartAxis chartAxis =  chart.PrimaryCategoryAxis;//Set visibilitychartAxis.HasMinorGridLines = true;//Set grid linesIChartGridLine gridLine = chartAxis.MinorGridLines;gridLine.LineProperties.Color = Color.Red;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public IChartGridLine MinorGridLines { get; }

Property Value

IChartGridLine

MinorTickMark

Represents minor tick marks. The following code illustrates how to set TickMarkType.TickMarkCross to MinorTickMark:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart category axisIChartAxis categoryAxis = chart.PrimaryCategoryAxis;//Set category minor tick typecategoryAxis.MinorTickMark = TickMarkType.TickMarkCross;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public TickMarkType MinorTickMark { get; set; }

Property Value

TickMarkType

MultiLevelLable

Axis is show Multi-level category lables.

public bool MultiLevelLable { get; set; }

Property Value

bool

NumberFormat

Gets or sets number format string.

public string NumberFormat { get; set; }

Property Value

string

NumberFormatIndex

Gets or sets format index.

public int NumberFormatIndex { get; set; }

Property Value

int

ParagraphType

public ChartParagraphType ParagraphType { get; set; }

Property Value

ChartParagraphType

Shadow

Represents the Shadow.Read-only

public ChartShadow Shadow { get; }

Property Value

ChartShadow

ShadowProperties

public IShadow ShadowProperties { get; }

Property Value

IShadow

TextDirection

axis's text direction

public TextVerticalValue TextDirection { get; set; }

Property Value

TextVerticalValue

TextRotationAngle

Text rotation angle. Should be integer value between -90 and 90. The following code illustrates how to set TextRotationAngle for IChart.PrimaryCategoryAxis:

//Create worksheetWorkbook workbook = new Workbook();Worksheet worksheet = workbook.Worksheets[0];//Add dataworksheet.Range["A1"].Text = "Jan";
                       worksheet.Range["B1"].Text = "Feb";
                       worksheet.Range["C1"].Text = "Mar";
                       worksheet.Range["A2"].Text = "10";
                       worksheet.Range["B2"].Text = "20";
                       worksheet.Range["C2"].Text = "30";//Create chart and set rangeChart chart = worksheet.Charts.Add();chart.DataRange = worksheet.Range["A1:C2"];//Set chart category axisIChartAxis chartAxis =  chart.PrimaryCategoryAxis;//Set text rotation anglechartAxis.TextRotationAngle = 90;//Save to fileworkbook.SaveToFile("Chart.xlsx");
public int TextRotationAngle { get; set; }

Property Value

int

TickLabelPosition

Represents tick label position.

public TickLabelPositionType TickLabelPosition { get; set; }

Property Value

TickLabelPositionType

Title

Title of the axis.

public string Title { get; set; }

Property Value

string

TitleArea

Returns text area for the axis title. Read-only.

public IChartTextArea TitleArea { get; }

Property Value

IChartTextArea

Visible

Indicates is axis is visible.

public bool Visible { get; set; }

Property Value

bool

Methods

Clone(object, Dictionary<int, int>, Dictionary<string, string>)

public virtual XlsChartAxis Clone(object parent, Dictionary<int, int> dicFontIndexes, Dictionary<string, string> dicNewSheetNames)

Parameters

parent object
dicFontIndexes Dictionary<int, int>
dicNewSheetNames Dictionary<string, string>

Returns

XlsChartAxis