ComponentOne Chart for .NET (2.0) Search HelpCentral 

Charting Labels

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:

·      Visual Basic

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

·      C#

C1Chart1.ChartLabels.LabelsCollection[0].Text = "First label in collection";

·      Delphi

begin

  C1Chart1.ChartLabels.LabelsCollection[0].Text := 'First label in  collection');

end;

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

·      Visual Basic

Dim Clabel As C1.Win.C1Chart.Label

Clabel = C1Chart1.ChartLabels.LabelsCollection

·      C#

C1.Win.C1Chart.Label Clabel;

Clabel = C1Chart1.ChartLabels.LabelsCollection.AddNewLabel();

·      Delphi

var

  Clabel: C1.Win.C1Chart.Label;

begin

  Clabel := C1Chart1.ChartLabels.LabelsCollection.AddNewLabel();

end;

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 property specifies the positioning of the label around its anchor. For instance, setting the Compass property to East will place the label to the right of the anchor.

·      The AttachMethod 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 property specifies the text to appear in the ChartLabel.

·      The Connected 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 property specifies the distance, in the anchor direction, from the ChartLabel to its attached location, and is of type Long.

·      The DefaultLabelStyle 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.


Attaching and Positioning Chart Labels

Anchoring Chart Labels

Customizing Chart Labels

Setting a Default Label Style


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.