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

dyRangeSelector

dygraph interactive range selection and zooming


Description

Add a range selector to the bottom of the chart that allows users to pan and zoom to various date ranges.

Usage

dyRangeSelector(dygraph, dateWindow = NULL, height = 40,
  fillColor = " #A7B1C4", strokeColor = "#808FAB", keepMouseZoom = TRUE,
  retainDateWindow = FALSE)

Arguments

dygraph

Dygraph to add range selector to

dateWindow

Initially zoom in on a section of the graph. Is a two element vector [earliest, latest], where earliest/latest objects convertible via as.POSIXct.

height

Height, in pixels, of the range selector widget.

fillColor

The range selector mini plot fill color. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". You can also specify "" to turn off fill.

strokeColor

The range selector mini plot stroke color. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". You can also specify "" to turn off stroke.

keepMouseZoom

Keep mouse zoom when adding a range selector

retainDateWindow

Whether to retain the user's current date window (zoom level) when updating an existing dygraph with new data and/or options.

Value

A dygraph that displays a range selector

Note

See the online documentation for additional details and examples.

Shiny applications can respond to changes in the dateWindow via a special date window shiny input value. For example, if the output id of a dygraph is 'series' then the current date window can be read from input$series_date_window as an array of two date values (from and to).

Examples

library(dygraphs)

dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyRangeSelector()   
 
dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))   
    
dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyRangeSelector(height = 20, strokeColor = "")

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.