This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
MainWindow.xaml.vb
45 lines (38 loc) · 1.56 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
Imports System
Imports System.Linq
Imports System.Windows
Imports System.Windows.Input
Imports DevExpress.Xpf.Charts
Imports System.Collections.Generic
Namespace ChartSample
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub Chart_MouseDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
Dim chartControl As ChartControl = DirectCast(sender, ChartControl)
Dim hitInfo As ChartHitInfo = chartControl.CalcHitInfo(e.GetPosition(chartControl))
Dim pointIndex As Integer = series.Points.IndexOf(hitInfo.SeriesPoint)
Dim point As SeriesPoint = hitInfo.SeriesPoint
Dim oldPointPercent As Double=0
CalcPointPercent(pointIndex, oldPointPercent)
point.Value += 1
Dim newPointPercent As Double = 0
CalcPointPercent(pointIndex, newPointPercent)
series.Rotation += 360 * (oldPointPercent - newPointPercent)
If series.Rotation > 360 Then
series.Rotation = series.Rotation Mod 360
End If
End Sub
Private Sub CalcPointPercent(ByVal pointIndex As Integer, ByRef oldPointPercent As Double)
For i As Integer = 0 To pointIndex - 1
oldPointPercent += series.Points(i).Value
Next i
oldPointPercent /= series.Points.Sum(Function(p) p.Value)
End Sub
End Class
End Namespace