rstudio / dygraphs

R interface to dygraphs
http://rstudio.github.io/dygraphs
Other
365 stars 194 forks source link

Reset/Unzoom does not work when labelsDiv argument is provided to dyLegend() #247

Open ghiggi opened 4 years ago

ghiggi commented 4 years ago

Here below a reproducible example showing that when 'labelsDiv' argument is provided to dyLegend(), dygraphs does not unzoom anymore when double-clicking the graphic or when pressing the"reset zoom" button.

library(zoo)
library(dygraphs)
library(xts)

# Simulate time series 
ts = zoo(rnorm(100), seq(as.Date("2010-01-01"), by="1 month", length.out=100))
# Div to hide the legend 
noLegendDiv='<div id="dygraphLabelsContainer" style="position:absolute:left:0px;top:0px; visibility:hidden; z-index:-1"></div>'
# Plot time series 
dy <- dygraph(ts, main = "")
dy <- dy %>%
  dyLegend(show = "never",
           labelsDiv = noLegendDiv) %>% 
  dyUnzoom()
dy