-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathForm1.vb
89 lines (78 loc) · 3.48 KB
/
Form1.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Imports System
Imports System.Data
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraEditors
Imports DevExpress.DashboardWin
Imports DevExpress.DashboardCommon
Imports DevExpress.XtraCharts
Imports DevExpress.DashboardCommon.ViewerData
Namespace Dashboard_ClientDataCards_Win
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
AddHandler dashboardViewer1.DashboardItemClick, AddressOf dashboardViewer1_DashboardItemClick
End Sub
' Handles the DashboardViewer.DashboardItemClick event.
Private Sub dashboardViewer1_DashboardItemClick(ByVal sender As Object, ByVal e As DashboardItemMouseActionEventArgs)
If e.DashboardItemName = "cardDashboardItem1" And e.GetAxisPoint() IsNot Nothing Then
' Obtains client data related to the clicked card.
Dim clickedItemData As MultiDimensionalData = e.Data.GetSlice(e.GetAxisPoint())
Dim delta As DeltaDescriptor = e.GetDeltas()(0)
' Creates a data table that will be used to hold client data.
Dim dataSource As New DataTable()
dataSource.Columns.Add("Argument", GetType(Date))
dataSource.Columns.Add("Actual", GetType(Double))
dataSource.Columns.Add("Target", GetType(Double))
' Saves values of axis points placed on the "sparkline" axis and corresponding
' actual/target values to the data table.
For Each point As AxisPoint In clickedItemData.GetAxisPoints(DashboardDataAxisNames.SparklineAxis)
Dim row As DataRow = dataSource.NewRow()
Dim deltaValue As DeltaValue = clickedItemData.GetSlice(point).GetDeltaValue(delta)
If deltaValue.ActualValue.Value IsNot Nothing AndAlso deltaValue.TargetValue.Value IsNot Nothing Then
row("Argument") = point.Value
row("Actual") = deltaValue.ActualValue.Value
row("Target") = deltaValue.TargetValue.Value
Else
row("Argument") = DBNull.Value
row("Actual") = DBNull.Value
row("Target") = DBNull.Value
End If
dataSource.Rows.Add(row)
Next point
DisplayDetailedChart(GetFormTitle(clickedItemData), dataSource)
End If
End Sub
' Creates a new form that is invoked on the card click and
' shows the chart displaying client data.
Private Sub DisplayDetailedChart(ByVal title As String, ByVal dataSource As DataTable)
Dim form As New XtraForm()
form.Text = title
form.Bounds = New Rectangle(100, 100, 700, 350)
Dim chart As New ChartControl()
chart.Parent = form
chart.Dock = DockStyle.Fill
Dim series1 As New Series("Actual", ViewType.SplineArea)
Dim series2 As New Series("Target", ViewType.Spline)
chart.Series.AddRange(New Series() { series1, series2 })
For Each series As Series In chart.Series
series.DataSource = dataSource
series.ArgumentDataMember = "Argument"
series.ValueScaleType = ScaleType.Numerical
Next series
series1.ValueDataMembers.AddRange(New String() { "Actual" })
series2.ValueDataMembers.AddRange(New String() { "Target" })
CType(chart.Diagram, XYDiagram).AxisY.Label.TextPattern = "{V:$0}"
form.ShowDialog()
form.Dispose()
End Sub
' Obtains a value of the axis point placed on the "default" axis
' to display this value in the invoked form title.
Private Function GetFormTitle(ByVal clickedItemData As MultiDimensionalData) As String
Dim clickedPoint As AxisPoint = clickedItemData.GetAxisPoints(DashboardDataAxisNames.DefaultAxis)(0)
Dim clickedPointValue As String = clickedPoint.Value.ToString()
Return clickedPointValue
End Function
End Class
End Namespace