Empty event payload for plotly_selected when using ggplotly on geom_tile
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem reproduzierbaren Shiny-Beispiel aus inst/examples/shiny/event_data/app.R und vergleiche den ggplotly-Fall mit geom_tile mit den funktionierenden histogram- und plot_ly-Zweigen. Verfolge event_data("plotly_selected") und event_register("plotly_selected"); abgeschlossen ist die Aufgabe, wenn die Tile-Auswahl wie bei den anderen auswählbaren Plots eine nicht leere Payload zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100