From 15ab2819c7131761c0cb413eeb67922e9265d6de Mon Sep 17 00:00:00 2001 From: gnoblet Date: Wed, 6 Jul 2022 20:14:37 -0400 Subject: [PATCH] Add `reverse` arg to `hbar()` --- DESCRIPTION | 4 +- NEWS.md | 6 +++ R/hbar.R | 14 ++--- docs/404.html | 4 +- docs/LICENSE.html | 4 +- docs/authors.html | 4 +- docs/deps/bootstrap-5.1.0/bootstrap.min.css | 2 +- docs/index.html | 14 ++--- docs/news/index.html | 9 +++- docs/pkgdown.yml | 4 +- docs/reference/abort_bad_argument.html | 15 ++++-- docs/reference/buffer_bbox.html | 13 +++-- docs/reference/cols_agora.html | 13 +++-- docs/reference/cols_reach.html | 13 +++-- docs/reference/hbar.html | 60 +++++++++++++++------ docs/reference/hbar_percent.html | 60 +++++++++++++++------ docs/reference/if_not_in_stop.html | 17 ++++-- docs/reference/if_vec_not_in_stop.html | 17 ++++-- docs/reference/index.html | 4 +- docs/reference/pal_agora.html | 31 +++++++---- docs/reference/pal_reach.html | 31 +++++++---- docs/reference/scale_color.html | 31 +++++++---- docs/reference/scale_fill.html | 31 +++++++---- docs/reference/subvec_not_in.html | 13 +++-- docs/reference/theme_reach.html | 11 ++-- docs/reference/theme_reach_borders.html | 11 ++-- docs/reference/theme_reach_flip_hist.html | 11 ++-- docs/reference/theme_reach_hist.html | 11 ++-- docs/search.json | 2 +- man/hbar.Rd | 3 ++ man/hbar_percent.Rd | 3 ++ 31 files changed, 321 insertions(+), 145 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index de7e8be..a0f9e60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: visualizeR Type: Package Title: What a color! What a viz! -Version: 0.1.3.9000 +Version: 0.1.4.9000 Authors@R: c( person( 'Noblet', 'Guillaume', @@ -17,7 +17,7 @@ Depends: R (>= 4.1.0) License: GPL (>= 3) Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.0 Imports: ggplot2, rlang, grDevices, simplevis, glue, scales Suggests: knitr, sf VignetteBuilder: knitr diff --git a/NEWS.md b/NEWS.md index b0ebd89..0ab98e1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# visualizeR 0.1.4.9000 + +* `hbar()`gains a new boolean argument `reverse` to pass to `pal_reach()` or `pal_agora()`, indicating if the color palette should be reversed or not. + +--- + # visualizeR 0.1.3.9000 * Small change to `hbar()`: removes error arg within `simplevis::gg_hbar()` call. diff --git a/R/hbar.R b/R/hbar.R index 7496072..eddd99b 100644 --- a/R/hbar.R +++ b/R/hbar.R @@ -12,19 +12,20 @@ #' @param group_title The group legend title. Defaut to NULL #' @param font_family The font family. Default to "Leelawadee" #' @param stack Should the chart be stacked? Default to "FALSE" (dodge) +#' @param reverse Boolean indicating whether the color palette should be reversed #' @param ... Other arguments to be passed to "simplevis::gg_hbar" or "simplevis:gg_hbar_col" #' #' @return A horizontal bar chart #' #' @export -hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", stack = FALSE, ...){ +hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", stack = FALSE, reverse = FALSE, ...){ if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'")) - if (initiative == "reach") main_col <- cols_reach("main_grey") + if (initiative == "reach") main_col <- pal_reach("main", reverse = reverse) - if (initiative == "agora") main_col <- cols_agora("main_bordeaux") + if (initiative == "agora") main_col <- pal_agora("main", reverse = reverse) if (initiative == "impact") rlang::abort("IMPACT colors are under development") @@ -78,19 +79,20 @@ hbar_percent <- function(.tbl, x, y, group = NULL, initiative = "reach", x_title #' @param group_title The group legend title. Defaut to NULL #' @param font_family The font family. Default to "Leelawadee" #' @param stack Should the chart be stacked? Default to "FALSE" (dodge) +#' @param reverse Boolean indicating whether the color palette should be reversed #' @param ... Other arguments to be passed to "simplevis::gg_hbar" or "simplevis:gg_hbar_col" #' #' @return A horizontal bar chart #' #' @export -hbar <- function(.tbl, x, y, group = NULL, initiative = "reach", x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", stack = FALSE, ...){ +hbar <- function(.tbl, x, y, group = NULL, initiative = "reach", x_title = "", y_title = "", group_title = NULL, font_family = "Leelawadee", stack = FALSE, reverse = FALSE,...){ if (!(initiative %in% c("reach", "agora", "impact"))) rlang::abort(c("Wrong `initiative` arg", "*" = paste0("Arg `initiative` cannot be: ", initiative), "i" = "It must be one of 'reach' or 'agora' or 'impact'")) - if (initiative == "reach") main_col <- cols_reach("main_grey") + if (initiative == "reach") main_col <- pal_reach("main", reverse = reverse) - if (initiative == "agora") main_col <- cols_agora("main_bordeaux") + if (initiative == "agora") main_col <- pal_agora("main", reverse = reverse) if (initiative == "impact") rlang::abort("IMPACT colors are under development") diff --git a/docs/404.html b/docs/404.html index bc14e9a..a8762fd 100644 --- a/docs/404.html +++ b/docs/404.html @@ -31,7 +31,7 @@ visualizeR - 0.1.3.9000 + 0.1.4.9000