Skip to content

Commit

Permalink
feat: add progress arg to polarMap() etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-davison-ricardo committed May 28, 2024
1 parent 1e7b95a commit 6c1c0b9
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 12 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Pairwise statistics (e.g., `"robust_slope"`) are now supported by `polarMap()`. (#72)

* The `polarMap()` family has gained the `progress` argument, allowing users to switch the progress bar on and off.

## Bug fixes

* Vectors greater than length 1 passed to `popup` in the `polarMap()` argument will no longer error when `type = NULL`.
Expand Down
6 changes: 4 additions & 2 deletions R/polar_annulusMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ annulusMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -116,7 +117,7 @@ annulusMap <- function(data,
}

# cut data
data <- openair::cutData(x = data, type = type, ...)
data <- openair::cutData(x = data, type = type %||% "default", ...)

# deal with popups
if (length(popup) > 1) {
Expand Down Expand Up @@ -195,7 +196,8 @@ annulusMap <- function(data,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down
9 changes: 6 additions & 3 deletions R/polar_diffMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ diffMap <- function(before,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -220,7 +221,8 @@ diffMap <- function(before,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down Expand Up @@ -323,7 +325,8 @@ create_polar_diffmarkers <-
popup = NULL,
label = NULL,
d.fig,
dropcol = "conc") {
dropcol = "conc",
progress = TRUE) {
# make temp directory
dir <- tempdir()

Expand Down Expand Up @@ -400,7 +403,7 @@ create_polar_diffmarkers <-
by = c(latitude, longitude, split_col)
) %>%
dplyr::mutate(
plot = purrr::map2(before, after, fun, .progress = "Creating Polar Markers"),
plot = purrr::map2(before, after, fun, .progress = ifelse(progress, "Creating Polar Markers", FALSE)),
url = paste0(dir, "/", .data[[latitude]], "_", .data[[longitude]], "_", .data[[split_col]], "_", id, ".png")
)

Expand Down
4 changes: 3 additions & 1 deletion R/polar_freqMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ freqMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -214,7 +215,8 @@ freqMap <- function(data,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down
4 changes: 3 additions & 1 deletion R/polar_percentileMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ percentileMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -187,7 +188,8 @@ percentileMap <- function(data,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down
12 changes: 11 additions & 1 deletion R/polar_polarMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@
#' [ggplot2::facet_wrap()]. The default, `NULL`, results in a roughly square
#' grid of panels.
#'
#' @param progress *Show a progress bar?*
#'
#' *default:* `TRUE` | *scope:* dynamic & static
#'
#' By default, a progress bar is shown to visualise the function's progress
#' creating individual polar markers. This option allows this to be turned
#' off, if desired.
#'
#' @param control **Deprecated.** Please use `type`.
#'
#' @inheritDotParams openair::polarPlot -mydata -pollutant -x -limits -type
Expand Down Expand Up @@ -317,6 +325,7 @@ polarMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# list pairwise statistics
Expand Down Expand Up @@ -473,7 +482,8 @@ polarMap <- function(data,
d.fig = d.fig,
popup = popup,
label = label,
dropcol = funpoll
dropcol = funpoll,
progress = progress
)

if (!static) {
Expand Down
4 changes: 3 additions & 1 deletion R/polar_pollroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pollroseMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -167,7 +168,8 @@ pollroseMap <- function(data,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down
4 changes: 3 additions & 1 deletion R/polar_windroseMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ windroseMap <- function(data,
d.fig = 3.5,
static = FALSE,
static.nrow = NULL,
progress = TRUE,
...,
control = NULL) {
# check basemap providers are valid
Expand Down Expand Up @@ -173,7 +174,8 @@ windroseMap <- function(data,
split_col = split_col,
d.fig = d.fig,
popup = popup,
label = label
label = label,
progress = progress
)

if (static) {
Expand Down
5 changes: 3 additions & 2 deletions R/utils-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ create_polar_markers <-
popup = NULL,
label = NULL,
d.fig,
dropcol = "conc") {
dropcol = "conc",
progress = TRUE) {
# make temp directory
dir <- tempdir()

Expand Down Expand Up @@ -468,7 +469,7 @@ create_polar_markers <-
plots_df <-
nested_df %>%
dplyr::mutate(
plot = purrr::map(data, fun, .progress = "Creating Polar Markers"),
plot = purrr::map(data, fun, .progress = ifelse(progress, "Creating Polar Markers", FALSE)),
url = paste0(
dir,
"/",
Expand Down
9 changes: 9 additions & 0 deletions man/annulusMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/diffMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/freqMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/percentileMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/polarMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/pollroseMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions man/windroseMap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c1c0b9

Please sign in to comment.