-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.vb
71 lines (61 loc) · 2.87 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
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.Json
Imports DevExpress.XtraEditors
Imports System
Namespace DashboardJsonExample
Partial Public Class Form1
Inherits XtraForm
Public Sub New()
InitializeComponent()
dashboardDesigner1.CreateRibbon()
InitializeDashboard()
dashboardDesigner1.ReloadData()
End Sub
Public Sub InitializeDashboard()
Dim dashboard As New Dashboard()
Dim jsonDataSource As DashboardJsonDataSource = CreateJsonDataSourceFromWeb()
'DashboardJsonDataSource jsonDataSource = CreateJsonDataSourceFromFile();
'DashboardJsonDataSource jsonDataSource = CreateJsonDataSourceFromString();
dashboard.DataSources.Add(jsonDataSource)
Dim pivot As New PivotDashboardItem()
pivot.DataSource = jsonDataSource
pivot.Rows.Add(New Dimension("ContactTitle"))
pivot.Columns.Add(New Dimension("Country"))
pivot.Values.Add(New Measure("Id", SummaryType.Count))
Dim chart As New ChartDashboardItem()
chart.DataSource = jsonDataSource
chart.Arguments.Add(New Dimension("Country"))
chart.Panes.Add(New ChartPane())
Dim theSeries As New SimpleSeries(SimpleSeriesType.Bar)
theSeries.Value = New Measure("Id", SummaryType.Count)
chart.Panes(0).Series.Add(theSeries)
dashboard.Items.AddRange(pivot, chart)
dashboard.RebuildLayout()
dashboard.LayoutRoot.Orientation = DashboardLayoutGroupOrientation.Vertical
dashboardDesigner1.Dashboard = dashboard
End Sub
Public Shared Function CreateJsonDataSourceFromWeb() As DashboardJsonDataSource
Dim jsonDataSource = New DashboardJsonDataSource()
jsonDataSource.JsonSource = New UriJsonSource(New Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json"))
jsonDataSource.RootElement = "Customers"
jsonDataSource.Fill()
Return jsonDataSource
End Function
Public Shared Function CreateJsonDataSourceFromFile() As DashboardJsonDataSource
Dim jsonDataSource = New DashboardJsonDataSource()
Dim fileUri As New Uri("customers.json", UriKind.RelativeOrAbsolute)
jsonDataSource.JsonSource = New UriJsonSource(fileUri)
jsonDataSource.RootElement = "Customers"
jsonDataSource.Fill()
Return jsonDataSource
End Function
Public Shared Function CreateJsonDataSourceFromString() As DashboardJsonDataSource
Dim jsonDataSource = New DashboardJsonDataSource()
Dim json As String = "{""Customers"":[{""Id"":""ALFKI"",""CompanyName"":""Alfreds Futterkiste"",""ContactName"":""Maria Anders"",""ContactTitle"":""Sales Representative"",""Address"":""Obere Str. 57"",""City"":""Berlin"",""PostalCode"":""12209"",""Country"":""Germany"",""Phone"":""030-0074321"",""Fax"":""030-0076545""}],""ResponseStatus"":{}}"
jsonDataSource.JsonSource = New CustomJsonSource(json)
jsonDataSource.RootElement = "Customers"
jsonDataSource.Fill()
Return jsonDataSource
End Function
End Class
End Namespace