Nevron .NET Vision Documentation
Series Texts Formatting

The data point labels and the legend can display texts that contain values obtained from the series data. The Format properties of the NSeriesLegend and NDataLabelStyle classes accept formatting commands (enclosed in the < and > characters) that represent specific data point or series values. These formatting commands are divided into two categories.  


Series Texts Formatting

The data series formatting commands are specific for the different series. For example a pie series can parse the <value> and <label> formatting commands, while the stock series supports the <open>, <high>, <low>, <close> and <xvalue> formatting commands.

The valid formatting commands that are present in a format string are dynamically replaced with the corresponding formatted values. For example the <value> formatting command is replaced by the elevation value of the respective data point. The following code demonstrates the usage of this formatting command:

Copy Code
NChart chart = chartControl.Charts[0];
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.DataLabelStyle.Format = "<value>";
Visual Basic
Copy Code
Dim chart As NChart = chartControl.Charts(0)
Dim bar As NBarSeries = chart.Series.Add(SeriesType.Bar)
bar.DataLabelStyle.Format = "<value>"

You can control the formatting of the data series values through the ValueFormatter property of the respective data series object. You can assign a NNumericValueFormatter (for numeric values) or a NDateTimeValueFormatter (for date-time values) to the ValueFormatter property and use the desired format specifier and culture. The format specifiers are combinations of characters that indicate how a base type value is to be represented. The .NET framework documentation contains a detailed description of format specifiers. The following code replaces the value formatter of the Values data series in order to make the values appear with 3 decimal places.

Copy Code
bar.Values.ValueFormatter = new NNumericValueFormatter("0.000");

Visual Basic

Copy Code
bar.Values.ValueFormatter = New NNumericValueFormatter("0.000")
Calculated Values Formatting Commands

All series derived from NSeries inherit the following value formatting commands:

<total> - represents the total sum of the values contained in the Values series
<percent> - represents the percentage of the current data point value to the total value
<cumulative> - represents the cumulative sum accumulated up to this data point
<index> - represents the index of the data point inside the values data series

You can control the value formatting of these values with the help of the NValueFormatter objects accessible through the TotalValueFormatter, PercentValueFormatter, CumulativeValueFormatter and IndexValueFormatter properties of the NSeries class. The following code will format the percent values of a pie series with Percentage format.

Copy Code
pie.DataLabelStyle.Format = "<percent>";
pie.PercentValueFormatter = new NNumericValueFormatter(NumericValueFormat.Percentage);
Visual Basic
Copy Code
pie.DataLabelStyle.Format = "<percent>"
pie.PercentValueFormatter = New NNumericValueFormatter(NumericValueFormat.Percentage)
See Also



©2017. Nevron Software LLC.

Send Feedback