From 1a6063e9fb91c36676e9dd39a3c3e913b929a36b Mon Sep 17 00:00:00 2001 From: pvictor Date: Sat, 4 Apr 2020 19:11:10 +0200 Subject: [PATCH] fixed darkmode, 2nd yaxis example, NEWS --- NEWS.md | 16 ++++++++++++++ R/apex-utils.R | 16 ++------------ examples/ax_yaxis2.R | 48 ++++++++++++++++++++++++++++++++++++++++ man/ax_yaxis2.Rd | 48 +++++++++++++++++++++++++++++++++++----- man/set_tooltip_fixed.Rd | 1 - 5 files changed, 108 insertions(+), 21 deletions(-) create mode 100644 examples/ax_yaxis2.R diff --git a/NEWS.md b/NEWS.md index 8f46cc0..65a4323 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,19 @@ +apexcharter 0.1.5 +================== + +## New functions + +* `add_shade()`, `add_shade_weekend()`, `add_event()` to add annotations on timeries charts. +* `add_hline()`, `add_vline()`, `add_point()` to add annotations on charts. +* `set_tooltip_fixed()` to fix tooltip in specific position. + +## Bugfixes + +* Dark mode wasn't activated properly in `ax_theme()`. + + + + apexcharter 0.1.4 ================== diff --git a/R/apex-utils.R b/R/apex-utils.R index cec565b..0ec2736 100644 --- a/R/apex-utils.R +++ b/R/apex-utils.R @@ -1157,19 +1157,7 @@ ax_yaxis <- function(ax, #' @return A \code{apexcharts} \code{htmlwidget} object. #' @export #' -#' @examples -#' -#' library(dplyr) -#' data("economics_long", package = "ggplot2") -#' -#' eco <- economics_long %>% -#' filter(variable %in% c("pce", "pop")) %>% -#' filter(date >= "2000-01-01") -#' -#' apex(eco, aes(x = date, y = value, color = variable), type = "line") %>% -#' ax_yaxis(title = list(text = "Pce")) %>% -#' ax_yaxis2(opposite = TRUE, title = list(text = "Pop")) -#' +#' @example examples/ax_yaxis2.R ax_yaxis2 <- function(ax, ...) { params <- dropNulls(list(...)) yaxis <- .get_ax_opt(ax, "yaxis") @@ -1234,6 +1222,6 @@ ax_theme <- function(ax, mode = mode, palette = palette, monochrome = monochrome - ), list(...))[-1] + ), list(...)) .ax_opt2(ax, "theme", l = dropNulls(params)) } diff --git a/examples/ax_yaxis2.R b/examples/ax_yaxis2.R new file mode 100644 index 0000000..7999bce --- /dev/null +++ b/examples/ax_yaxis2.R @@ -0,0 +1,48 @@ +library(apexcharter) +library(dplyr) +data("economics_long", package = "ggplot2") + +eco <- economics_long %>% + filter(variable %in% c("pce", "pop")) %>% + mutate(value = round(value)) + +# add second y-axis +apex(eco, aes(x = date, y = value, color = variable), type = "line") %>% + ax_yaxis(title = list(text = "Pce")) %>% + ax_yaxis2(opposite = TRUE, title = list(text = "Pop")) + +# Customize axis a bit more +apex(eco, aes(x = date, y = value, color = variable), type = "line") %>% + ax_yaxis( + title = list(text = "Pce"), + axisBorder = list( + show = TRUE, + color = "#008FFB" + ), + labels = list( + style = list( + colors = "#008FFB" + ) + ), + tooltip = list( + enabled = TRUE + ) + ) %>% + ax_yaxis2( + opposite = TRUE, + min = 160000, + forceNiceScale = TRUE, + title = list(text = "Pop"), + axisBorder = list( + show = TRUE, + color = "#00E396" + ), + labels = list( + style = list( + colors = "#00E396" + ) + ), + tooltip = list( + enabled = TRUE + ) + ) diff --git a/man/ax_yaxis2.Rd b/man/ax_yaxis2.Rd index 71eff85..2370650 100644 --- a/man/ax_yaxis2.Rd +++ b/man/ax_yaxis2.Rd @@ -18,16 +18,52 @@ A \code{apexcharts} \code{htmlwidget} object. Secondary Y-axis options } \examples{ - +library(apexcharter) library(dplyr) data("economics_long", package = "ggplot2") -eco <- economics_long \%>\% +eco <- economics_long \%>\% filter(variable \%in\% c("pce", "pop")) \%>\% - filter(date >= "2000-01-01") + mutate(value = round(value)) -apex(eco, aes(x = date, y = value, color = variable), type = "line") \%>\% - ax_yaxis(title = list(text = "Pce")) \%>\% +# add second y-axis +apex(eco, aes(x = date, y = value, color = variable), type = "line") \%>\% + ax_yaxis(title = list(text = "Pce")) \%>\% ax_yaxis2(opposite = TRUE, title = list(text = "Pop")) - + +# Customize axis a bit more +apex(eco, aes(x = date, y = value, color = variable), type = "line") \%>\% + ax_yaxis( + title = list(text = "Pce"), + axisBorder = list( + show = TRUE, + color = "#008FFB" + ), + labels = list( + style = list( + colors = "#008FFB" + ) + ), + tooltip = list( + enabled = TRUE + ) + ) \%>\% + ax_yaxis2( + opposite = TRUE, + min = 160000, + forceNiceScale = TRUE, + title = list(text = "Pop"), + axisBorder = list( + show = TRUE, + color = "#00E396" + ), + labels = list( + style = list( + colors = "#00E396" + ) + ), + tooltip = list( + enabled = TRUE + ) + ) } diff --git a/man/set_tooltip_fixed.Rd b/man/set_tooltip_fixed.Rd index 4cea94b..9355466 100644 --- a/man/set_tooltip_fixed.Rd +++ b/man/set_tooltip_fixed.Rd @@ -38,5 +38,4 @@ apex( type = "line" ) \%>\% set_tooltip_fixed() - }