To attach a ChartLabel to a data coordinate on the chart, set the AttachMethod property to AttachMethodEnum.DataCoordinate, and then under the AttachMethodData object set the X and Y properties to the data coordinates at which the ChartLabel is to be attached. For example, the following attaches a ChartLabel to the data coordinate (1.1, 15.8):
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
With C1Chart1.ChartLabels.LabelsCollection(0) .AttachMethod = AttachMethodEnum.DataCoordinate .AttachMethodData.X = 1.1 .AttachMethodData.Y = 15.8 End With |
To write code in C#
C# |
Copy Code
|
---|---|
C1.Win.C1Chart.Label lab = c1Chart1.ChartLabels.LabelsCollection[0]; lab.AttachMethod = AttachMethodEnum.DataCoordinate; lab.AttachMethodData.X = 1.1; lab.AttachMethodData.Y = 15.8; |
ChartLabels can only be attached to a data coordinate if the chart is an Area or XY-Plot. Any part of the ChartLabel that falls outside of the ChartArea is clipped.
For more information on how to attach the chart label by data coordinate at design time see, Attach by Data Coordinate.