# Configure Chart Axis

DsExcel allows you to configure the chart axis using the axis title, gridlines, display unit label, and tick labels. Learn more in DsExcel docs.

## Content

In DsExcel .NET, you can configure chart axis using the following elements in your spreadsheet:

* [Axis Title](/document-solutions/dot-net-excel-api/docs/online/Features/UseChart/CustomizeChartObjects/AxisAndOtherLines/ConfigureChartAxis#axis-title)
* [Gridlines](/document-solutions/dot-net-excel-api/docs/online/Features/UseChart/CustomizeChartObjects/AxisAndOtherLines/ConfigureChartAxis#b)
* [Display Unit Label](/document-solutions/dot-net-excel-api/docs/online/Features/UseChart/CustomizeChartObjects/AxisAndOtherLines/ConfigureChartAxis#display-unit-label)
* [Tick Labels](/document-solutions/dot-net-excel-api/docs/online/Features/UseChart/CustomizeChartObjects/AxisAndOtherLines/ConfigureChartAxis#tick-labels)

## Axis Title

While configuring chart axis, you can set the style for the axis title as per your preferences by using the [AxisTitle property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.AxisTitle.html) of the [IAxis interface](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.html).
Refer to the following example code to configure axis title's layout.

```csharp
IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 200, 100, 300, 300);
worksheet.Range["A1:D6"].Value = new object[,]
{
    {null, "S1", "S2", "S3"},
    {"Item1", 10, 25, 25},
    {"Item2", -51, -36, 27},
    {"Item3", 52, -85, -30},
    {"Item4", 22, 65, 65},
    {"Item5", 23, 69, 69}
};
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);
IAxis value_axis = shape.Chart.Axes.Item(AxisType.Value);
category_axis.HasTitle = true;
category_axis.AxisTitle.Format.Fill.Color.RGB = Color.Pink;
category_axis.AxisTitle.Text = "aaaaaaaaaa";
category_axis.AxisTitle.Font.Size = 20;
category_axis.AxisTitle.Font.Color.RGB = Color.Green;
category_axis.AxisTitle.Font.Strikethrough = true;
```

You can also set the direction of the axis title to horizontal, vertical, rotated (to 90 or 270 degree), and stacked (with text reading left-to-right or right to left). The **Direction** property in [IAxisTitle](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxisTitle.html) and IAxisTitle.[ITextFrame](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.ITextFrame.html) interfaces allows you to set the direction of the axis title using [TextDirection](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.TextDirection.html) enumeration.
Refer to the following example code to set the axis title direction to stacked:

```csharp
// Create chart.
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);

// Display the axis title.
category_axis.HasTitle = true;

// Set the name of axis title.
category_axis.AxisTitle.Text = "Category";

// Set direction of axis title to stacked.
category_axis.AxisTitle.TextFrame.Direction = TextDirection.Stacked;

// OR
category_axis.AxisTitle.Direction = TextDirection.Stacked;
```

DsExcel also allows you to configure the text angle of axis titles by using the **Orientation** property of IAxisTitle interface.
Refer to the following example code to set the text angle of the axis title:

```csharp
// Create chart.
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);

// Display the axis title.
category_axis.HasTitle = true;

// Set the name of axis title.
category_axis.AxisTitle.Text = "Category";

// Set axis title orientation to 45 degrees.
category_axis.AxisTitle.Orientation = 45;
```

The direction and orientation of the axis title can also be exported or imported into a JSON or PDF document.

> !type=note
> **Note:** The Orientation property only applies if the value of Direction property is Horizontal.

## Gridlines

While configuring the axis of a chart, you can also set the style of major and minor gridlines as per your choice using the [HasMajorGridlines property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.HasMajorGridlines.html), [HasMinorGridlines property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.HasMinorGridlines.html), [MajorGridlines property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.MajorGridlines.html) and [MinorGridlines property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.MinorGridlines.html) of the IAxis interface.
Refer to the following example code to set major and minor gridlines' style.

## Display Unit Label

While configuring the chart axis in your worksheet, you can also set the display unit for the axis and configure its label style using the [DisplayUnit property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.DisplayUnit.html), [DisplayUnitLabel property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.DisplayUnitLabel.html) and [HasDisplayUnitLabel property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.HasDisplayUnitLabel.html) of the IAxis interface.
Refer to the following example code to set display unit for the axis and configure its label style.

```csharp
IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnClustered, 200, 100, 300, 300);
worksheet.Range["A1:D6"].Value = new object[,]
{
    {null, "S1", "S2", "S3"},
    {"Item1", 10, 25, 25},
    {"Item2", -51, -36, 27},
    {"Item3", 52, -85, -30},
    {"Item4", 22, 65, 65},
    {"Item5", 23, 69, 69}
};
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);
IAxis value_axis = shape.Chart.Axes.Item(AxisType.Value);
value_axis.DisplayUnit = DisplayUnit.Hundreds;
value_axis.HasDisplayUnitLabel = true;
value_axis.DisplayUnitLabel.Font.Color.RGB = Color.Green;
value_axis.DisplayUnitLabel.Font.Italic = true;
value_axis.DisplayUnitLabel.Format.Fill.Color.RGB = Color.Pink;
value_axis.DisplayUnitLabel.Format.Line.Color.RGB = Color.Red;
```

## Tick Labels

While configuring the axis of a chart, you can set the position and layout of the tick-mark labels as per your choice using the [TickLabelPosition property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.TickLabelPosition.html), [TickLabels property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.TickLabels.html), [TickLabelSpacing property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.TickLabelSpacing.html), [TickLabelSpacingIsAuto property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.TickLabelSpacingIsAuto.html) and [TickMarkSpacing property](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.IAxis.TickMarkSpacing.html) of the IAxis interface.
Refer to the following example code to configure the tick mark label's position and layout.

```csharp
// Create chart.
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);
IAxis value_axis = shape.Chart.Axes.Item(AxisType.Value);

//tick-mark labels' fill will be green according to axis's format.
category_axis.Format.Fill.Color.RGB = Color.Green;

category_axis.TickLabelPosition = TickLabelPosition.NextToAxis;
category_axis.TickLabelSpacing = 2;
category_axis.TickLabels.Font.Color.RGB = Color.Red;
category_axis.TickLabels.Font.Italic = true;
category_axis.TickLabels.NumberFormat = "#,##0.00";
category_axis.TickLabels.Offset = 100;
```

You can also set the direction of the tick labels to horizontal, vertical, rotated (to 90 or 270 degree), and stacked (with text reading left-to-right or right to left). The [Direction](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.ITickLabels.Direction.html) property in [ITickLabels](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.ITickLabels.html) interface allows you to set the direction of the axis title using [TextDirection](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.TextDirection.html) enumeration.
Refer to the following example code to set the vertical tick labels:

```csharp
// Create chart.
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);

// Set category axis.
var categoryAxis = shape.Chart.Axes.Item(AxisType.Category);

// Set category tick labels to vertical.
categoryAxis.TickLabels.Direction = TextDirection.Vertical;
```

DsExcel also allows you to configure the text angle of tick-mark labels by using the [Orientation](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.Drawing.ITickLabels.Orientation.html) property of ITickLabels interface.
Refer to the following example code to set the text angle of tick mark label:

```csharp
// Create chart.
shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);
IAxis category_axis = shape.Chart.Axes.Item(AxisType.Category);

//config tick label's angle
category_axis.TickLabels.Orientation = 45;

//save to an excel file
workbook.Save("configtickmarklabelangle.xlsx");
```

The direction and orientation of the tick labels can also be exported or imported into a JSON or PDF document.

> !type=note
> **Note:** The Orientation property only applies if the value of Direction property is Horizontal.