Back to Devexpress

CrosshairLegendElement.SeriesPoint Property

wpf-devexpress-dot-xpf-dot-charts-dot-crosshairlegendelement.md

latest6.4 KB
Original Source

CrosshairLegendElement.SeriesPoint Property

Returns the series point which the Crosshair Cursor highlights.

Namespace : DevExpress.Xpf.Charts

Assembly : DevExpress.Xpf.Charts.v25.2.dll

NuGet Package : DevExpress.Wpf.Charts

Declaration

csharp
public SeriesPoint SeriesPoint { get; }
vb
Public ReadOnly Property SeriesPoint As SeriesPoint

Property Value

TypeDescription
SeriesPoint

The series point.

|

Remarks

Use the SeriesPoint property to get access the series point parameters when custom drawing a crosshair cursor using the ChartControl.CustomDrawCrosshair event.

Refer to the Tooltip and Crosshair Cursor document for more information about the Crosshair Cursor.

Example

This example demonstrates how to modify the Crosshair Cursor’s appearance using the ChartControl.CustomDrawCrosshair event.

In this sample, crosshair content is displayed in a legend. For this, set the CrosshairOptions.ContentShowMode to the Legend value that the CrosshairContentShowMode enumeration contains. Note that you can specify the crosshair’s content show mode for the specified series using the XYSeries2D.CrosshairContentShowMode property.

Use the CustomDrawCrosshairEventArgs.CrosshairLegendElements property to obtain the crosshair legend elements’ collection.

To customize each crosshair legend element options, use the CrosshairLegendElement class properties.

csharp
using System.Windows;
using System.Windows.Media;
using DevExpress.Xpf.Charts;
namespace CustomDrawCrosshair {
    public partial class MainWindow : Window {
        const int ColorSelectorValue = 10;
        public MainWindow() {
            InitializeComponent();
        }
        private void OnCustomDrawCrosshair(object sender, CustomDrawCrosshairEventArgs e) {
            foreach(CrosshairLegendElement legendElement in e.CrosshairLegendElements) {
                legendElement.Foreground = (legendElement.SeriesPoint.Value > ColorSelectorValue) ? Brushes.Green : Brushes.Red;
                legendElement.LineElement.Brush = legendElement.Foreground;
                legendElement.AxisLabelElement.Background = legendElement.Foreground;
            }            
        }
    }
}
vb
Imports System.Windows
Imports System.Windows.Media
Imports DevExpress.Xpf.Charts

Namespace CustomDrawCrosshair

    Public Partial Class MainWindow
        Inherits Window

        Const ColorSelectorValue As Integer = 10

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub OnCustomDrawCrosshair(ByVal sender As Object, ByVal e As CustomDrawCrosshairEventArgs)
            For Each legendElement As CrosshairLegendElement In e.CrosshairLegendElements
                legendElement.Foreground = If((legendElement.SeriesPoint.Value > ColorSelectorValue), Brushes.Green, Brushes.Red)
                legendElement.LineElement.Brush = legendElement.Foreground
                legendElement.AxisLabelElement.Background = legendElement.Foreground
            Next
        End Sub
    End Class
End Namespace
xaml
<Window
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CustomDrawCrosshair"
        xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts" 
        x:Class="CustomDrawCrosshair.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <dxc:ChartControl CustomDrawCrosshair="OnCustomDrawCrosshair">
            <dxc:ChartControl.CrosshairOptions>
                <dxc:CrosshairOptions ContentShowMode="Legend"
                                      ShowValueLabels="True"
                                      ShowValueLine="True"/>
            </dxc:ChartControl.CrosshairOptions>
            <dxc:ChartControl.Legends>
                <dxc:Legend/>
            </dxc:ChartControl.Legends>
            <dxc:XYDiagram2D>
                <dxc:BarSideBySideSeries2D DisplayName="Series1">
                    <dxc:SeriesPoint Argument="A" Value="8.452"/>
                    <dxc:SeriesPoint Argument="B" Value="13.697"/>
                    <dxc:SeriesPoint Argument="C" Value="9.147"/>
                    <dxc:SeriesPoint Argument="D" Value="12.186"/>
                    <dxc:SeriesPoint Argument="E" Value="10.82"/>
                </dxc:BarSideBySideSeries2D>
                <dxc:BarSideBySideSeries2D DisplayName="Series2">
                    <dxc:SeriesPoint Argument="A" Value="10.89"/>
                    <dxc:SeriesPoint Argument="B" Value="8.254"/>
                    <dxc:SeriesPoint Argument="C" Value="11.196"/>
                    <dxc:SeriesPoint Argument="D" Value="13.327"/>
                    <dxc:SeriesPoint Argument="E" Value="9.75"/>
                </dxc:BarSideBySideSeries2D>
            </dxc:XYDiagram2D>
        </dxc:ChartControl>
    </Grid>
</Window>

See Also

CrosshairLegendElement Class

CrosshairLegendElement Members

DevExpress.Xpf.Charts Namespace