Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
bump version of echarts4r in DESC #14
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCoene committed Mar 13, 2020
1 parent 9d8d8e6 commit 8f18d90
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ Imports:
shinyMobile (>= 0.5.0),
countrycode
Suggests:
echarts4r (>= 0.3.0),
echarts4r (>= 0.3.0.9000),
echarts4r.maps,
testthat (>= 2.1.0),
covr
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
URL: https://github/JohnCoene/coronavirus
BugReports: https://github/JohnCoene/coronavirus/issues
Remotes:
Expand Down
69 changes: 69 additions & 0 deletions R/embeds_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,73 @@ get_query <- function(query, param){
}

return(p)
}

# legacy, depreacted keep for embeds
mod_map_echarts <- function(df, log){

dat <- df %>%
dplyr::filter(country %in% c("Mainland China", "Hong Kong", "Taiwan")) %>%
dplyr::left_join(chinese_provinces, by = "state") %>%
dplyr::arrange(desc(date)) %>%
dplyr::select(state, type, date, cases) %>%
dplyr::mutate(
cases = dplyr::case_when(
log ~ log1p(cases),
TRUE ~ cases
)
)

index <- length(unique(dat$date)) -1
titles <- unique(dat$date) %>%
rev() %>%
purrr::map(function(x){
list(text = format(x, "%d %B %H:00"))
})

bs <- list(
shadowColor = "rgba(0, 0, 0, 0.8)",
shadowBlur = 5,
shadowOffsetX = 3
)

dat %>%
tidyr::pivot_wider(
c(state, date),
names_from = type,
values_from = cases
) %>%
dplyr::arrange(desc(date), desc(confirmed)) %>%
dplyr::group_by(date) %>%
echarts4r::e_charts(state, timeline = TRUE, dispose = FALSE) %>%
echarts4r::e_bar(confirmed, name = "Confirmed", itemStyle = bs) %>%
echarts4r::e_bar(recovered, name = "Recovered", itemStyle = bs) %>%
echarts4r::e_bar(death, name = "Deaths") %>%
echarts4r::e_legend(
orient = "vertical",
right = 25,
top = 50
) %>%
echarts4r::e_tooltip(
trigger = "axis",
axisPointer = list(
type = "shadow"
)
) %>%
echarts4r::e_timeline_serie(
title = titles
) %>%
echarts4r::e_timeline_opts(
currentIndex = index,
playInterval = 600,
symbolSize = 4,
axis_type = "time",
label = list(
show = FALSE
),
checkpointStyle = list(
symbol = "diamond",
symbolSize = 20
)
)
}

0 comments on commit 8f18d90

Please sign in to comment.