Key variable returned as length 1 character from event_data('plotly_click')
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
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)
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 le reprex R/Shiny fourni, en vous concentrant sur geom_tile() et event_data("plotly_click") dans l’observateur plotly_click. Suivez le transfert de la variable key pour les clics sur les tuiles et vérifiez le résultat par rapport à la chaîne complète attendue du nom de ligne, plutôt qu’à une valeur de caractères de longueur un.
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é
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100