2D Chart for WinForms | ComponentOne
Charting Labels / Attaching and Positioning Chart Labels / Attaching the Chart Label by Data Point
In This Topic
    Attaching the Chart Label by Data Point
    In This Topic

    To attach a ChartLabel to a data point, set the AttachMethod property to AttachMethodEnum.DataIndex, and then under the AttachMethodData object set the GroupIndex, SeriesIndex, and PointIndex properties. These properties specify the ChartGroup, Series, and Point indices. PointIndex refers to the element of the data array. SeriesIndex refers to the element of the series array. Each series has arrays of data.

    The following code example attaches a ChartLabel to a data point:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    With C1Chart1.ChartLabels.LabelsCollection(0)
        .AttachMethod = AttachMethodEnum.DataIndex
        .AttachMethodData.GroupIndex = 0
        .AttachMethodData.SeriesIndex = 1
        .AttachMethodData.PointIndex = 2
    End With
    

    To write code in C#

    C#
    Copy Code
    C1.Win.C1Chart.Label lab = c1Chart1.ChartLabels.LabelsCollection[0];
    lab.AttachMethod = AttachMethodEnum.DataIndex;
    lab.AttachMethodData.GroupIndex = 0;
    lab.AttachMethodData.SeriesIndex = 1;
    lab.AttachMethodData.PointIndex = 2;
    

    For more information on how to attach the chart label by data point at design time see, Attach by Data Index.

    See Also