-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
278 lines (237 loc) · 7.65 KB
/
ui.R
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# Define the app's user interface
ui <- fixedPage(
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "app.css")
),
navbarPage(
# Page title
# Displayed to the left of the navigation bar
title = div(
img(
src = "codeclan-logo.png",
height = "40px"
),
style = "position: relative; top: -10px"
),
windowTitle = "CodeClan Location Data",
# Parent sections organised by tab
# Overview parent tab
# Contains the MVP and a broad overview of the data
tabPanel(
title = "Overview",
# Title
titlePanel("Aggregate User Data by Location"),
# =======================================================================================================================
# CONTROLS
# =======================================================================================================================
fluidRow(
class = "controls",
# Date range controls
column(
width = 4,
dateRangeInput(
inputId = "date",
label = "Date range",
# Default start and end dates (set to Q1 2020)
start = "2020-01-01",
end = "2020-03-31",
# Minimum and maximum dates (set to the minimum and maximum values defined by the dataset)
min = ui_date_range[1],
max = ui_date_range[2]
)
),
# Catchment area slider controls
column(
width = 4,
sliderInput(
inputId = "catchment_radius",
label = "Catchment area radius (km)",
# Minimum and maximum values
# Set maximum value to 135 (approximately the distance from Edinburgh to Aberdeen)
min = 0,
max = 135,
# Default end value
value = 34,
step = 1
)
),
# Catchment area checkbox selector
# Choose which of the three (four including NAs) key catchment areas to display data for
column(
width = 4,
checkboxGroupInput(
inputId = "catchment_select",
label = "Selected catchment areas",
choices = c(
"Edinburgh",
"Glasgow",
"Inverness",
"None"
),
selected = c(
"Edinburgh",
"Glasgow",
"Inverness"
)
)
)
),
# Main body
fluidRow(
column(width = 3,
# Leaflet plot
fluidRow(
h4("Catchment areas"),
leafletOutput("leaflet_plot")
),
br(class = "spacer"),
# Total visitors
fluidRow(
h4("Total visitors"),
# Total Scottish visitors
div(
style = "text-align: center",
div(
style = "font-size: 200%; font-weight: bold",
textOutput("text_sessions_sum")
),
tags$i("throughout Scotland"),
br(),
# Total visitors per catchment area
div(
style = "font-size: 300%; font-weight: bold",
textOutput("text_sum_catchment_sessions_bydate")
),
tags$i("in selected catchments")
)
),
br(class = "spacer"),
# Percentage share of visitors per catchment area
fluidRow(
h4("Percentage share"),
fluidRow(
column(
width = 6,
div(class = "catchment-name", "Edinburgh")
),
column(
width = 6,
div(
class = "percent",
textOutput("text_catchment_sessions_share_ed"),
p(class = "percent-sign", "%")
)
)
),
fluidRow(
column(
width = 6,
div(class = "catchment-name", "Glasgow")
),
column(
width = 6,
div(
class = "percent",
textOutput("text_catchment_sessions_share_gl"),
p(class = "percent-sign", "%")
)
)
),
fluidRow(
column(
width = 6,
div(class = "catchment-name", "Inverness")
),
column(
width = 6,
div(
class = "percent",
textOutput("text_catchment_sessions_share_in"),
p(class = "percent-sign", "%")
)
)
),
fluidRow(
column(
width = 6,
div(class = "catchment-name", "None")
),
column(
width = 6,
div(
class = "percent",
textOutput("text_catchment_sessions_share_na"),
p(class = "percent-sign", "%")
)
)
)
)
),
column(
width = 9,
h4("Number of sessions per catchment area"),
plotOutput("session_performance_plot"),
plotOutput("sum_catchment_sessions")
)
),
fluidRow(
div(class = "footer")
)
),
# =======================================================================================================================
# DEBUGGING AND TESTING
# =======================================================================================================================
# Comment out for final version
# Please keep this section as the *final* section in the ui.R script
if(debug_section_enabled == 1){
navbarMenu( # Keep the leading comma
title = "Debug",
# Section header
"Debug",
tabPanel(
title = "User-selected control values",
# Print the values selected by the user
# Confirms that the reactive inputs are functional
h2("User-selected control values"),
h4("Date range"),
textOutput("debug_print_date"),
br(),
h4("Catchment radius"),
textOutput("debug_print_catchment_radius"),
br(),
h4("Catchment area names"),
textOutput("debug_print_catchment_select")
),
tabPanel(
title = "Reactive vectors",
h2("Vectors"),
h4("Catchment area coordinates"),
tableOutput("debug_print_catchment_coordinates"),
br(),
h4("Total number of sessions"),
textOutput("debug_print_total_sessions_sum"),
),
# Section header
"----",
"Tables",
tabPanel(
title = "Full reactive dataset",
h4("Full reactive dataset"),
tableOutput("debug_print_data")
),
tabPanel(
title = "Total sessions per day",
h4("Total sessions per day"),
tableOutput("debug_print_total_sessions")
),
tabPanel(
title = "Total sessions per day per catchment",
# h4("Sum"),
# textOutput("text_sum_catchment_sessions_bydate"),
# h4("Table"),
tableOutput("debug_catchment_session_sum")
)
)
}
)
)