Created
February 25, 2020 03:05
-
-
Save tcash21/f88b30809ba390b0591778f6d5812aa9 to your computer and use it in GitHub Desktop.
plotly_click + ggplot bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment