Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dyEvent

dygraph event line


Description

Add a vertical event line to a dygraph

Usage

dyEvent(dygraph, x, label = NULL, labelLoc = c("top", "bottom"),
  color = "black", strokePattern = "dashed", date)

Arguments

dygraph

Dygraph to add event line to

x

Either numeric or date/time for the event, depending on the format of the x-axis of the dygraph. (For date/time must be a POSIXct object or another object convertible to POSIXct via as.POSIXct)

label

Label for event. Defaults to blank.

labelLoc

Location for label (top or bottom)

color

Color of event line. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". Defaults to black.

strokePattern

A predefined stroke pattern type ("dotted", "dashed", "dotdash", or "solid") or a custom pattern array where the even index is a draw and odd is a space in pixels. Defaults to dashed.

date

(deprecated) See argument x.

Value

A dygraph with the specified event line.

Note

See the online documentation for additional details and examples.

Examples

library(dygraphs)

dygraph(presidents, main = "Presidential Approval") %>%
  dyAxis("y", valueRange = c(0, 100)) %>%
  dyEvent("1950-6-30", "Korea", labelLoc = "bottom") %>%
  dyEvent("1965-2-09", "Vietnam", labelLoc = "bottom")
dygraph(presidents, main = "Presidential Approval") %>%
  dyAxis("y", valueRange = c(0, 100)) %>%
  dyEvent(c("1950-6-30", "1965-2-09"), c("Korea", "Vietnam"), labelLoc = "bottom")

dygraphs

Interface to 'Dygraphs' Interactive Time Series Charting Library

v1.1.1.6
MIT + file LICENSE
Authors
Dan Vanderkam [aut, cph] (dygraphs library in htmlwidgets/lib, http://dygraphs.com/), Petr Shevtsov [cre, cph], JJ Allaire [aut], RStudio [cph], Jonathan Owen [aut, cph], Daniel Gromer [aut, cph], Benoit Thieurmel [aut, cph], Kent Laukhuf [ctb], jQuery Foundation [cph] (jQuery library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/htmlwidgets/lib/jquery/AUTHORS.txt)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.