This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
/
MainWindow.xaml.vb
61 lines (54 loc) · 2.1 KB
/
MainWindow.xaml.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Imports Microsoft.VisualBasic
Imports System.Windows
Imports System.Windows.Input
Imports DevExpress.Xpf.Charts
Imports System.Text
Namespace DetermineHoveredChartElement
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub chartControl1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
' Obtain hit information under the test point.
Dim hitInfo As ChartHitInfo = chartControl1.CalcHitInfo(e.GetPosition(chartControl1))
Dim builder As New StringBuilder()
' Check whether the chart element is under the test point and if so - obtain the element's content.
If hitInfo.InDiagram Then
builder.AppendLine("In diagram")
End If
If hitInfo.InAxis Then
builder.AppendLine("In axis:" & hitInfo.Axis.Name)
End If
If hitInfo.AxisLabel IsNot Nothing Then
builder.AppendLine("Axis Label:" & Constants.vbLf + hitInfo.AxisLabel.Name)
End If
If hitInfo.AxisTitle IsNot Nothing Then
builder.AppendLine("Axis title:" & Constants.vbLf + hitInfo.AxisTitle.Content)
End If
If hitInfo.InTitle Then
builder.AppendLine("In chart title:" & Constants.vbLf & " " & hitInfo.Title.Content)
End If
If hitInfo.InLegend Then
builder.AppendLine("In legend")
End If
If hitInfo.InSeries Then
builder.AppendLine("In series: " & hitInfo.Series.Name)
End If
If hitInfo.InSeriesLabel Then
builder.AppendLine("In series label")
builder.AppendLine("Series Label:" & hitInfo.SeriesLabel.Name)
End If
If hitInfo.SeriesPoint IsNot Nothing Then
builder.AppendLine("Argument: " & hitInfo.SeriesPoint.Argument)
builder.AppendLine("Value: " & hitInfo.SeriesPoint.Value)
End If
' Show hit-testing results
If builder.Length > 0 Then
text1.Content = String.Format("Hit-testing results:" & Constants.vbLf + builder.ToString())
Else
text1.Content = "Move the mouse" & Constants.vbLf & " pointer over" & Constants.vbLf & " the chart to see" & Constants.vbLf & " information on" & Constants.vbLf & " hovered chart" & Constants.vbLf & " elements."
End If
End Sub
End Class
End Namespace