Skip to content

Commit

Permalink
feat: added demographics section
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliversinn committed Dec 31, 2023
1 parent 4742c2b commit 4bc3856
Show file tree
Hide file tree
Showing 8 changed files with 1,079 additions and 155 deletions.
416 changes: 416 additions & 0 deletions Dashboard/demographics.R

Large diffs are not rendered by default.

71 changes: 0 additions & 71 deletions Dashboard/explorer.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,74 +155,3 @@ aggregation_dt <- function(data, variable_name, download_name) {
)
return(data)
}

gender_pie <- function(data) {
data <- as.data.frame(data) %>%
dplyr::mutate(
key_color = case_when(
key == "female" ~ "#FF90C2",
key == "male" ~ "#1640D6",
key == "not reported" ~ "#A2AEBB",
key == "_missing" ~ "#071013"
)
)
fig <- plot_ly(
data,
labels = ~key,
values = ~doc_count,
type = "pie",
textposition = "inside",
textinfo = "value+percent",
texttemplate = "%{value}<br>%{percent:.1%}",
sort = FALSE,
height = 500,
marker = list(colors = ~key_color)
) %>%
layout(
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
legend = list(
orientation = "h", x = 0, y = 0.0,
bgcolor = "rgba(0,0,0,0)", font = list(size = 15)
)
) %>%
config(displaylogo = FALSE) %>%
layout(hovermode = "x")
return(fig)
}


vital_status_pie <- function(data) {
data <- as.data.frame(data) %>%
dplyr::mutate(
key_color = case_when(
key == "alive" ~ "#F9DC5C",
key == "dead" ~ "#ED254E",
key == "not reported" ~ "#A2AEBB",
key == "_missing" ~ "#071013"
)
)
fig <- plot_ly(
data,
labels = ~key,
values = ~doc_count,
type = "pie",
textposition = "inside",
textinfo = "value+percent",
texttemplate = "%{value}<br>%{percent:.1%}",
sort = FALSE,
height = 500,
marker = list(colors = ~key_color)
) %>%
layout(
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
legend = list(
orientation = "h", x = 0, y = 0.0,
bgcolor = "rgba(0,0,0,0)", font = list(size = 15)
)
) %>%
config(displaylogo = FALSE) %>%
layout(hovermode = "x")
return(fig)
}
1 change: 1 addition & 0 deletions Dashboard/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ options(shiny.fullstacktrace = TRUE)
source("explorer.R")
source("project.R")
source("diagnosis.R")
source("demographics.R")
Loading

0 comments on commit 4bc3856

Please sign in to comment.