# Labels

Customize charts by adding labels to them using Spread for ASP.NET. Learn how you can set the text, alignment, and other formatting for axis labels.

## Content

The labels contain the plot title and the axis labels. You can set the main title for the chart using the [Text](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.LabelArea.Text.html) property in the [LabelArea](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.LabelArea.html) class.
You can set the text, alignment, and other formatting properties for the axis labels. You can use the [IndexAxis.Title](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.IndexAxis.Title.html) property in the plot area class to set the title for the x-axis. Whereas [ValueAxis.Title](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.ValueAxis.Title.html) property is used to set the title in the plot area for the y-axis. For more formatting, use **TitleTextFill** and **TitleTextFont** properties. You can also set the **TitleOffset**, if required. Here, the label text can also be bound to a datasource with the **TitleDataSource** and **TitleDataField** properties.
For more details, refer to the following classes:

* [YPlotArea](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.YPlotArea.html)
* [IndexAxis](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.IndexAxis.html)
* [ValueAxis](/spreadnet/api/latest/online-asp/FarPoint.Web.Chart/FarPoint.Web.Chart.ValueAxis.html)

## Using Code

The following examples show how to set axis labels in different ways.
**Example 1:** Set a title and formatting for the axis labels.

```csharp
// Create a plot area
 YPlotArea plotArea = new YPlotArea();
 plotArea.Location = new PointF(0.2f, 0.2f);
 plotArea.Size = new SizeF(0.6f, 0.6f);
 // Set the title and formatting in the plot area for the x-axis
 plotArea.XAxis.Title = "Categories";
 plotArea.XAxis.TitleTextFont = new System.Drawing.Font("Arial", 12);
 plotArea.XAxis.TitleTextFill = new FarPoint.Web.Chart.SolidFill(Drawing.Color.Crimson);
 plotArea.XAxis.TitleVisible = true;
 // Set the title and formatting in the plot area for the y-axis
 plotArea.YAxis[0].Title = "Values";
 plotArea.YAxes[0].TitleTextFont = new System.Drawing.Font("Comic Sans MS", 12);
 plotArea.YAxes[0].TitleTextFill = new FarPoint.Web.Chart.SolidFill(Drawing.Color.Chartreuse);
```

```vbnet
' Create a plot area
 Dim plotArea As New FarPoint.Web.Chart.YPlotArea()
 plotArea.Location = New PointF(0.2F, 0.2F)
 plotArea.Size = New SizeF(0.6F, 0.6F)
 ' Set the title and formatting in the plot area for the x-axis
 plotArea.XAxis.Title = "Categories"
 plotArea.XAxis.TitleTextFont = New System.Drawing.Font("Arial", 12)
 plotArea.XAxis.TitleTextFill = New FarPoint.Web.Chart.SolidFill(Drawing.Color.Crimson)
 plotArea.XAxis.TitleVisible = True
 ' Set the title and formatting in the plot area for the y-axis
 plotArea.YAxis(0).Title = "Values"
 plotArea.YAxes(0).TitleTextFont = New System.Drawing.Font("Comic Sans MS", 12)
 plotArea.YAxes(0).TitleTextFill = New FarPoint.Web.Chart.SolidFill(Drawing.Color.Chartreuse)
```

**Example 2:** Set axis labels from the DataSource.

```csharp
DataTable table = new DataTable();
 DataRow dr = table.NewRow();
 table.Columns.Add("Category");
 dr[0] = "03:00-04:00";
 table.Rows.Add(dr);
 dr = table.NewRow();
 dr[0] = "04:00-05:00";
 table.Rows.Add(dr);
 dr = table.NewRow();
 dr[0] = "06:00-07:00";
 table.Rows.Add(dr);
 dr = table.NewRow();
 dr[0] = "07:00-08:00";
 table.Rows.Add(dr);
 // Create a bar series
 BarSeries series = new BarSeries();
 series.SeriesName = "Series 0";
 series.Values.Add(2.0);
 series.Values.Add(4.0);
 series.Values.Add(3.0);
 series.Values.Add(5.0);
 // Show Axis Labels from the DataSource
 series.CategoryNames.DataField = "Category";
 series.CategoryNames.DataSource = table;
```

```vbnet
Dim table As DataTable = New DataTable()
Dim dr As DataRow = table.NewRow()
table.Columns.Add("Category")
dr(0) = "03:00-04:00"
table.Rows.Add(dr)
dr = table.NewRow()
dr(0) = "04:00-05:00"
table.Rows.Add(dr)
dr = table.NewRow()
dr(0) = "06:00-07:00"
table.Rows.Add(dr)
dr = table.NewRow()
dr(0) = "07:00-08:00"
table.Rows.Add(dr) 
' Create a bar series
Dim series As BarSeries = New BarSeries()
series.SeriesName = "Series 0"
series.Values.Add(2.0)
series.Values.Add(4.0)
series.Values.Add(3.0)
series.Values.Add(5.0)
' Show Axis Labels from the DataSource
series.CategoryNames.DataField = "Category"
series.CategoryNames.DataSource = table
```

## Using the Chart Designer

1. Select the **PlotArea** from the **Format** menu.
2. Select the **XAxis** and **YAxis** Collections
3. Set the **Title** and other properties, as needed.
4. Select **Apply** and **OK** to close the Chart Designer.