Nevron .NET Vision Documentation
Data Labels

Data labels are descriptive texts displayed over data points. Each series derived from NSeries has an associated instance of a NDataLabelStyle object controlling the default data label style. It is accessible through the DataLabelStyle property of the NSeries class. The NSeries class also provides the DataLabelStyles data series, which contains individual data label styles for the data points. Initially the DataLabelStyles data series is empty and all data labels are displayed with the default style.

Controlling the labels visibility

The visibility of a data label is controlled through the Visible property of the NDataLabelStyle object. By default it is set to true and series data labels are visible. The following code hides all data labels:

C#
Copy Code
bar.DataLabelStyle.Visible = false;
Visual Basic
Copy Code
bar.DataLabelStyle.Visible = False

If you want to display a data label only at some specific index (for example 3), you have to use the following code:

C#
Copy Code
NDataLabelStyle dataLabel = new NDataLabelStyle();
dataLabel.Visible = true;
dataLabel.Format = "";

series.DataLabelStyle.Visible = false;
series.DataLabelStyles[3] = dataLabel;
Visual Basic
Copy Code
Dim dataLabel As NDataLabelStyle = New NDataLabelStyle
dataLabel.Visible = True
dataLabel.Format = ""

series.DataLabelStyle.Visible = False
series.DataLabelStyles(3) = dataLabel

In the same manner you can use individual NDataLabelStyle objects for the data points in order to override the other properties of the default data label style. For example you can display data labels with different text color or formatting.

Controlling the labels format

The user can control what information is displayed in each individual data label with the help of a simple formatting string. It is specified from the Format property. The following example demonstrates how to display the elevation value and the label in the data labels.

C#
Copy Code
series.DataLabelStyle.Format = "<value> <label>";
Visual Basic
Copy Code
series.DataLabelStyle.Format = "<value> <label>"

For a list of the formatting commands and detailed instruction how to format the values, please refer to the Series Texts Formatting topic.

Controlling the appearance of the data label text

The data label text appearance is controlled through the TextStyle property of the NDataLabelStyle object. It exposes a NTextStyle object. The data label arrow appearance is controlled through the ArrowLength, ArrowPointerLength and ArrowStrokeStyle properties. The following code sets the color of the data label arrow to green and increases the length of the arrow:

C#
Copy Code
series.DataLabelStyle.ArrowStrokeStyle = new NStrokeStyle(Color.Green);
Visual Basic
Copy Code
series.DataLabelStyle.ArrowStrokeStyle = New NStrokeStyle(Color.Green)

The vertical position of a data label towards the data point bounds can be set through the VertAlign property. It accepts values from the VertAlign enumeration: Top, Center and Bottom. Please note that the "top" of a data point is not always the upper part and "bottom" is not always the lower part of a data point. For data points that have orientation (for example floating bars) the terms "top" and "bottom" depend on the data point orientation.

Related Examples
Windows forms: Series Attributes\Data Labels
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback