add_event: Add an event to a chart

View source: R/annotations.R

add_eventR Documentation

Add an event to a chart

Description

Add a vertical line to mark a special event on a chart.

Usage

add_event(ax, when, color = "#E41A1C", dash = 4, label = NULL, ...)

Arguments

ax

An apexchart() htmlwidget object.

when

Vector of position to place the event.

color

Color of the line.

dash

Creates dashes in borders of SVG path. A higher number creates more space between dashes in the border. Use 0 for plain line.

label

Add a label to the shade, use a character or see label for more controls.

...

Additional arguments, see https://apexcharts.com/docs/options/annotations/ for possible options.

Value

An apexchart() htmlwidget object.

See Also

add_event_marker to add a point.

Examples

library(apexcharter)
data("consumption")

# specify from and to date
apex(consumption, aes(date, value, group = type), "spline") %>% 
  add_event(when = "2020-01-11")

# several events
apex(consumption, aes(date, value, group = type), "spline") %>% 
  add_event(when = c("2020-01-11", "2020-01-29"))

# Add labels on events
apex(consumption, aes(date, value, group = type), "spline") %>% 
  add_event(
    when = c("2020-01-11", "2020-01-29"),
    label = label(text = c("Am", "Ar"))
  )

# can be combined with shade
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"))

apexcharter documentation built on July 9, 2023, 7:55 p.m.