I am making a time series visualization using plotly
using monthly data. I want the user to be able to choose which months are shown and for this I use filter_slider
from crosstalk
. My data looks like this:
library(plotly)
library(crosstalk)
library(dplyr)
df <- data.frame(
value = runif(18, min = -1, max = 1),
time = rep(c('2021-05-01', '2021-06-01', '2021-07-01', '2021-08-01',
'2021-09-01', '2021-10-01'), 3) %>% as.Date(),
group = rep(c(1, 2, 3), each = 3) %>% factor()
)
sd <- highlight_key(df)
widgets <- bscols(
filter_slider('ti', 'Time', sd, ~time, timeFormat = '%y-%b')
)
plot <- plot_ly(
sd, x = ~time, y = ~value, mode = 'lines+markers',
type = 'scatter', color = ~group)
bscols(widgets, plot)
I have two issues
For your second question, adding the argument "step = 31" to filter_slider appears to work.