From cefba791f7f42f11c37357d45c570434ee9ff47a Mon Sep 17 00:00:00 2001 From: pvictor Date: Fri, 23 Jul 2021 10:19:43 +0200 Subject: [PATCH] updated documentation (point and marker crosslink) --- R/annotations.R | 15 ++++++++++++--- examples/add_point.R | 11 ----------- man/add_event.Rd | 3 +++ man/add_event_marker.Rd | 5 ++++- man/add_point.Rd | 14 +++----------- man/label.Rd | 3 ++- vignettes/chart-options.Rmd | 2 +- vignettes/shiny-integration.Rmd | 6 +++--- 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/R/annotations.R b/R/annotations.R index 95ad572..213bc00 100644 --- a/R/annotations.R +++ b/R/annotations.R @@ -96,7 +96,8 @@ add_annotation <- function(ax, type_annotation = c("xaxis", "yaxis", "points"), #' @param cssClass A custom Css Class to give to the annotation label elements. #' @param padding Padding for the label: top, right, bottom, left. #' -#' @return A \code{list} that can be used in \code{\link{add_shade}}. +#' @return A \code{list} that can be used in \code{\link{add_shade}}, \code{\link{add_point}}, +#' \code{\link{add_event}}, \code{\link{add_event_marker}}. #' @export #' label <- function(text = NULL, @@ -271,6 +272,8 @@ add_shade_weekend <- function(ax, color = "#848484", opacity = 0.2, label = NULL #' #' @return An \code{apexcharts} \code{htmlwidget} object. #' @export +#' +#' @seealso \code{\link{add_event_marker}} to add a point. #' #' @example examples/add_event.R add_event <- function(ax, when, color = "#E41A1C", dash = 4, label = NULL, ...) { @@ -287,13 +290,17 @@ add_event <- function(ax, when, color = "#E41A1C", dash = 4, label = NULL, ...) } -#' Add an event marker to a chart +#' @title Add an event marker to a chart +#' +#' @description Add a point with a label based on a datetime. #' #' @param when Vector of position to place the event. #' @inheritParams add_point #' #' @return An \code{apexcharts} \code{htmlwidget} object. #' @export +#' +#' @seealso \code{\link{add_event}} to add a vertical line. #' #' @example examples/add_event_marker.R add_event_marker <- function(ax, when, y, @@ -397,6 +404,8 @@ add_vline <- function(ax, value, color = "#000", dash = 0, label = NULL, ...) { #' #' @return An \code{apexcharts} \code{htmlwidget} object. #' @export +#' +#' @seealso \code{\link{add_event_marker}} to add a point when x-axis is a datetime. #' #' @example examples/add_point.R add_point <- function(ax, x, y, @@ -411,7 +420,7 @@ add_point <- function(ax, x, y, ax = ax, type_annotation = "points", position = "front", - as_date = FALSE, + as_date = inherits(x, c("Date", "POSIXct")), x = x, y = y, marker = marker( size = size, diff --git a/examples/add_point.R b/examples/add_point.R index 11c477a..6978d38 100644 --- a/examples/add_point.R +++ b/examples/add_point.R @@ -39,14 +39,3 @@ apex( x = clusters$centers[, 1], y = clusters$centers[, 2] ) - - - - - - - - - - - diff --git a/man/add_event.Rd b/man/add_event.Rd index 641d529..231fd90 100644 --- a/man/add_event.Rd +++ b/man/add_event.Rd @@ -53,3 +53,6 @@ apex(consumption, aes(date, value, group = type), "spline") \%>\% add_shade(from = "2020-01-06", to = "2020-01-20")\%>\% add_event(when = c("2020-01-11", "2020-01-29")) } +\seealso{ +\code{\link{add_event_marker}} to add a point. +} diff --git a/man/add_event_marker.Rd b/man/add_event_marker.Rd index e37d2ff..30400ef 100644 --- a/man/add_event_marker.Rd +++ b/man/add_event_marker.Rd @@ -47,7 +47,7 @@ or see \code{\link{label}} for more controls.} An \code{apexcharts} \code{htmlwidget} object. } \description{ -Add an event marker to a chart +Add a point with a label based on a datetime. } \examples{ library(apexcharter) @@ -74,3 +74,6 @@ apex(consumption, aes(date, value, group = type), "spline") \%>\% color = "firebrick" ) } +\seealso{ +\code{\link{add_event}} to add a vertical line. +} diff --git a/man/add_point.Rd b/man/add_point.Rd index 068843c..bae63be 100644 --- a/man/add_point.Rd +++ b/man/add_point.Rd @@ -91,15 +91,7 @@ apex( x = clusters$centers[, 1], y = clusters$centers[, 2] ) - - - - - - - - - - - +} +\seealso{ +\code{\link{add_event_marker}} to add a point when x-axis is a datetime. } diff --git a/man/label.Rd b/man/label.Rd index 86f9850..9587718 100644 --- a/man/label.Rd +++ b/man/label.Rd @@ -51,7 +51,8 @@ label( \item{padding}{Padding for the label: top, right, bottom, left.} } \value{ -A \code{list} that can be used in \code{\link{add_shade}}. +A \code{list} that can be used in \code{\link{add_shade}}, \code{\link{add_point}}, +\code{\link{add_event}}, \code{\link{add_event_marker}}. } \description{ Label for annotations diff --git a/vignettes/chart-options.Rmd b/vignettes/chart-options.Rmd index 50c55f7..ca32a65 100644 --- a/vignettes/chart-options.Rmd +++ b/vignettes/chart-options.Rmd @@ -41,7 +41,7 @@ apex(data = diamonds, type = "column", mapping = aes(x = cut)) %>% ) ``` -If you more control (font size, alignment, ...), you can use `ax_title()`, `ax_subtitle()`, `ax_xaxis()` and `ax_yaxis()`, as described below. +If you want more control (font size, alignment, ...), you can use `ax_title()`, `ax_subtitle()`, `ax_xaxis()` and `ax_yaxis()`, as described below. diff --git a/vignettes/shiny-integration.Rmd b/vignettes/shiny-integration.Rmd index bc8f331..8316a2e 100644 --- a/vignettes/shiny-integration.Rmd +++ b/vignettes/shiny-integration.Rmd @@ -131,7 +131,7 @@ data.frame( More examples are available with: ```{r} -run_input_demo("click") +run_demo_input("click") ``` @@ -168,7 +168,7 @@ Here values for `y` are `NULL` because zoom is only possible on x-axis, but for More examples are available with: ```{r} -run_input_demo("zoom") +run_demo_input("zoom") ``` @@ -231,5 +231,5 @@ list( More examples are available with: ```{r} -run_input_demo("selection") +run_demo_input("selection") ```