dygraphs for R

repository·master·Indexed 18 days ago

https://github.com/rstudio/dygraphs

An R interface to the dygraphs JavaScript charting library for creating interactive time-series visualizations. It supports xts-compatible objects and provides functions like dyAxis(), dyOptions(), and dyRangeSelector() for customization. Features include zoom/pan, series highlighting, shaded regions, and integration with R Markdown and Shiny.

Tokens
517
Snippets
3
Records
4
Agent score
13%

What's inside dygraphs

  1. Overview of dygraphs for R features

    master

    The dygraphs package is an R interface to the dygraphs JavaScript charting library, designed for rich time-series charting.

    Key Capabilities:

    • Data Support: Automatically plots xts time series objects (or any object convertible to xts).
    • Visual Customization: Highly configurable axes and series display, including optional second Y-axes and upper/lower bars (e.g., for prediction intervals).
    • Interactivity: Includes zoom/pan, series/point highlighting, and range selectors.
    • Overlays: Supports shaded regions, event lines, and point annotations.
    • Integration: Works at the R console (via RStudio Viewer), and embeds seamlessly in R Markdown and Shiny web applications.
  2. Install the dygraphs package

    master

    The dygraphs package depends on the development version of the htmlwidgets package. To install both, use the devtools package to install from GitHub.

    devtools::install_github(c("ramnathv/htmlwidgets", "rstudio/dygraphs"))
  3. Create a basic interactive time-series plot

    master

    If you have an xts-compatible time-series object, you can create an interactive plot using the dygraph() function. This provides an R interface to the dygraphs JavaScript charting library.

    dygraph(nhtemp, main = "New Haven Temperatures")
  4. Customize dygraphs plots with axes, options, and range selectors

    master

    You can extend a dygraph() call using pipes (%>%) to customize the visualization. Key functions include:

    • dyAxis(): Configure axis properties like labels and value ranges.
    • dyOptions(): Set graph display options such as fillGraph or drawGrid.
    • dyRangeSelector(): Add an interactive range selector for zooming/panning.
    dygraph(nhtemp, main = "New Haven Temperatures") %>%
      dyAxis("y", label = "Temp (F)", valueRange = c(40, 60)) %>%
      dyOptions(fillGraph = TRUE, drawGrid = FALSE) %>%
      dyRangeSelector()