Closed
Description
Introduced in #1393. MRE of problem:
library(plotly)
library(shiny)
# cache computation of a correlation matrix
correlation <- round(cor(mtcars), 3)
ui <- fluidPage(
mainPanel(
plotlyOutput("heat")
),
verbatimTextOutput("selection")
)
server <- function(input, output, session) {
output$heat <- renderPlotly({
plot_ly() %>%
add_heatmap(
x = names(mtcars),
y = names(mtcars),
z = correlation
) %>%
layout(
xaxis = list(title = ""),
yaxis = list(title = "")
)
})
output$selection <- renderPrint({
s <- event_data("plotly_click")
if (length(s) == 0) {
"Click on a cell in the heatmap to display a scatterplot"
} else {
cat("You selected: \n\n")
as.list(s)
}
})
}
shinyApp(ui, server)