Key variable returned as length 1 character from event_data('plotly_click')
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Not sure if this is a bug or not, but I'm using plotly within a Shiny app. I'm using a geom_tile() heatmap type of graph and the user should be able to click a box which then triggers a follow-up database query. I followed the solution here: https://community.plot.ly/t/how-to-return-the-same-event-data-information-for-selected-points-even-after-modifying-the-data/5847/2
However, this doesn't seem to work for a geom_tile() click. I create a key variable by pasting the label and month of the clicked box together. The key is always returned as a length 1 character instead of returning the full string. Full reprex below:
library(plotly)
library(shiny)
mtcars$key <- row.names(mtcars)
mtcars$col <- "black"
mtcars$name <- row.names(mtcars)
ui <- fluidPage(
plotlyOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderPlotly({
p <- ggplot(mtcars, aes(x = gear, y = name, key = key)) +
geom_tile(aes(fill = mpg, key = key))
ggplotly(p)
})
observeEvent(event_data("plotly_click"), {
click_data <- event_data("plotly_click")
print(click_data)
})
}
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
Beginnen Sie mit dem bereitgestellten R/Shiny-reprex und konzentrieren Sie sich auf geom_tile() und event_data("plotly_click") im plotly_click-Beobachter. Verfolgen Sie, wie die Variable key für Tile-Klicks übertragen wird, und überprüfen Sie das Ergebnis anhand des erwarteten vollständigen Zeilennamen-Strings statt anhand eines Character-Werts der Länge eins.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100