-
Notifications
You must be signed in to change notification settings - Fork 8
/
ui.R
414 lines (395 loc) · 19.7 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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
## ui.R ##
header <- dashboardHeader(title = span(tagList(icon("diagnoses"), "CoronaDash")),
tags$li(a(href = 'https://petolau.github.io/',
target="_blank", "Created by PetoLau",
img(src = 'favicon_trans.png',
title = "PetoLau", height = "25px"),
style = "padding-top:13px; padding-bottom:9px;"),
class = "dropdown")
)
sidebar <- dashboardSidebar(
sidebarMenuOutput("Side_dash")
)
css <- ".shiny-output-error { visibility: hidden; }
.shiny-output-error:before { visibility: hidden; }
"
body <- dashboardBody(
useShinyjs(),
tags$head(tags$link(rel = "shortcut icon", href = "favicon_trans.png")),
tags$style(make_css(list('.dygraph-legend',
c('left', 'background-color'),
c('70px !important', 'transparent !important')))),
tags$head(
tags$style(
HTML(
".checkboxgroup-inline {
margin-left: 0px;
margin-right: 10px;
}
.checkboxgroup-inline+.checkboxgroup-inline {
margin-left: 0px;
margin-right: 10px;
}
"
)
)
),
tags$script(HTML("
var openTab = function(tabName){
$('a', $('.sidebar')).each(function() {
if(this.getAttribute('data-value') == tabName) {
this.click()
};
});
}
")),
shinyEffects::setShadow(class = "box"),
shinyEffects::setShadow(id = "my-progress"),
shinyWidgets::useSweetAlert(),
setSliderColor(color = "DeepSkyBlue",
sliderId = 1),
chooseSliderSkin("Flat"),
tags$style(type="text/css", css),
tabItems(
tabItem(tabName = "corTab",
class = 'active',
fluidRow(
column(width = 4,
box(title = span(icon("magic"), " Select your preferences - country and forecasting horizon"),
solidHeader = F, status = "info",
collapsible = TRUE, width = NULL,
uiOutput("selector_country"),
uiOutput("slider_n_days_forec"),
htmlOutput("text_date_update")
),
box(
title = span(icon("share-alt"), " Connect with the author on:"),
status = "info",
solidHeader = F,
footer = "Links for my twitter, linkedin and github accounts.",
collapsible = TRUE, width = NULL, collapsed = TRUE,
# htmlOutput("text_accounts"),
socialButton(
url = "https://twitter.com/petolauri",
type = "twitter"
),
socialButton(
url = "https://www.linkedin.com/in/peter-laurinec-590a8a90",
type = "linkedin"
),
socialButton(
url = "https://github.com/PetoLau/CoronaDash",
type = "github"
)
)
),
box(title = span(icon("table"), " Table of countries"),
footer = "Table is sorted by total Active cases. New cases = cases in the past day (24h).
ActCases/MilPop = Active cases per 1 million population",
status = "info",
solidHeader = F,
collapsible = TRUE, width = 4, collapsed = F,
DTOutput("dt_countries_cases")
),
box(
title = span(icon("info-circle"), " Information about this app and forecasting COVID-19"),
status = "info",
solidHeader = T,
collapsible = FALSE, width = 4, collapsed = F,
htmlOutput("informative_text")
)
),
fluidRow(
box(title = span(icon("table"), " Statistics"),
solidHeader = F, status = "warning",
collapsible = TRUE, width = 12,
valueBoxOutput("valuebox_total_cases") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_deaths") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_death_rate") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_active") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_recov") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_active_per_mil") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_positivetests_rate") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_num_tests_pop") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
tabBox(
title = span(icon("chart-area"), " Cases for the selected country"),
id = "tabset1",
tabPanel("Cumulative cases",
htmlOutput("cases_text"),
dygraphOutput("dygraph_country_cases") %>% withSpinner(color = "#5bc0de")),
tabPanel("New cases only",
# htmlOutput("cases_text"),
dygraphOutput("dygraph_country_new_cases") %>% withSpinner(color = "#5bc0de"))
),
# box(title = span(icon("chart-area"), " Cases for the selected country"),
# solidHeader = F, status = "primary",
# collapsible = TRUE, width = 6,
# htmlOutput("cases_text"),
# dygraphOutput("dygraph_country_cases") %>% withSpinner(color = "#5bc0de")
# ),
box(title = span(icon("chart-line"), " Forecasted total cumulative cases for the selected country +
90% upper prediction interval"),
solidHeader = F, status = "primary",
collapsible = TRUE, width = 6,
htmlOutput("cases_forec_text"),
dygraphOutput("dygraph_country_cases_forecast") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
tabBox(
title = span(icon("chart-area"), " Deaths for the selected country"),
id = "tabset2",
tabPanel("Cumulative deaths",
htmlOutput("death_text"),
dygraphOutput("dygraph_country_deaths") %>% withSpinner(color = "#5bc0de")
),
tabPanel("New deaths only",
# htmlOutput("death_text"),
dygraphOutput("dygraph_country_new_deaths") %>% withSpinner(color = "#5bc0de")
)
)
# box(title = span(icon("chart-area"), " Deaths for the selected country"),
# solidHeader = F, status = "primary",
# collapsible = TRUE, width = 6,
# htmlOutput("death_text"),
# dygraphOutput("dygraph_country_deaths") %>% withSpinner(color = "#5bc0de")
# )
# box(title = span(icon("chart-line"), " Forecasted cumulative deaths for the selected country +
# 90% upper prediction interval"),
# solidHeader = F,
# collapsible = TRUE, width = 6,
# dygraphOutput("dygraph_country_deaths_forecast") %>% withSpinner(color = "#5bc0de")
# )
)
),
tabItem(tabName = "compareTab",
fluidRow(
box(title = span(icon("flag"), " Select multiple countries for comparison"),
solidHeader = F, status = "info",
collapsible = F, width = 6,
uiOutput("picker_countries_selector")
),
box(title = span(icon("table"), " Select one statistic for comparison"),
solidHeader = F, status = "danger",
collapsible = F, width = 3,
uiOutput("picker_stats_selector"),
uiOutput("switch_log_scale_compareTab")
),
box(title = span(icon("angle-double-up"), " Set parameters for comparison of \"since first\" trajectories graph"),
solidHeader = F, status = "info",
collapsible = F, width = 3,
uiOutput("selector_cases_since_first_n"),
uiOutput("selector_deaths_since_first_n")
)
),
fluidRow(
box(title = span(icon("chart-line"), " Comparison of countries' trajectories since their first total N-th case/ N-th death"),
solidHeader = F, status = "primary",
collapsible = TRUE, width = 12,
dygraphOutput("dygraph_countries_stats_since_first") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
box(title = span(icon("chart-area"), " Comparison of countries"),
solidHeader = F, status = "primary",
collapsible = TRUE, width = 12,
dygraphOutput("dygraph_countries_stats") %>% withSpinner(color = "#5bc0de")
)
)
),
tabItem(tabName = "trajectoryTab",
fluidRow(
box(title = span(icon("info-circle"), " Information about analysis capabilities in this dashboards tab"),
solidHeader = T, status = "info",
collapsible = F, width = 12,
htmlOutput("info_clustering_trajectories")
)
),
fluidRow(
box(title = span(icon("table"), " Select one statistic for clustering trajectories"),
solidHeader = F, status = "info",
collapsible = F, width = 4,
uiOutput("picker_stat_selector_clust"),
uiOutput("picker_country_clust"),
# infoBoxOutput("infobox_inwhich_cluster_country") %>% withSpinner(color = "#5bc0de", size = 0.1)
htmlOutput("text_inwhich_cluster_country")
),
box(title = span(icon("angle-double-up"), " Set parameters for comparison of \"since first\" trajectories data"),
solidHeader = F, status = "info",
collapsible = F, width = 4,
uiOutput("selector_cases_since_first_n_clust"),
uiOutput("selector_deaths_since_first_n_clust")
),
box(title = span(icon("sliders-h"), " Select parameters for analysis/ clustering"),
solidHeader = F, status = "info",
collapsible = F, width = 4,
uiOutput("selector_top_n_countries_clust"),
uiOutput("selector_n_clusters_dtw")
)
),
fluidRow(
box(title = span(icon("chart-line"), " Clustered countries' trajectories based on selected statistics and parameters (see above)"),
solidHeader = F, status = "info",
footer = "DTW distance measure and hierarchical clustering with Ward criterion are used.
Colored dashed lines are DTW barycenters.",
collapsible = TRUE, width = 8,
fluidRow(column(width = 5, uiOutput("selector_sma_order")),
column(width = 4, uiOutput("switch_normalization")),
column(width = 3, uiOutput("switch_log_scale"))
),
plotOutput("plot_clusters_trajectories", height = "70vh") %>% withSpinner(color = "#5bc0de")
),
box(title = span(icon("crosshairs"), " Focus plot for detailed analysis of countries in the selected cluster"),
solidHeader = F, status = "primary",
footer = "Interactive plot - zoom in/out etc.",
collapsible = TRUE, width = 4,
uiOutput("picker_cluster_focus"),
plotlyOutput("plotly_focus_cluster") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
box(title = span(icon("tree"), " Dendrogram of clustered countries' trajectories based on similarities of selected statistic"),
footer = "DTW distance measure and hierarchical clustering with Ward criterion are used.",
solidHeader = F, status = "success",
collapsible = F, width = 7,
# uiOutput("dropdown_clustering_crit"),
plotOutput("plot_clusters_trajectories_dendogram", height = "75vh") %>% withSpinner(color = "#5bc0de")
),
box(title = span(icon("chart-area"), " 2D MDS Scatter plot of clustered countries' trajectories for selected statistic"),
footer = "MDS - Multidimensional scaling - parametric.",
solidHeader = F, status = "info",
collapsible = F, width = 5,
plotOutput("plot_scatter_mds_trajectories", height = "72vh") %>% withSpinner(color = "#5bc0de")
)
)
),
tabItem(tabName = "analysisTab",
fluidRow(
box(title = span(icon("info-circle"), " Information about analysis capabilities in this dashboards tab"),
solidHeader = T, status = "info",
collapsible = F, width = 12,
htmlOutput("info_clustering_stats")
)
),
fluidRow(
box(title = span(icon("balance-scale"), " Select multiple statistics for clustering countries based on these data"),
solidHeader = F, status = "info",
collapsible = F, width = 9,
uiOutput("picker_multiple_stats_clust"),
uiOutput("picker_sort_column")
),
box(title = span(icon("sliders-h"), " Select parameters for analysis/ clustering"),
solidHeader = F, status = "info",
collapsible = F, width = 3,
uiOutput("selector_top_n_countries_multi"),
uiOutput("selector_n_clusters_multi")
)
),
fluidRow(
box(title = span(icon("chart-area"), " 2D/MDS Scatter plot of countries for selected statistics"),
footer = "If a number of statistics is equal to 2, then scatter plot is used without MDS. If n > 2 then MDS is always used.
MDS - Multidimensional scaling - parametric.",
solidHeader = F, status = "info",
collapsible = F, width = 6,
plotOutput("plot_scatterplot_mds_country_stats", height = "72vh") %>% withSpinner(color = "#5bc0de")
),
box(title = span(icon("tree"), " Dendrogram of clustered countries based on similarities of selected statistics"),
footer = "Euclidean distance measure and hierarchical clustering with Ward criterion are used.",
solidHeader = F, status = "success",
collapsible = F, width = 6,
uiOutput("dropdown_clustering_crit"),
plotOutput("clust_res_multidim", height = "75vh") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
box(title = span(icon("table"), " Clusters' members averages"),
# footer = "If a number of statistics is equal to 2, then scatter plot is used without MDS. If n > 2 then MDS is always used.
# MDS - Multidimensional scaling - parametric.",
solidHeader = F, status = "info",
collapsible = F, width = 12,
DTOutput("dt_clusters_averages") %>% withSpinner(color = "#5bc0de")
)
)
),
tabItem(tabName = "worldTab",
fluidRow(
box(title = span(icon("table"), " World statistics"),
solidHeader = F, status = "warning",
collapsible = TRUE, width = 12,
valueBoxOutput("valuebox_total_cases_world") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_deaths_world") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_death_rate_world") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_active_world") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_total_recov_world") %>% withSpinner(color = "#5bc0de"),
valueBoxOutput("valuebox_active_per_mil_world") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
tabBox(
title = span(icon("chart-area"), " Cases for the World"),
id = "tabset3",
tabPanel("Cumulative cases",
htmlOutput("cases_text_world"),
dygraphOutput("dygraph_world_cases") %>% withSpinner(color = "#5bc0de")
),
tabPanel("New cases only",
# htmlOutput("cases_text_world"),
dygraphOutput("dygraph_world_new_cases") %>% withSpinner(color = "#5bc0de")
)
),
# box(title = span(icon("chart-area"), " Cases for the World"),
# solidHeader = F, status = "primary",
# collapsible = TRUE, width = 6,
# htmlOutput("cases_text_world"),
# dygraphOutput("dygraph_world_cases") %>% withSpinner(color = "#5bc0de")
# ),
box(title = span(icon("chart-line"), " Forecasted total cumulative cases for the World +
90% upper prediction interval"),
solidHeader = F, status = "primary",
collapsible = TRUE, width = 6,
dygraphOutput("dygraph_world_cases_forecast") %>% withSpinner(color = "#5bc0de")
)
),
fluidRow(
tabBox(
title = span(icon("chart-area"), " Deaths for the World"),
id = "tabset4",
tabPanel("Cumulative deaths",
htmlOutput("death_text_world"),
dygraphOutput("dygraph_world_deaths") %>% withSpinner(color = "#5bc0de")
),
tabPanel("New deaths only",
# htmlOutput("death_text_world"),
dygraphOutput("dygraph_world_new_deaths") %>% withSpinner(color = "#5bc0de")
)
),
# box(title = span(icon("chart-area"), " Deaths for the World"),
# solidHeader = F, status = "primary",
# collapsible = TRUE, width = 6,
# htmlOutput("death_text_world"),
# dygraphOutput("dygraph_world_deaths") %>% withSpinner(color = "#5bc0de")
# ),
box(title = span(icon("chart-line"), " Forecasted total cumulative deaths for the World +
90% upper prediction interval"),
solidHeader = F, status = "primary",
collapsible = TRUE, width = 6,
dygraphOutput("dygraph_world_deaths_forecast") %>% withSpinner(color = "#5bc0de")
)
)
)
)
)
ui <- function(req) {
dashboardPagePlus(
title = "CoronaDash",
enable_preloader = TRUE,
loading_duration = 2.1,
header = header,
sidebar = sidebar,
body = body,
skin = "blue-light" # -light
)
}