-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_ui.R
346 lines (339 loc) · 11.5 KB
/
app_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
#' The application User-Interface
#'
#' @param request Internal parameter for `{shiny}`.
#' DO NOT REMOVE.
#' @import shiny
#' @noRd
app_ui <- function(request) {
tagList(
# External resources
golem_add_external_resources(),
shinyjs::useShinyjs(),
# Application UI logic
bslib::page_navbar(
id = "page_navbar",
title = "NHP mitigator comparisons [WIP]",
## sidebar ----
sidebar = bslib::sidebar(
id = "sidebar",
title = "Global settings",
width = 400,
bslib::accordion(
id = "global_accordion",
open = FALSE,
### scheme select ----
bslib::accordion_panel(
id = "accordion_schemes",
title = "Select schemes",
icon = bsicons::bs_icon("hospital"),
shiny::selectInput(
inputId = "focus_scheme",
label = bslib::tooltip(
trigger = list(
"Focal scheme",
bsicons::bs_icon("info-circle")
),
"The scheme to highlight in plots. Causes autoselection of peers."
),
choices = NULL,
selected = NULL,
multiple = FALSE
),
shiny::selectInput(
inputId = "schemes",
label = bslib::tooltip(
trigger = list(
"Schemes to visualise",
bsicons::bs_icon("info-circle")
),
"Defaults to peers of the selected scheme if 'Select all schemes?' is unchecked."
),
choices = NULL,
selected = NULL,
multiple = TRUE
),
shiny::checkboxInput(
inputId = "toggle_all_schemes",
label = bslib::tooltip(
trigger = list(
"Select all schemes?",
bsicons::bs_icon("info-circle")
),
"Automatically select all schemes at once."
),
value = TRUE
)
),
### mitigator select ----
bslib::accordion_panel(
id = "accordion_mitigators",
title = "Select mitigators",
icon = bsicons::bs_icon("sliders"),
shiny::selectInput(
inputId = "activity_type",
label = bslib::tooltip(
trigger = list(
"Activity type",
bsicons::bs_icon("info-circle")
),
"Select an activity type to filter the mitigators by."
),
choices = c("All", "Inpatients", "Outpatients", "Accident and Emergency"),
selected = "All",
multiple = FALSE
),
shiny::selectInput(
inputId = "mitigator_groups",
label = bslib::tooltip(
trigger = list(
"Mitigator group",
bsicons::bs_icon("info-circle")
),
"Select a group to pre-populate the mitigator selection box."
),
choices = NULL,
selected = NULL,
multiple = FALSE
),
shiny::selectInput(
inputId = "mitigators",
label = bslib::tooltip(
trigger = list(
"Mitigators to visualise",
bsicons::bs_icon("info-circle")
),
"Prepopulated given the activity type and mitigator-group selections, but you can add or remove individual mitigators."
),
choices = NULL,
selected = NULL,
multiple = TRUE
)
)
)
),
## navpanel ----
### information ----
bslib::nav_panel(
id = "nav_panel_info",
title = "Information",
bslib::navset_card_underline(
id = "navset",
bslib::nav_panel(
title = "About",
md_file_to_html("app", "text", "about.md")
),
bslib::nav_panel(
title = "How to use",
md_file_to_html("app", "text", "how-to.md")
)
)
),
### point range plots ----
bslib::nav_panel(
id = "nav_panel_pointrange",
title = "Point-ranges",
bslib::card(
full_screen = TRUE,
bslib::layout_sidebar(
sidebar = bslib::sidebar(
title = "Point-range settings",
open = TRUE,
shiny::checkboxInput(
inputId = "toggle_horizon_pointrange",
label = bslib::tooltip(
trigger = list(
"Standardise by horizon length?",
bsicons::bs_icon("info-circle")
),
"Divides the scheme's chosen mitigator values by the number of years between the chosen start and final year."
),
value = FALSE
),
shiny::checkboxInput(
inputId = "toggle_mitigator_code_pointrange",
label = bslib::tooltip(
trigger = list(
"Show mitigator code?",
bsicons::bs_icon("info-circle")
),
"Replaces the full mitigator name with the mitigator code."
),
value = FALSE
),
shiny::checkboxInput(
inputId = "toggle_invert_facets",
label = bslib::tooltip(
trigger = list(
"Facet by scheme?",
bsicons::bs_icon("info-circle")
),
"Invert the pointrange plots to show mitigators on the y axis and scheme as the faceting variable."
),
value = FALSE
),
shiny::checkboxInput(
inputId = "toggle_nee_reference_range",
label = bslib::tooltip(
trigger = list(
"Show NEE range?",
bsicons::bs_icon("info-circle")
),
"Include reference results from the National Elicitation Exercise (NEE). These values are shown as horizontal bars behind each point illustrating the 10% to 90% range, with a vertical line marking the mean value."
),
value = TRUE
),
shiny::numericInput(
inputId = "facet_rows",
label = bslib::tooltip(
trigger = list(
"Number of facet rows",
bsicons::bs_icon("info-circle")
),
"Choose the number of rows over which to break the faceted pointrange charts."
),
value = 2,
min = 1,
max = 5,
step = 1
),
shiny::bookmarkButton(
label = "Bookmark ",
icon = shiny::icon("bookmark", lib = "glyphicon"),
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4"
)
),
shiny::plotOutput("pointrange"),
)
)
),
### heatmap plots ----
bslib::nav_panel(
id = "nav_panel_heatmaps",
title = "Heatmaps",
bslib::navset_card_underline(
id = 'nav_panel_heatmaps_tabs',
full_screen = TRUE,
#### heatmaps ----
bslib::nav_panel(
title = bslib::tooltip(
trigger = list(
'Heatmaps',
bsicons::bs_icon('info-circle')
),
'Customisable heatmaps showing distributions of values by mitigator and scheme'
),
bslib::layout_sidebar(
sidebar = bslib::sidebar(
title = "Heatmap settings",
open = TRUE,
shiny::selectInput(
inputId = "heatmap_type",
label = bslib::tooltip(
trigger = list(
"Value type",
bsicons::bs_icon("info-circle")
),
"Schemes' low or high 80% confidence internal selection in the NHP inputs app, or the range or midpoint of these."
),
choices = c(
Binary = "value_binary",
Midpoint = "value_mid",
Range = "value_range",
Low = "value_lo",
High = "value_hi"
),
selected = "value_mid",
multiple = FALSE
),
shiny::checkboxInput(
inputId = "toggle_horizon_heatmap",
label = bslib::tooltip(
trigger = list(
"Standardise by horizon length?",
bsicons::bs_icon("info-circle")
),
"Divides the scheme's chosen mitigator values by the number of years between the chosen start and final year."
),
value = FALSE
),
shiny::bookmarkButton(
label = "Bookmark",
icon = shiny::icon("bookmark", lib = "glyphicon"),
style = "color: #fff; background-color: #337ab7; border-color: #2e6da4"
)
),
shiny::plotOutput("heatmap"),
)
),
#### mitigator coverage ----
bslib::nav_panel(
title = bslib::tooltip(
trigger = list(
'Mitigator coverage',
bsicons::bs_icon('info-circle')
),
'The proportion of schemes using each mitigator',
),
DT::DTOutput("mitigator_uptake_dt")
),
#### scheme coverage ----
bslib::nav_panel(
title = bslib::tooltip(
trigger = list(
'Scheme coverage',
bsicons::bs_icon('info-circle')
),
'The proportion of mitigators in use by each scheme. Selected schemes are shown in bold, the focal scheme is highlighted in red.',
),
DT::DTOutput("scheme_uptake_dt")
),
),
),
### data -----
bslib::nav_panel(
id = "nav_panel_data",
title = "Data",
bslib::navset_card_underline(
full_screen = TRUE,
bslib::nav_panel(
"Raw data",
DT::DTOutput("raw_data_dt")
),
bslib::nav_panel(
"Mitigator lookup",
DT::DTOutput("mitigator_lookup_dt")
),
bslib::nav_panel(
"Scheme lookup",
DT::DTOutput("scheme_lookup_dt")
)
)
),
bslib::nav_spacer(),
bslib::nav_item(bslib::input_dark_mode(mode = "light"))
)
)
}
#' Add external Resources to the Application
#'
#' This function is internally used to add external
#' resources inside the Shiny application.
#'
#' @import shiny
#' @importFrom golem add_resource_path activate_js favicon bundle_resources
#' @noRd
golem_add_external_resources <- function() {
add_resource_path(
"www",
app_sys("app/www")
)
tags$head(
favicon(),
bundle_resources(
path = app_sys("app/www"),
app_title = "NHP mitigator comparisons"
)
# Add here other external resources
# for example, you can add shinyalert::useShinyalert()
)
}