# Charting Labels

## Content



[ChartLabels](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.ChartLabels.html) is a label that displays in front of the chart data. The chart does not adjust to fit [ChartLabels](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.ChartLabels.html), since they are completely independent. ChartLabels are useful when highlighting an important data point, but can also be used generally to provide information on data or on the chart.

A Label object defines an independent rectangular region that can be attached to a chart. The LabelsCollection contains all of the chart labels defined for a particular chart. A chart label can be added to the chart at design time or programmatically through the [ChartLabels](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.ChartLabels.html) object. [C1Chart](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.C1Chart.html) provides an **Edit Labels** designer so you can conveniently add, remove, or modify existing labels through the designer.

The following code shows how to access a [ChartLabels](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.ChartLabels.html) individually by specifying the index number in the LabelsCollection:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
C1Chart1.ChartLabels.LabelsCollection(0).Text = "First label in collection"
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
c1Chart1.ChartLabels.LabelsCollection[0].Text = "First label in collection";
```

DOC-DETAILS-TAG-CLOSE

The following code shows how to create a Label object, by calling the AddNewLabel method:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Dim Clabel As C1.Win.C1Chart.Label
Clabel = C1Chart1.ChartLabels.LabelsCollection.AddNewLabel()
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
C1.Win.C1Chart.Label Clabel;
Clabel = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();
```

DOC-DETAILS-TAG-CLOSE

There is no limit to the number of ChartLabels a chart can contain. Each ChartLabel has label, interior color, border and attachment attributes that can be customized.

The Label object provides a number of properties that help define and position the ChartLabel. The most important of these properties are:

*   The [Compass](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.DataLabel.Compass.html) property specifies the positioning of the label around its anchor. For instance, setting the [Compass](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.DataLabel.Compass.html) property to _East_ will place the label to the right of the anchor.
*   The [AttachMethod](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.Label.AttachMethod.html) property specifies by which method the label will be attached to the chart. It can be attached by _Coordinate_, _DataCoordinate_, _DataIndex_, or by the _DataIndexY_.
*   The [Text](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.DataLabel.Text.html) property specifies the text to appear in the ChartLabel.
*   The [Connected](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.DataLabel.Connected.html) property is a Boolean, which specifies whether a line is to be drawn from the chart label to its attached location. If **True**, the line is drawn.
*   The [Offset](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.DataLabel.Offset.html) property specifies the distance, in the anchor direction, from the ChartLabel to its attached location, and is of type Long.
*   The [DefaultLabelStyle](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.ChartLabels.DefaultLabelStyle.html) property sets a default style that all the labels will inherit from. For instance, if the BackColor of the default style is set to black, all future labels will have a black back color.

A Label object defines an independent rectangular region that can be attached to a chart. The LabelsCollection contains all of the ChartLabels defined for a particular chart.

## See Also

[Attaching and Positioning Chart Labels](/componentone/docs/win/online-chart2d/chartinglabels/attachingandposition)

[Anchoring Chart Labels](/componentone/docs/win/online-chart2d/chartinglabels/anchoringchartlabels)

[Customizing Chart Labels](/componentone/docs/win/online-chart2d/chartinglabels/customizingchartlabe)

[Setting a Default Label Style](/componentone/docs/win/online-chart2d/chartinglabels/settingadefaultlabel)