Skip to main content
A newer version of this page is available. .

XYSeries2D.CrosshairLabelPattern Property

Gets or sets a string which represents the pattern specifying the text to be displayed within a crosshair label for the current XYSeries2D type.

Namespace: DevExpress.Xpf.Charts

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

Declaration

public string CrosshairLabelPattern { get; set; }

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 display pattern that determines the text to be displayed in crosshair labels for a particular XYSeries.

For example, the following image shows two crosshair label patterns: “{S}: {A} - {V}” for the first Line Series, and {A:V} for the second Line series:

Series - CrosshairLabelPattern

A full list of available placeholders is detailed below.

Pattern Description
{A} Displays a series point argument.
{V} Displays series point values.
{VP} Displays series point values as percentages (for a Pie and Donut, Nested Donut series and Full-Stacked series).
{S} Displays the name of the series.
{G} Displays the name of a stacked group.
{W} Displays the weight (for a Bubble series).
{V1} Displays the first value (for a Range series).
{V2} Displays the second value (for a Range series).
{VD} Displays the duration between the first and second data point values (for a Range Area series).
{HV} Displays the high value (for a Financial series).
{LV} Displays the low value (for a Financial series).
{OV} Displays the open value (for a Financial series).
{CV} Displays the close value (for a Financial series).

You can also use standard and custom format specifies together with the placeholders to format numeric and date/time values (e.g., {V:F0}). To learn more, see the Format Specifiers topic.

To learn more on a crosshair cursor, see the Crosshair Cursor topic.

In addition, you can specify a pattern using the Pattern Editor (the editor is invoked by clicking the ellipsis button of the CrosshairLabelPattern property in the Properties window of the Chart Designer).

Example

This example demonstrates changing a text displayed in crosshair labels using crosshair format patterns.

To accomplish this, it is necessary to specify a string which will represent a displayed pattern within a crosshair label using 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.

To learn more on a crosshair cursor, see the Tooltip and Crosshair Cursor topic.

<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>

The following code snippets (auto-collected from DevExpress Examples) contain references to the CrosshairLabelPattern property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also