Hello everyone,
Rangeslider feature disappears in R when you set any of the tracers into visible=FALSE mode. I am including an example below. If you remove the “visible=FALSE” argument from the add_trace everything works perfectly. Any hint on why this is happening?
Thanks in advance!
library(plotly)
library(quantmod)
getSymbols(Symbols = c(“AAPL”, “MSFT”))
ds ← data.frame(Date = index(AAPL), AAPL[,6], MSFT[,6])
plot_ly(ds, x = ~Date, y = ~AAPL.Adjusted, mode = “lines”, type=“scatter”, name = “Apple”) %>%
add_trace(x = ~Date, y = ~MSFT.Adjusted, mode = “lines”, type=“scatter”, name = “Microsoft”, visible=F) %>%
layout(
title = “Stock Prices”,
xaxis = list(
rangeselector = list(
buttons = list(
list(
count = 3,
label = “3 mo”,
step = “month”,
stepmode = “backward”),
list(
count = 6,
label = “6 mo”,
step = “month”,
stepmode = “backward”),
list(
count = 1,
label = “1 yr”,
step = “year”,
stepmode = “backward”),
list(
count = 1,
label = “YTD”,
step = “year”,
stepmode = “todate”),
list(step = “all”))),rangeslider = list(type = "date")), yaxis = list(title = "Price"))