Skip to main content

Data Labels

Version: 12.0

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.

important

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

There are seven different types of data labels:

  • XYDataLabel,
  • PercentageDataLabel,
  • BarColumnPercentageDataLabel,
  • XYScatterDataLabel,
  • ValuePostionDataLabel,
  • BarColumnValuePositionDataLabel, and
  • ScalarDataLabel.

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).

LabelParentUsed By
XYDataLabelObject
PercentageDataLabelXYDataLabelStackedSeriesElement, Stacked100PercentLineSeriesElement, Indexed100PercentStackedLineSeries, Indexed100PercentStackedAreaSeriesElement, DateTime100PercentStackedLineSeriesElement
BarColumnPercentageDataLabelPercentageDataLabelStacked100PercentSeriesElements, Stacked100PercentBarSeriesElement, Indexed100PercentStackedColumnSeriesElement, Indexed100PercentStackedBarSeriesElement, DateTime100PercentStackedColumnSeriesElement
ValuePositionDataLabelXYDataLabelAreaSeries, StackedAreaSeriesElement, DateTimeStackedAreaSeriesElement, StackedLineSeriesElement, LineSeries, IndexedStackedLineSeriesElement, IndexedStackedAreaSeriesElement, IndexedLineSeries, IndexedAreaSeries, DateTimeStackedLineSeriesElement, DateTimeLineSeries, DateTimeAreaSeries
BarColumnValuePositionDataLabelValuePositionDataLabelBarSeries, ColumnSeries, StackedColumnSeriesElement, StackedBarSeriesElement, IndexedStackedColumnSeriesElement, IndexedColumnSeries, IndexedBarSeries, DateTimeStackedBarSeriesElement, DateTimeBarSeries
XYScatterDataLabelXYDataLabelXYScatterSeries
ScalarDataLabelObjectPieSeries

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​

PropertyDescription
AlignGets or sets the alignment of the data label.
AngleGets or sets the angle of the data label.
ColorGets or sets the Color object to use for the color of the XYDataLabel.
FontGets or sets the Font object to use for the font of the XYDataLabel.
FontSizeGets or sets the FontSize of the XYDataLabel.
PaddingGets or sets the space between the x and y intersection point and data label.
PositionGets or sets the DataLabelPosition object to use for the position of the data label.
PrefixGets or sets the prefix of the XYDataLabel.
SeparatorGets or sets the separator of the XYDataLabel.
SuffixGets or sets the suffix of the XYDataLabel.
WidthGets or sets the width of the data label.
WrapTextGets 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.

PropertyDescription
ShowPercentageGets or sets visible status of the series value as a percentage. By default it is false.
ShowPositionGets or sets visible status for the position of the series value. By default it is false.
ShowSeriesGets or sets visible status of the series name. By default it is false.
ShowValueGets 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)
info

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.

PropertyDescription
SeriesGets or sets the visible status of the SeriesName. By default it is false.
ShowXValueGets or sets the visible status of the XValue. By default it is false.
ShowYValueGets 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)
info

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.

PropertyDescription
ShowPositionGets or sets visible status for the position. By default it is False.
ShowSeriesGets or sets visible status. By default it is False.
ShowValueGets or sets visible status. By default it is False.
SuffixGets or sets the suffix. (Inherited from XYDataLabel)
WidthGets or sets the width of the data label. (Inherited from XYDataLabel)
WrapTextGets 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)
info

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.

PropertyDescription
ColorGets or sets the Color object to use for the color.
FontGets or sets the Font object to use for the font
FontSizeGets or sets the FontSize.
PrefixGets or sets the prefix.
SeparatorGets or sets the separator
ShowElementGets or sets the visible status of the PieSeriesElement name. By default it is False.
ShowPercentageGets or sets the visible status of the PieSeriesElementValue as a percentage. By default it is False.
ShowValueGets or sets the visible status of the PieSeriesElementValue. By default it is False.
SuffixGets 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)
info

Refer to the ScalarDataLabel API documentation for a complete example.