-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_prod_final_style.R
448 lines (368 loc) · 11.2 KB
/
app_prod_final_style.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
#Mudando
#https://public.tableau.com/app/profile/pradeepkumar.g/viz/WebTrafficDashboardRedesign/Cockpit
divStyle <- function(color, border) {
paste0(
"background: ", color, "; ",
"border: 10px solid ", border, ";"
)
}
breakpoint_system <- getBreakpointSystem()
breakpoint_system <- addBreakpoint(
breakpoint_system,
breakpoint("md", max = 1180)
)
divStyle <- function(color, border) {
paste0(
"background: ", color, "; ",
"border: 10px solid ", border, ";"
)
}
# source(file = 'database.R')
function_hc <- function(hc){
hc %>%
hc_xAxis( type ='datetime', categories = data$dates) %>%
hc_yAxis(
title = list(text = paste0("")),
style = list(
fontSize = "16px",
color = "lightgray",
fontWeight = "100",
fontFamily = "Roboto Condensed"
),
plotLines = list(
list(
value = ymd(20220101) %>% datetime_to_timestamp(),
color = "lightgray",
dashStyle = "longdashdot",
label = list(
text = "Forecasting",
align = "right",
verticalAlign = "middle",
rotation = 0,
x = 180,
y = 50,
style = list(color = "lightgray", fontWeight = "bold")
)
)
),
gridLineWidth = 0.5,
gridLineColor = 'lightgray',
gridLineDashStyle = "longdash"
) %>%
hc_plotOptions(series = list(
lineWidth = 1.25,
marker = list(enabled = FALSE),
borderRadius = 1,
dataLabels =
list(enabled = FALSE)
)) %>%
hc_credits(enabled = TRUE,
text = "Data as of 10 - 2022")
}
### Modulo
ui <- gridPage(
tags$style(
'
@import url("https://fonts.googleapis.com/css2?family=Exo+2:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
*{
font-family: "Exo 2", sans-serif;
}
/************************************************/
/**************MARQUEE AREA and HEADER AREA******/
/************************************************/
.marquee-container{
display: flex;
align-items: center;
justify-content: end;
background: #0f1923;
overflow: hidden;
padding: 0.5em 2em;
width: 100vw;
}
.marquee-container .marquee {
display: flex;
align-items: center;
font-size: .75em;
font-family: sans-serif;
padding: 0.25em 0;
color: #fff;
white-space: nowrap;
animation: marquee 41.5s infinite linear;
font-weight: 500;
margin: 0px;
}
/* notice the infinite */
.marquee-container .marquee:after{
}
@keyframes marquee{
0% {
transform: translateX(0)
}
100% {
transform: translateX(40%)
}
}
/****************************HEADER AREA*******************************/
'
),
title = "Web Traffic Dashboard",
breakpoint_system = breakpoint_system,
style = 'padding:1em;background: #e7e7e9;',
# fill_page = FALSE,
# auto_fill = FALSE,
rows = list(
default = "auto auto auto auto auto auto ",
md = "auto auto auto auto auto auto auto ",
xs = "auto auto auto auto auto auto auto "
),
columns = list(
default = "1fr 1fr",
md = "1fr 1fr",
xs = "100px 200px 1fr 1fr 1fr"
),
areas = list(
default = c(
"marquee marquee",
"header header",
"sub_title sub_title",
"area-1 area-2",
"area-3 area-4",
"table table"),
md = c(
"marquee",
" header ",
" sub_title ",
" area-1",
" area-2",
" area-3",
"area-4",
"table")
),
gap = list(
default = "",
md = "10px"
),
div(
class = "marquee",
style = "
display: flex;
justify-content: space-between;
height: fit-content;",
div(class = "marquee-container",
div(class = "marquee",
style = "display: flex; align-items: center;",
lista_marquee,lista_marquee)
)),
div(
class = "header",
style = "background: #23292C; color: whitesmoke;
padding: 1em;
display: flex;
justify-content: space-between;
height: fit-content;
",
div(
h5('RecoveryWatch: Predictive Indicators for Economic Recovery')
),
tags$img(src = 'img/logo.png',class = 'company_logo', width = '114px', height = '24px')),
div(
class = "sub_title",
style = "background: #236192;color: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
height: fit-content;",
div(
h5('Business & Consumer Sentiment: Measures of sentiment among consumers and business')
),
dateRangeInput(
'dateRange',
label = '',
start = data$dates[1] ,
end = data$dates[12]
)),
div(
class = "area-1",
style = "background: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
height: fit-content;",
div(
class = 'charts',
style =' width: 100%;',
h5('Consumer Sentiment', style = ''),
p("4-6 month lead-time", style = ''),
highchartOutput(outputId = 'chart_top_left', height = 200),
p(class = 'source',"Source: Consumer Sentiment Data", style = 'margin: 0px;'))),
div(
class = "area-2",
style = "background: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
height: fit-content;",
div(
class = 'charts',
style =' width: 100%;',
h5('Economic Policy Uncertainty Index'),
p("6-9 month lead-time"),
highchartOutput(outputId = 'chart_top_right', height = 200),
p(class = 'source',"Source: Consumer Sentiment Data", style = 'margin: 0px;')
)),
div(
class = "area-3",
style = "background: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
height: fit-content;",
div(
class = 'charts',
style =' width: 100%;',
style = 'height: fit-content;',
h5('OECD Business Confidence Indicator'),
p("4-6 month lead-time"),
highchartOutput(outputId = 'chart_bottom_left', height = 200),
p(class = 'source',"Source: Consumer Sentiment Data", style = 'margin: 0px;')
)),
div(
class = "area-4",
style = "background: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
height: fit-content;",
div(
class = 'charts',
style =' width: 100%;',
h5('Small Business Optimism Index'),
p("3-5 month lead-time"),
highchartOutput(outputId = 'chart_bottom_right', height = 200),
p(class = 'source',"Source: Consumer Sentiment Data", style = 'margin: 0px;')
)),
div(
class = "table",
style = "background: whitesmoke;
padding: 1em; display: flex;justify-content: space-between;
",
div(
h5('Monthly Trends'),
p("showing results for Aug 2018 compared to Jul 2018"),
reactable::reactableOutput(outputId = 'table')
)),
hr(class = 'hr_chart', style = 'height: 2px'),
div(
class = 'table',
style = 'background: whitesmoke; display: flex; justify-content: space-between;',
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
div(
class = 'left_comment',
tags$ul(
class = 'list',
h4("MONTHLY TRENDS"),
tags$li(
class = 'list_1',
p(
"How have these indicators changed up or down in the past 5 months.",
style = "color: gray; font-size: .85em;"
)
),
tags$li(class = 'list_2'),
tags$li(class = 'list_3')
)
),
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
div(class = 'gt_table',
gt::gt_output('summary_table')),
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
div(class = 'icons_up_down',
))
)
server <- function(input, output, session) {
output$chart_top_left <- renderHighchart({
data %>% filter(dates >= input$dateRange[1] &
dates <= input$dateRange[2]) %>%
hchart("line",
options = list(highchart.json = TRUE),
name = 'Example',
color = 'green',
hcaes(x = year, y = round(life / 2, 0))) %>%
function_hc()
})
output$chart_top_right <- renderHighchart({
data %>% filter(dates >= input$dateRange[1] &
dates <= input$dateRange[2]) %>%
hchart("line",
name = 'Example',
color = 'red',
hcaes(x = year, y = round(life / 2, 0))) %>%
function_hc()
})
output$chart_bottom_left <- renderHighchart({
data %>% filter(dates >= input$dateRange[1] &
dates <= input$dateRange[2]) %>%
hchart("line",
name = 'Example',
color = 'blue',
hcaes(x = year, y = round(life / 2, 0))) %>%
function_hc()
})
output$chart_bottom_right <- renderHighchart({
data %>% filter(dates >= input$dateRange[1] &
dates <= input$dateRange[2]) %>%
hchart("line",
name = 'Example',
color = 'black',
hcaes(x = year, y = round(life / 2, 0))) %>%
function_hc()
})
output$summary_table <- render_gt({
gt(table_df) %>%
cols_label(indicators = "Indicators",
Relationship = "Relationship",
jan_20 = "Jan/20",
jul_22 = "Jul/22",
aug_22 = "Aug/22",
sep_22 = "Sep/22",
out_22 = "Out/22"
)%>%
tab_style(
locations = cells_column_labels(columns = everything()),
style = list(
#Give a thick border below
cell_borders(sides = "bottom", weight = px(3)),
cell_fill(color = 'lightgray'),
#Make text bold
cell_text(weight = "700",size = '12px')
)
) %>%
tab_style(
locations = cells_body(),
style = list(
#Give a thick border below
cell_fill(color = 'whitesmoke'),
#Make text bold
cell_text(weight = "700",size = '12px')
)
) %>%
data_color(columns = c(indicators),
colors = 'lightgray') %>%
tab_options(
#Remove border between column headers and title
column_labels.border.top.width = px(3),
column_labels.border.top.color = "transparent",
#Remove border around table
table.border.top.color = "transparent",
table.border.bottom.color = "transparent",
#Reduce the height of rows
data_row.padding = px(3),
#Adjust font sizes and alignment
source_notes.font.size = 12,
heading.align = "left",table.width = 850
) %>% tab_options(data_row.padding = px(1)) %>%
text_transform(
locations = cells_body(columns = jan_20:last_col()),
fn = function(x) {
local_image(
filename = c('www/img/down.png','www/img/up.png'),
height = 10
)
}
)
})
}
options(shiny.autoreload = TRUE)
shinyApp(ui = ui, server = server,
options = list(launch.browser = TRUE))