XYSeries2D.CrosshairLabelPattern Property

Gets or sets a format string that specifies the display text in a crosshair label for the current XYSeries2D type.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v20.1.dll

Declaration

public string CrosshairLabelPattern { get; set; }
Public Property CrosshairLabelPattern As String

Property Value

Type Description
String

A String that is the crosshair label pattern. The default value is Empty.

Remarks

Use the CrosshairLabelPattern property to define a pattern that specifies the text in crosshair labels for a particular XYSeries.

Patterns can comprise plain text and placeholders with format specifiers.

For example, the following image shows two crosshair label patterns: "{S}: {A:hh:mm} - {V:f3}" for the first Line Series, and "{A} : {V:f0} °F" for the second Line series:

Series - CrosshairLabelPattern

<dxc:LineSeries2D DisplayName="Series 1" CrosshairLabelPattern="{}{S}: {A:hh\:mm} - {V:f3}"/>
<dxc:LineSeries2D DisplayName="Series 2" CrosshairLabelPattern="{}{A} : {V:f0} °F" />

Note: In XAML, insert empty brackets into the beginning of a pattern if it starts with a placeholder.

A full list of available placeholders is detailed below.

Show the list
Pattern Description
{S} Displays the Series.DisplayName value.
{A} Displays a series point argument.
{V} Displays series point values.
Stacked series-specific placeholders
{VP} Displays series point values as percentages.
{G} Displays the name of a stacked group.
{TV} Displays a total group value.
Bubble series-specific placeholders
{W} Displays the weight.
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.
Financial series specific placeholders
{OV} Displays the open value.
{HV} Displays the high value.
{LV} Displays the low value.
{CV} Displays the close value.

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

See the Crosshair Cursor Customization topic to learn more on how to format the crosshair label text.

In addition, you can use the Pattern Editor to specify the pattern. The editor is invoked by clicking the ellipsis button of the CrosshairLabelPattern property in the Properties window of the Chart Designer.

Examples

This example demonstrates how to change the text displayed in crosshair labels.

To do this, use the CrosshairAxisLabelOptions.Pattern, XYSeries2D.CrosshairLabelPattern, and CrosshairOptions.GroupHeaderPattern properties.

In addition, standard and custom format specifiers are used together with the placeholders to format numeric and date/time values (e.g., {A:F0}). To learn more, see the Format Specifiers topic.

See the Crosshair Cursor topic to learn more on a crosshair cursor.

<Window x:Class="UsingCrosshairLabelPattern.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxc:ChartControl>
            <!--region #GroupHeaderPattern-->
            <dxc:ChartControl.CrosshairOptions>
                <dxc:CrosshairOptions  GroupHeaderPattern="Year: {A}" 
                                       ShowArgumentLabels="True" ShowArgumentLine="True" 
                                       ShowValueLabels="True" ShowValueLine="True">
                </dxc:CrosshairOptions>
            </dxc:ChartControl.CrosshairOptions>
            <!--endregion #GroupHeaderPattern-->
            <dxc:ChartControl.Diagram>
                <dxc:XYDiagram2D>
                    <!--region #CrosshairAxisLabelPattern-->
                    <dxc:XYDiagram2D.AxisX>
                        <dxc:AxisX2D>
                            <dxc:AxisX2D.CrosshairAxisLabelOptions>
                                <dxc:CrosshairAxisLabelOptions Pattern="Year: {A:F0}" />
                            </dxc:AxisX2D.CrosshairAxisLabelOptions>
                        </dxc:AxisX2D>
                    </dxc:XYDiagram2D.AxisX>
                    <!--endregion #CrosshairAxisLabelPattern-->

                    <!--region #CrosshairLabelPattern-->
                    <dxc:XYDiagram2D.Series>
                        <dxc:LineSeries2D DisplayName="Europe" 
                                          CrosshairLabelPattern="{}{S} population: {V}">
                            <dxc:LineSeries2D.Points>
                                <dxc:SeriesPoint Argument="1950" Value="546" />
                                <dxc:SeriesPoint Argument="1960" Value="605" />
                                <dxc:SeriesPoint Argument="1970" Value="656" />
                                <dxc:SeriesPoint Argument="1980" Value="694" />
                                <dxc:SeriesPoint Argument="1990" Value="721" />
                                <dxc:SeriesPoint Argument="2000" Value="730" />
                                <dxc:SeriesPoint Argument="2010" Value="728" />
                                <dxc:SeriesPoint Argument="2020" Value="721" />
                                <dxc:SeriesPoint Argument="2030" Value="704" />
                                <dxc:SeriesPoint Argument="2040" Value="680" />
                                <dxc:SeriesPoint Argument="2050" Value="650" />
                            </dxc:LineSeries2D.Points>
                        </dxc:LineSeries2D>
                        <dxc:LineSeries2D  DisplayName="Americas" 
                                           CrosshairLabelPattern="{}{S} population: {V} ">
                            <dxc:LineSeries2D.Points>
                                <dxc:SeriesPoint Argument="1950" Value="332" />
                                <dxc:SeriesPoint Argument="1960" Value="417" />
                                <dxc:SeriesPoint Argument="1970" Value="513" />
                                <dxc:SeriesPoint Argument="1980" Value="614" />
                                <dxc:SeriesPoint Argument="1990" Value="721" />
                                <dxc:SeriesPoint Argument="2000" Value="836" />
                                <dxc:SeriesPoint Argument="2010" Value="935" />
                                <dxc:SeriesPoint Argument="2020" Value="1027" />
                                <dxc:SeriesPoint Argument="2030" Value="1110" />
                                <dxc:SeriesPoint Argument="2040" Value="1178" />
                                <dxc:SeriesPoint Argument="2050" Value="1231" />
                            </dxc:LineSeries2D.Points>
                        </dxc:LineSeries2D>
                    </dxc:XYDiagram2D.Series>
                    <!--endregion #CrosshairLabelPattern-->
                </dxc:XYDiagram2D>
            </dxc:ChartControl.Diagram>
        </dxc:ChartControl>
    </Grid>
</Window>
See Also