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:
C# |
Copy Code
|
---|---|
NChart chart = chartControl.Charts[0];
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.Values.Add(12);
bar.Values.Add(25);
bar.Values.Add(67);
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.Values.Add(12) bar.Values.Add(25) bar.Values.Add(67) 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.
C# |
Copy Code
|
---|---|
bar.Values.ValueFormatter = new NNumericValueFormatter("0.000"); |
Visual Basic |
Copy Code
|
---|---|
bar.Values.ValueFormatter = New NNumericValueFormatter("0.000") |