Set default button in rangeselector
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Stumbled across this topic on SO and wasn't entirely satisfied with the suggested workaround. Is this something that you might want to have a look at?
Here's a minimum reprex: say I wanted to plot daily ozone readings from the airquality dataset against time and add range selectors,
library(plotly)
dat = airquality
dat$Date = as.Date(paste(1973, dat$Month, dat$Day, sep = "-"))
p0 = plot_ly(dat, x = ~ Date, y = ~ Ozone, type = "bar")
p1 = p0 %>% layout(
xaxis = list(
rangeselector = list(
buttons = list(
list(
count = 1
, label = "1 mo"
, step = "month"
, stepmode = "backward"
)
, list(step = "all")
)
)
)
)
p1

, then the default zoom level would always be set to full range. If I wanted the default range to cover the last month only, I could certainly circumvent that through specifying a custom range as suggested in the linked answer,
p1 %>% layout(
xaxis = list(
range = c(
{
dt = max(dat$Date)
lubridate::month(dt) = lubridate::month(dt) - 1
dt
}
, max(dat$Date)
)
)
)

, which works nicely for point, line, etc. charts. Bar charts (not sure about other types), on the other hand, are being cut off at the first and last position. Now, I could also circumvent that by adding something like paste(dt, "10:00:00") and paste(max(dat$Date), "10:00:00") to my custom range, but I wonder whether this could be made a lot more user-friendly through enabling something like active = TRUE directly in the buttons definition?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el reprex de airquality usando plot_ly(), layout(), xaxis y botones de rangeselector; después, compara la solución alternativa para el rango personalizado con el comportamiento solicitado del botón predeterminado. Sigue cómo se gestionan los botones de rangeselector y el rango de xaxis. Se considera terminado cuando un botón puede definir el rango inicial sin que los gráficos de barras queden recortados y el ejemplo existente siga funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100