SeriesBase.LegendTextPattern Property

Gets or sets the string that formats text for the series or series point legend items.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.dll

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public string LegendTextPattern { get; set; }
<XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)>
Public Property LegendTextPattern As String

Property Value

Type Description
String

A String object that is a format string. The default value is Empty.

Remarks

The legend contains series point items when the diagram type is Simple (3D Simple), or when the series's ColorEach property is enabled.

The following images show the LegendTextPattern property in action:

The code below applies the "{S} - {A}: {V:F1}" pattern to the legend items:

private void OnFormLoad(object sender, EventArgs e) {
    ((SideBySideBarSeriesView)chartControl1.Series[0].View).ColorEach = true;
    chartControl1.Series[0].LegendTextPattern = "{S} - {A}: {V:F1}";
}

Patterns can contain regular text (displayed as is) and value placeholders in braces. To format numeric and date/time values, you can apply Format Specifiers. Use a colon to separate a placeholder and its format specifier.

The following table lists the available placeholders:

Pattern Description
{S} Displays the name of the series. The Series.Name property should be specified.
{A} Displays a series point argument.
{V} Displays series point values.
Pie (Donut) series specific placeholders
{VP} Displays series point values as percentages.
Bubble series specific placeholders
{W} Displays the weight.
Stacked series specific placeholders
{VP} Displays series point values as percentages.
{TV} Displays a total group value.
Range series specific placeholders
{V1} Displays the first value.
{V2} Displays the second value.
{VD} Displays the duration between the first and second data point values formatted using a common time format (e.g. HH:MM:SS for date time values and #.## for numeric values).
{VDTD} Displays the duration between the first and second date-time data point values in days.
{VDTH} Displays the duration between the first and second date-time data point values in hours.
{VDTM} Displays the duration between the first and second date-time data point values in minutes.
{VDTS} Displays the duration between the first and second date-time data point values in seconds.
{VDTMS} Displays the duration between the first and second date-time data point values in milliseconds.

When a series provides a single legend item that defines the series itself, only the {S} placeholder is available.

When the Chart Control or a series is bound to data, the text pattern may contain data field values in addition to default placeholders. For example, the data source contains the Discount field and the text pattern may look like: {S}: {V:F2} (Discount: {Discount:P0}).

You can use the Pattern Editor to specify the legend pattern at design time. To invoke the editor, click the LegendTextPattern property's ellipsis button in the Properties window or the Chart Designer.

PatternEditor

The editor contains numerous predefined chart placeholders with the date-time, numeric, percent, currency, and special formats that allow you to create a text pattern.

See Also