Skip to content

Instantly share code, notes, and snippets.

@namoshizun
Created September 26, 2018 06:38
Show Gist options
  • Save namoshizun/5f4dc919c942cf1d1c6fe6a8d0584017 to your computer and use it in GitHub Desktop.
Save namoshizun/5f4dc919c942cf1d1c6fe6a8d0584017 to your computer and use it in GitHub Desktop.
Use plotly's default source name to capture click event on heatmaply
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