2D Chart for WinForms | ComponentOne
In This Topic
    Charting Labels
    In This Topic

    ChartLabels is a label that displays in front of the chart data. The chart does not adjust to fit ChartLabels, 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 object. C1Chart 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 individually by specifying the index number in the LabelsCollection:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    C1Chart1.ChartLabels.LabelsCollection(0).Text = "First label in collection"
    

    To write code in C#

    C#
    Copy Code
    c1Chart1.ChartLabels.LabelsCollection[0].Text = "First label in collection";
    

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

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim Clabel As C1.Win.C1Chart.Label
    Clabel = C1Chart1.ChartLabels.LabelsCollection.AddNewLabel()
    

    To write code in C#

    C#
    Copy Code
    C1.Win.C1Chart.Label Clabel;
    Clabel = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();
    

    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:

    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