I’m trying to get the y-axis to scale when I click a range selector button. It’s an issue because if I look at one month’s worth of data it looks flat unless I manually change the y-axis. Here’s a repeatable example of what I’m trying to fix:
x <- data.frame(Date = seq(Sys.Date()-365, Sys.Date(), by = 1), Value = 366:1)
p <- plot_ly(x = x$Date, y = x$Value, type = 'scatter', mode = 'lines') %>%
layout(
xaxis = list(title = "", type = 'date', rangeselector = list(
buttons = list(
list(count = 30, label = "30 days", step = "day", stepmode = "backward")
, list(step = "all", label = 'All')
)
))
)
Yep, that seems to be the same issue. Unfortunately, my Javascript skills are a bit rusty, but I think my solution is easier to get to now. I’m trying to use this plot in a Shiny app, which gives me the ability to use whatever javascript I want in the app.
The Javascript solution mentioned in that forum is rather long and I’m not sure how I can apply it to my R Plotly. I imagine I could add some Javascript to the head of my Shiny app using the same logic and point it at the correct plot… if I knew Javascript a little better. Any ideas?