Data Labels

Data labels appear next to a plotted value on a chart and provide additional information about the data value. By default, data labels appear slightly offset from where the value is plotted. But, the DataLabelLocation and the DataLabelPosition enumerations, allow changing the default appearance. Additionally, the Angle property can rotate a data label for more customization.

The DataLabelLocation and DataLabelPosition enumerations are not used with the ScalarDataLabel class.

There are seven different types of data labels:

The PercentageDataLabel and BarColumnPercentageDataLabel are both children of the XYDataLabel class. BarcolumnPercentageDataLabel is a child of PercentageDataLabel. The ValuPositionDataLabel and BarColumnValuePositionDataLabel are children of the XYDataLabel class. The BarColumnValuePositionDataLabel is a child of the ValuePositionDataLabel. The XYScatterDataLabel is a child of the XYDataLabel.

XYDataLabel <----- PercentageDataLabel, ValuePositionLabel, XYScatterDataLabel
PercentageDataLabel <-------- BarColumnPercentageDataLabel
ValuePositionLabel <-------- BarColumnValuePositionLabel

The following table lists the data labels and what series or series element sets the data label through the class's DataLabel property. For example, the DateTime100PercentStackedColumnSeriesElement has a DataLabel property that gets or sets the BarColumnPercentageDataLabel object to use for the DataLabel of the stacked 100Percent series element. This is the default data label for the series element. (Inherited from Stacked100PercentColumnSeriesElement).

Label Parent Used By
XYDataLabel Object
PercentageDataLabel XYDataLabel StackedSeriesElement, Stacked100PercentLineSeriesElement, Indexed100PercentStackedLineSeries, Indexed100PercentStackedAreaSeriesElement, DateTime100PercentStackedLineSeriesElement
BarColumnPercentageDataLabel PercentageDataLabel Stacked100PercentSeriesElements, Stacked100PercentBarSeriesElement, Indexed100PercentStackedColumnSeriesElement, Indexed100PercentStackedBarSeriesElement, DateTime100PercentStackedColumnSeriesElement
ValuePositionDataLabel XYDataLabel AreaSeries, StackedAreaSeriesElement, DateTimeStackedAreaSeriesElement, StackedLineSeriesElement, LineSeries, IndexedStackedLineSeriesElement, IndexedStackedAreaSeriesElement, IndexedLineSeries, IndexedAreaSeries, DateTimeStackedLineSeriesElement, DateTimeLineSeries, DateTimeAreaSeries
BarColumnValuePositionDataLabel ValuePositionDataLabel BarSeries, ColumnSeries, StackedColumnSeriesElement, StackedBarSeriesElement, IndexedStackedColumnSeriesElement, IndexedColumnSeries, IndexedBarSeries, DateTimeStackedBarSeriesElement, DateTimeBarSeries
XYScatterDataLabel XYDataLabel XYScatterSeries
ScalarDataLabel Object PieSeries

XYDataLabel

The XYDataLabel class is the parent class of all five data labels (it is not parent to the ScalarDataLabel class). The XYDataLabel has the following properties that are shared by its child classes.

Properties

Property Description
Align Gets or sets the alignment of the data label.
Angle Gets or sets the angle of the data label.
Color Gets or sets the Color object to use for the color of the XYDataLabel.
Font Gets or sets the Font object to use for the font of the XYDataLabel.
FontSize Gets or sets the FontSize of the XYDataLabel.
Padding Gets or sets the space between the x and y intersection point and data label.
Position Gets or sets the DataLabelPosition object to use for the position of the data label.
Prefix Gets or sets the prefix of the XYDataLabel.
Separator Gets or sets the separator of the XYDataLabel.
Suffix Gets or sets the suffix of the XYDataLabel.
Width Gets or sets the width of the data label.
WrapText Gets or sets the text wrapping of the data label.

PercentageDataLabel

Series that use the PercentageDataLabel display value labels in percentage format. It is also parent class to the BarColumnPercentageDataLabel class. The class has several overloaded constructors for customizing the data label's values, position, font, and color.

public PercentageDataLabel(bool showValue)
public PercentageDataLabel(bool showValue, bool showSeries)
public PercentageDataLabel(bool showValue, bool showPosition, bool showSeries)
public PercentageDataLabel(bool showValue, bool showPercentage, bool showPosition, bool showSeries)
public PercentageDataLabel(Font font, float fontSize, Color color, bool showValue)

Properties

The PercentageDataLabel inherits all the XYDataLabel class's properties as well as the following additional properties.

Property Description
ShowPercentage Gets or sets visible status of the series value as a percentage. By default it is false.
ShowPosition Gets or sets visible status for the position of the series value. By default it is false.
ShowSeries Gets or sets visible status of the series name. By default it is false.
ShowValue Gets or sets visible status of the series value. By default it is false.

The following example illustrates setting a PercentageDataLabel.

DateTime100PercentStackedLineSeriesElement seriesElement = new
    DateTime100PercentStackedLineSeriesElement("series name");
seriesElement.DataLabel = new PercentageDataLabel(true, true, true, true);        
Dim MyseriesElement As DateTime100PercentStackedLineSeriesElement = New
	DateTime100PercentStackedLineSeriesElement("Series name")
MyseriesElement.DataLabel = New PercentageDataLabel(True, True, True, True)      

Refer to the PercentageDataLabel API documentation for a complete example.

XYScatterDataLabel

The XYScatterSeries uses XYScatterDataLabel instances to display x-axis values, the y-axis values and the series names.

Properties

The XYScatterDataLabel includes the inherited properties from XYDataLabel and the following additional properties.

Property Description
Series Gets or sets the visible status of the SeriesName. By default it is false.
ShowXValue Gets or sets the visible status of the XValue. By default it is false.
ShowYValue Gets or sets the visible status of the YValue. By default it is false.

The following code illustrates creating and adding an XYScatterDataLabel to a XYScatter series.

XYScatterSeries xyScatterSeries = new XYScatterSeries("series name");
xyScatterSeries.DataLabel = new XYScatterDataLabel(true, true, true);        
Dim MyXYScatterSeries As XYScatterSeries = New XYScatterSeries("series name")
MyXYScatterSeries.DataLabel = New XYScatterDataLabel(True, True, True, True)         

Refer to XYScatterDataLabel for a complete example.

ValuePositionDataLabel

All series with numeric, date/time, and indexed data use ValuePositionDataLabel instances to display the x-axis value, the y-axis value, and the series name. The BarColumnValuePositionDataLabel inherits from the ValuePositionDataLabel.

Properties

The ValuePositionDataLabel inherits the XYDataLabel class's properties as well as the additional properties.

Property Description
ShowPosition Gets or sets visible status for the position. By default it is False.
ShowSeries Gets or sets visible status. By default it is False.
ShowValue Gets or sets visible status. By default it is False.
Suffix Gets or sets the suffix. (Inherited from XYDataLabel)
Width Gets or sets the width of the data label. (Inherited from XYDataLabel)
WrapText Gets or sets the text wrapping of the data label. (Inherited from XYDataLabel)

The below code shows how to add ValuePositionDataLabel to a DateTimeLine series.

DateTimeLineSeries lineSeries = new DateTimeLineSeries("series name");
lineSeries.DataLabel = new ValuePositionDataLabel(true, true, true);        
Dim MyLineSeries As DateTimeLineSeries = New DateTimeLineSeries("series name")
MyLineSeriesAs.DataLabel = New ValuePositionDataLabel(True, True, True) 

Refer to the ValuePositionDataLabel API documentation for a complete example.

ScalarDataLabel

The PieSeries uses ScalarDataLabel to display the PieSeries element value, PieSeries element name and PieSeries element value in percentage format. The ScalarDataLabelPosition enumeration can be used to specify whether the ScalarDataLabel is added inside or outside the circle. By default it appears outside the circle.

Properties

The ScalarDataLabel has the following properties.

Property Description
Color Gets or sets the Color object to use for the color.
Font Gets or sets the Font object to use for the font
FontSize Gets or sets the FontSize.
Prefix Gets or sets the prefix.
Separator Gets or sets the separator
ShowElement Gets or sets the visible status of the PieSeriesElement name. By default it is False.
ShowPercentage Gets or sets the visible status of the PieSeriesElementValue as a percentage. By default it is False.
ShowValue Gets or sets the visible status of the PieSeriesElementValue. By default it is False.
Suffix Gets or sets the suffix.

The below code shows how to add ScalarDataLabel to a PieSeries.

PieSeries pieSeries = new PieSeries();
pieSeries.DataLabel= new ScalarDataLabel(true,true,true);       
Dim MyPieSeries As PieSeries = New PieSeries()
MyPieSeries.DataLabel = New ScalarDataLabel(True, True, True)

Refer to the ScalarDataLabel API documentation for a complete example.

In this topic