Table of Contents

Interface IChartCategoryAxis

Namespace
Spire.Xls.Core
Assembly
Spire.XLS.dll

Represents category axis of the chart.

public interface IChartCategoryAxis : IChartValueAxis, IChartAxis
Inherited Members

Properties

AxisBetweenCategories

If true - cuts unused plot area. Default for area, surface charts. The following code illustrates how to set AxisBetweenCategories to "false" so that chart serie would be plotted on the tick marks:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Set category axis IsBetween
categoryAxis.AxisBetweenCategories = false;

//Save to file
workbook.SaveToFile("Chart.xlsx");
bool AxisBetweenCategories { get; set; }

Property Value

bool

BaseUnit

Represents base unit for the specified category axis. The following code illustrates how to set BaseUnit for IChartCategoryAxis:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Set category type
categoryAxis.CategoryType = CategoryType.Time;

//Set base unit
categoryAxis.BaseUnit = ChartBaseUnitType.Year;

//Save to file
workbook.SaveToFile("Chart.xlsx");
ChartBaseUnitType BaseUnit { get; set; }

Property Value

ChartBaseUnitType

BaseUnitIsAuto

True if use automatic base units for the specified category axis.

bool BaseUnitIsAuto { get; set; }

Property Value

bool

CategoryLabels

Category labels for the chart. The following code illustrates how to access the category labels range:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Get category label range . Output will be A1:C1
Console.WriteLine(categoryAxis.CategoryLabels.RangeAddressLocal);

//Save to file
workbook.SaveToFile("Chart.xlsx");
IXLSRange CategoryLabels { get; set; }

Property Value

IXLSRange

CategoryType

Represents axis category type. The following code illustrates how to set CategoryType.Time to CategoryType:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:C2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Set category type
categoryAxis.CategoryType = CategoryType.Time;

//Set base unit
categoryAxis.BaseUnit = ChartBaseUnitType.Year;

//Save to file
workbook.SaveToFile("Chart.xlsx");
CategoryType CategoryType { get; set; }

Property Value

CategoryType

CrossingPoint

Value axis / category crossing point (2D charts only).

double CrossingPoint { get; set; }

Property Value

double

EnteredDirectlyCategoryLabels

Entered directly category labels for the chart.

object[] EnteredDirectlyCategoryLabels { get; set; }

Property Value

object[]

LabelFrequency

Frequency of labels.

int LabelFrequency { get; set; }

Property Value

int

MajorUnitScale

Represens the major unit scale value for the category axis when the CategoryType property is set to TimeScale.

ChartBaseUnitType MajorUnitScale { get; set; }

Property Value

ChartBaseUnitType

MinorUnitScale

Represens the minor unit scale value for the category axis when the CategoryType property is set to TimeScale.

ChartBaseUnitType MinorUnitScale { get; set; }

Property Value

ChartBaseUnitType

Offset

Represents distance between the labels and axis line. The value can be from 0 through 1000.

int Offset { get; set; }

Property Value

int

TickLabelSpacing

Represents the number of categories or series between tick-mark labels. The following code illustrates how to set TickLabelSpacing for chart axis:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Set tick label spacing
categoryAxis.TickLabelSpacing = 2;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int TickLabelSpacing { get; set; }

Property Value

int

TickMarkSpacing

Represents the number of categories or series between tick marks. The following code illustrates how to set TickMarkSpacing for chart axis:

//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];

//Create chart and set range
IChart chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:F2"];

//Set chart category axis
IChartCategoryAxis categoryAxis = chart.PrimaryCategoryAxis;

//Set tick mark spacing
categoryAxis.TickMarkSpacing = 2;

//Save to file
workbook.SaveToFile("Chart.xlsx");
int TickMarkSpacing { get; set; }

Property Value

int

TickMarksFrequency

Frequency of tick marks.

int TickMarksFrequency { get; set; }

Property Value

int