Empty event payload for plotly_selected when using ggplotly on geom_tile
Personne n'a encore pris cette issue.
- Langage dominant
- R
- Étoiles
- 2.7k
- Forks
- 641
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
In the example provided below, the heatmap is selectable on the x but the corresponding event payload is empty.
Expected: The selection should be part of the event payload. This works for other plots, e.g. see commented out histogram example in the provided code.
# Source https://rdrr.io/cran/plotly/src/inst/examples/shiny/event_data/app.R
library(plotly)
library(nycflights13)
library(shiny)
library(dplyr)
library(lubridate)
flights = flights %>% mutate(departure = make_datetime(year, month, day, hour, minute))
ui <- fluidPage(
radioButtons("plotType", "Plot Type:", choices = c("ggplotly", "plotly")),
plotlyOutput("plot"),
verbatimTextOutput("brushing"),
)
server <- function(input, output, session) {
output$plot <- renderPlotly({
p <- if (identical(input$plotType, "ggplotly")) {
## works and gives correct results
# ggplotly(ggplot(flights, aes(x = departure)) + geom_histogram())
## gives empty event data
ggplotly(ggplot(head(flights, 10000), aes(x = departure, carrier, fill=arr_time)) + geom_tile())
} else {
plot_ly(mtcars, x = ~mpg, y = ~wt, customdata = nothing)
}
p %>%
layout(dragmode = "select") %>%
# see https://webinars.cpsievert.me/20180220/#13
event_register("plotly_selected")
})
observeEvent(event_data("plotly_selected"), {
d <- event_data("plotly_selected")
print("caught event from here as well")
print(paste(str(d)))
})
}
shinyApp(ui, server)
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple Shiny reproductible de inst/examples/shiny/event_data/app.R et comparez le cas ggplotly avec geom_tile aux branches fonctionnelles histogram et plot_ly. Suivez event_data("plotly_selected") et event_register("plotly_selected") ; le travail est terminé lorsque la sélection de tiles renvoie une payload non vide, comme les autres graphiques sélectionnables.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- r
- Domaine
- data-visualization
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100