fixed darkmode, 2nd yaxis example, NEWS

This commit is contained in:
pvictor 2020-04-04 19:11:10 +02:00
parent 79f04f26da
commit 1a6063e9fb
5 changed files with 108 additions and 21 deletions

16
NEWS.md
View File

@ -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
==================

View File

@ -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))
}

48
examples/ax_yaxis2.R Normal file
View File

@ -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
)
)

View File

@ -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
)
)
}

View File

@ -38,5 +38,4 @@ apex(
type = "line"
) \%>\%
set_tooltip_fixed()
}