Created
September 26, 2018 06:38
-
-
Save namoshizun/5f4dc919c942cf1d1c6fe6a8d0584017 to your computer and use it in GitHub Desktop.
Use plotly's default source name to capture click event on heatmaply
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(heatmaply) | |
library(shiny) | |
library(plotly) | |
ui <- fluidPage( | |
titlePanel("Old Faithful Geyser Data"), | |
mainPanel( | |
plotlyOutput(outputId = 'heatmap') | |
) | |
) | |
# Define server logic required to draw a histogram | |
server <- function(input, output) { | |
output$heatmap <- renderPlotly({ | |
data <- rnorm(100) %>% matrix(., 10, 10) | |
heatmaply(data) | |
}) | |
observe({ | |
click_event <- event_data("plotly_click", source = "A") | |
print(click_event) | |
}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment