-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.R
579 lines (537 loc) 路 30.1 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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
shinyUI(
fluidPage(
# =========================================================================
# Headtags
# =========================================================================
theme=shinytheme('journal'),
tags$head(
HTML("<title>M茅xico: Covid-19 Tracker</title>"),
tags$link(rel = "stylesheet", type = "text/css", href = "styles.css")
),
fluidRow(
class = 'main_content',
# =========================================================================
# Main Panel
# =========================================================================
column(12,
# ***** Mexico Map and National Numbers *****
fluidRow(
# =========================================================================
# Sidebar Panel
# =========================================================================
column(12,
class = 'col-xs-12 col-sm-12 col-md-6 col-lg-3 well',
style = 'padding: 1rem 3rem 3rem 3rem; margin-top: 1.5rem',
div(style='font-size: 0.9em;',
h1(span('COVID-19:', class = 'red_color'), span('MxTracker', class='yellow_color')),
p(span('脷ltima actualizaci贸n:', style= 'font-weight: bold;'), span(last_date_formated)),
p(span('Fuente:', style='font-weight: bold;'),
a('SSalud, Mx.', href= 'https://www.gob.mx/salud/documentos/informacion-internacional-y-nacional-sobre-nuevo-coronavirus-2019-ncov', target='blank_'),
span('a trav茅s de'),
a('@carranco-sga', href= 'https://github.com/carranco-sga/Mexico-COVID-19', target='blank_'),
),
class='header'
),
hr(class='hr_main_light'),
# ***** INPUT: Date *****
fluidRow(
column(6,
h3('Fecha'),
column(12,
dateInput(
inputId = 'pickDate',
label = 'Selecciona la fecha:',
value = last_date,
format = "dd/mm/yy",
language = 'es'
),
class = 'col-sm-8 col-md-8 col-lg-10'),
column(12,
htmlOutput('date_warning'),
class = 'col-sm-8 col-md-8 col-lg-10'),
column(12,
p(style='font-weight: normal; color: #aaaaaa; font-size: 14px;',
class='yellow_color',
'S贸lo fechas entre el 23 de enero y el 17 de abril del 2020.'),
),
class = 'col-xs-12 col-sm-6 col-md-12'
),
# ***** INPUT: MAP *****
column(6,
h3('Mapa'),
column(6,
selectInput(
inputId = 'mapData',
label = 'Mostrar Casos:',
choices = list("Positivos" = 'positivos',
"Decesos" = 'decesos',
"Sospechosos" = 'sospechosos'),
selected = 'positivos'
),
class = 'col-sm-8 col-md-8 col-lg-10'),
class = 'col-xs-12 col-sm-6 col-md-12'
),
),
hr(class='hr_main_light'),
# Quedate en casa
# h2(a('#QuedateEnCasa', href='https://twitter.com/hashtag/quedatencasa', target='_blank',
# style='color: #58EBD7'), class='header'),
# br(),
# # ***** Disclaimer *****
# ***** Footer *****
HTML("<div class='header'>
<p style = 'text-align: right; font-size: 0.9em;' class='header'><a href='http://joelriccilopez.com/' target='_blank'>J. Ricci-L贸pez</a> (2020) ©.<p/>
</div>
"),
),
# =================
# National Numbers
# =================
column(12,
class = "col-xs-12 col-sm-12 col-md-6 col-lg-3 numbers_panel",
style = 'padding: 0',
div(h3('Resumen nacional',
class = 'text-center'),
style = 'margin-bottom: 0px; z-index: 100'),
hr(class='hr_main'),
# ***** Date *****
fluidRow(
column(6,
h4('Fecha:'), class = "info_column_names"),
column(6,
fluidRow(
column(12,
h4(textOutput('text_date')),
class = "info_row_right date_column"),
class='info_row')
),
class = 'info_main_row'
),
# ***** Positive Cases *****
fluidRow(
column(6,
h4('N煤mero de POSITIVOS:'),
class = "info_column_names"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_pos')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-user-plus',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row positive_bg_color')
),
class = 'info_main_row'
),
# ***** Suspected Cases *****
fluidRow(
column(6,
h4('N煤mero de SOSPECHOSOS:'),
class = "info_column_names"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_susp')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-user-clock',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row suspect_bg_color')
),
class = 'info_main_row'
),
# ***** Negative Cases *****
fluidRow(
column(6,
h4('N煤mero de NEGATIVOS:'),
class = "info_column_names"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_neg')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-user-minus',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row negative_bg_color')
),
class = 'info_main_row'
),
# ***** Recovered Cases *****
conditionalPanel(
condition = "input.pickDate < '2020-03-22'",
fluidRow(
column(6,
h4('N煤mero de RECUPERADOS:'),
class = "info_column_names col-sm-12"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_recov')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-user-shield',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row recovered_bg_color')
),
class = 'info_main_row'
),
),
# ***** Deceased Cases *****
fluidRow(
column(6,
h4('N煤mero de DECESOS:'),
class = "info_column_names"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_deaths')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-cross',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row death_bg_color')
),
class = 'info_main_row'
),
# ***** Testing *****
fluidRow(
column(6,
h4('N煤mero de pruebas realizadas:'),
class = "info_column_names"),
column(6,
fluidRow(
column(6,
h3(textOutput('text_tested')),
class = "info_row_right col-xs-6"),
column(6,
icon('fas fa-vial',
class = 'icon', lib = "font-awesome"),
class = "icon_column col-xs-6"),
class='info_row tested_bg_color')
),
class = 'info_main_row'
),
# *** DISCLAIMER ***
div(
h3('Los datos de esta aplicaci贸n fueron obtenidos a partir de los Comunicados T茅cnicos di谩rios de la',
a('Secretar铆a de Salud, Mx', href="https://www.gob.mx/salud/documentos/informacion-internacional-y-nacional-sobre-nuevo-coronavirus-2019-ncov", target="_blank", style ="color: #FF7467;"), '. No obstante, pueden haber problemas de actualizaci贸n o errores en el c贸digo de esta aplicaci贸n, por lo cual recuerda siempre verificar con a la informaci贸n oficial.', class='small',
style='font-weight: normal; text-align: right; margin: 0 4rem; color: #666450'),
class='float-right'),
hr(),
),
# =================
# Mexico Map
# =================
column(12,
div(h3(
span('N煤mero de casos', style='font-weight: normal'),
span(textOutput('map_title_cases', inline = TRUE)),
span('por Estado:', style='font-weight: normal'),
span(textOutput('map_title_date', inline = TRUE), class='small'),
class = 'text-center'),
style = 'margin-bottom: 24px; z-index: 100'),
leafletOutput(
outputId = 'mapMx',
height = "90%"
),
fluidRow(
# column(6,
# checkboxInput("normalizeCasesMap",
# label = h4("Casos por cada 100, 000 habitantes.",
# style='font-weight: normal; color: black; margin: 0.2rem 0;'),
# value = FALSE),
#
# ),
column(6,
p(span('Da '),
span('click', class='font-weight-bold'),
span(' sobre un estado para m谩s informaci贸n.'),
style='color: #333333',
class='small'),
),
column(6,
p("GIS data map:", a('Kyle Walker', href='http://personal.tcu.edu/kylewalker/'),
style='color: #999;', class='small'),
style='text-align: right;'
),
),
class = "col-xs-12 col-sm-12 col-lg-6 sm_container",
style = "height: 580px; padding: 0 2em;",
),
),
hr(),
hr(class='hr_main'),
# =================
# TIME LINE PLOT
# =================
fluidRow(
column(12,
# =================
# Time Line
# =================
column(12, class= 'col-lg-12',
div(h3(span('L铆nea de Tiempo Nacional: ',
style='font-weight: bold;'),
span('N煤mero de casos',
style = 'font-weight: normal;'),
span(textOutput('lp_title', inline = TRUE),
style = 'font-weight: bold'),
span('por d铆a',
style = 'font-weight: normal'),
class = 'text-center')
),
div(
withSpinner(
plotlyOutput(
outputId = 'timePlot'
),
),
),
),
div(awesomeCheckbox("from_first_pos_case",
label = h4("A partir del primer caso confirmado",
style='font-weight: normal; color: #444; margin: -2px 0; padding:0'
),
status='danger',
value = TRUE),
# icon = icon("check"),
class='col-xs-12 col-sm-6 col-lg-12',
style = 'padding: 0; margin-top: 9rem; margin-left: 7rem'
),
class = 'col-xs-12 col-lg-9 col-lg-push-3 sm_container',
style = 'min-height: 620px;'
),
column(12,
# =================
# Time Line Inputs
# =================
column(12,
style='padding: 0 4rem',
class = 'col-xs-12 col-sm-12 col-md-12',
h3(icon("fas fa-clock"),
'Datos Nacionales', style='font-weight: normal; color: #333'),
hr(class='hr_main_red'),
# From the first confirmed case
# column(12,
# awesomeCheckbox("from_first_pos_case",
# label = h4("A partir del primer caso confirmado",
# style='font-weight: bold; color: #444; margin: -1rem 1rem; padding: 0'
# ),
# status='danger',
# value = TRUE),
# icon = icon("check"),
# class='col-xs-12 col-sm-6 col-lg-12',
# # style = 'padding: 0 2rem;', style='margin-top: 0rem;'
# ),
# Complementary categories
column(12,
awesomeCheckboxGroup("case_categories",
label = h4("Categor铆as complement谩rias:",
style='font-weight: bold; color: #444; margin: 1rem 0;'
),
choices = list("Casos Sospechosos" = 'Susp_rep',
"Casos Negativos" = 'Neg_rep',
"Pruebas Realizadas" = 'Tested_tot'),
selected = c('Susp_rep', 'Neg_rep', 'Tested_tot')),
class='col-xs-12 col-sm-6 col-lg-12 plot_input_labels'
),
# Cummulative or new cases
column(12,
awesomeRadio("cum_or_new_cases",
label = h4("Casos por d铆a:",
style='font-weight: bold; color: #444; margin: 1rem 0;'
),
choices = list("Acumulados" = 'cum',
"Nuevos Casos" = 'new'),
status='succes', inline=FALSE),
class='col-xs-12 col-sm-6 col-lg-12 plot_input_labels',
# style='margin-top: 1rem;'
),
# Scale
column(12,
awesomeRadio("scale_log",
label = h4("Selecciona la escala de visualizaci贸n:",
style='font-weight: bold; color: #444; margin: 1rem 0;'),
choices = list("Lineal" = 'raw',
"Logar铆tmica (log10)" = 'log'),
status='succes',
selected = 'raw', inline = F),
class='col-xs-12 col-sm-6 col-lg-12 plot_input_labels', style='margin-top: 1rem;'
),
),
class = 'col-xs-12 col-lg-3 col-lg-pull-9 sideSecondary',
style = 'padding: 3rem; color: black;'
),
),
hr(),
hr(class='hr_main'),
hr(),
fluidRow(
column(12,
class = 'col-xs-12 col-lg-12', # 'col-xs-12 col-lg-9 col-lg-push-3',
h3(span('Desglose de los Datos:'),
span(textOutput('sec2_title_date', inline = TRUE), style='font-weight: normal'),
style = 'text-align: center;'),
hr(),
column(12, class = 'col-sm-12 col-md-6 col-lg-4 sm-container',
h4(span('Distribuci贸n de Sexos:'),
span('Casos positivos', style='font-weight: normal'), class='text-center'),
div(
withSpinner(
plotlyOutput(
outputId = 'pieSex'
),
),
)
),
column(12, class = 'col-sm-12 col-md-6 col-lg-8',
h4(span('Distribuci贸n de Edades:'),
span('Casos positivos', style='font-weight: normal'), class='text-center'),
div(
withSpinner(
plotlyOutput(
outputId = 'histAges'
),
),
style = 'padding: 0 1rem;'
),
div(
checkboxInput("splitBySex",
label = h4("Distribuir por sexos",
style='font-weight: normal; color: black; margin: 0.2rem 0;'),
value = TRUE),
style='padding-left: 80px;'
),
),
# column(12, class = 'col-sm-12 col-md-3 col-lg-3',
# h4(span('Pa铆s Fuente:'),
# span('Casos positivos', style='font-weight: normal'), class='text-center'),
# div(
# withSpinner(
# plotlyOutput(
# outputId = 'importCountry'
# ),
# ),
# style = 'padding: 0 0;'
# )
# ),
),
# =====================
# Stacked bars and hist
# =====================
# column(12,
# # =================
# # Inputs
# # =================
# column(12,
# style='padding: 0 4rem',
# class = 'col-xs-12 col-sm-12 col-md-12 sm_container',
# h3(icon('fas fa-info-circle'),
# 'Informaci贸n sobre los casos', style='font-weight: normal;', class='sec3-header'),
# hr(class='hr_main_red'),
# br(),
# # Go to date button
# column(12,
# actionButton(
# inputId = 'selState',
# label = h4('Modificar fecha',
# style='font-weight: normal; color: black; margin: 0.2rem 0;'),
# onclick ="document.getElementById('pickDate').scrollIntoView();"
# ),
# class='col-xs-12 col-sm-6 col-lg-12',
# style = 'padding: 0;', style='margin-top: 1rem;'
# ),
# br(),
# br(),
# # Select data per a requested state?
# column(12,
# checkboxInput("filterByState",
# label = h4("Filtrar datos por estado.",
# style='font-weight: bold; color: #444; margin: 0 1rem;'),
# value = FALSE),
# class='col-xs-12 col-sm-6 col-lg-12',
# style = 'padding: 0 2rem;', style='margin-top: 1rem;'
# ),
# # State Selection
# conditionalPanel(
# condition = "input.filterByState === true",
# column(12,
# selectInput(
# inputId = 'selState',
# label = h4('Selecciona el Estado:',
# style='font-weight: bold; color: black; margin: 0.2rem 0;'),
# choices = MX_SATES,
# selected = 'positivos'
# ),
# class='col-xs-12 col-sm-6 col-lg-12',
# style = 'padding: 0 2rem;', style='margin-top: 1rem;'
# ),
# h4('Pendiente...')
# ),
# # Complementary categories
# column(12,
# p(''),
# class='col-xs-12 col-sm-6 col-lg-12 plot_input_labels'
# ),
# ),
# class = 'col-xs-12 col-lg-3 col-lg-pull-9 sideSecondary',
# style = 'padding: 3rem'
# ),
),
hr(),
hr(class='hr_main'),
hr(),
fluidRow(
class='justify-content-end',
column(12, class = 'col-sm-12 col-md-12 col-lg-12',
h3(span('L铆nea de Tiempo por Estado:'),
span('Casos positivos', style='font-weight: normal'), class='text-center'),
div(
withSpinner(
plotlyOutput(
outputId = 'statesTimePlot'
),
),
br(),
fluidRow(
class='justify-content-end',
style='margin-top: 4em;',
column(4,
class = 'col-sm-12 col-lg-4',
awesomeCheckbox("normalizeCases",
label = h4(span("Normalizar los casos:", style='font-weight: bold;'),
span("Casos por cada 100,000 habitantes"),
style='font-weight: normal; color: #444; margin: -2px 0; padding:0'),
value = TRUE),
style='padding-left: 2.1em;'
),
),
fluidRow(
class='justify-content-end',
column(4,
class = 'col-sm-12 4col-lg-4',
awesomeCheckbox("hideLabelsLineStates",
label = h4(span("Mostrar nombres de los estados", style='font-weight: bold;'),
style='font-weight: normal; color: #444; margin: -2px 0; padding:0'),
value = TRUE),
),
)
)
),
),
class = 'col-xs-12 col-md-12 col-lg-12',
)
),
class='main_row_layout',
div(
includeHTML('include_html/footer.html')
)
)
)