Xceed Chart for WinForms v4.4 Documentation
Series Texts Formatting

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Series > Series Texts Formatting

A series can display data-point related texts in the data-point labels and in the series legend. The properties SeriesLegend.Format and DataLabels.Format accept formatting commands, enclosed in the < and > characters, specific to each data series and which represent a data point-specific value. These formatting commands are divided into two categories.

Data Series Formatting Commands

The available data series formatting commands depend on the specific series. For example, a bar series can parse the <value> and <label> formatting commands, while the stock series also supports the <open>, <high>, <low>, <close>, and <xvalue> formatting commands.

If a valid formatting command is present in the format string, it is replaced with the data-point formatted value it represents. For example, the following code displays the values of the bars in the data labels.

VB.NET  

Dim bar As BarSeries =   Chart.Series.Add(SeriesType.Bar)

bar.Add(12)

bar.Add(25)

bar.Add(67)

 

bar.DataLabels.Mode = DataLabelsMode.Every

bar.DataLabels.Format = "<value>"

C#  
BarSeries bar = Chart.Series.Add(SeriesType.Bar);
bar.Add(12);
bar.Add(25);
bar.Add(67);
bar.DataLabels.Mode = DataLabelsMode.Every;
bar.DataLabels.Format = "<value>";

By default the data series values are formatted with the default locale value-formatting settings. If, for example, the user wants to format the data label values displayed by the previous example, the ValueFormatting object attached to the Values data series must be modified. For example, the following code formats the values with 3 decimal places.

VB.NET  

bar.Values.ValueFormat.Format = ValueFormat.CustomNumber

bar.Values.ValueFormat.CustomFormat = "0.000"

C#  
bar.Values.ValueFormat.Format = ValueFormat.CustomNumber;
bar.Values.ValueFormat.CustomFormat = "0.000";

Calculated Value Formatting Commands

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

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

The user can control the formatting of these values with the help of the ValueFormatting objects accessible from the TotalValueFormatting, PercentValueFormatting, CumulativeValueFormat, andIndexValueFormatting properties of the Series class. The following code formats the percent values of the pie series data points with a Percentage format.

VB.NET  

pie.DataLabels.Mode = DataLabelsMode.Every

pie.DataLabels.Format = "<percent>"

pie.DataLabels.PercentValueFormat.Format = ValueFormat.Percentage

C#  
pie.DataLabels.Mode = DataLabelsMode.Every;
pie.DataLabels.Format = "<percent>";
pie.DataLabels.PercentValueFormat.Format = ValueFormat.Percentage;

See Also

DataSeries | ValueFormatting