You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As per the bug report listed here, we were recently trying to implement interactive heatmaps in Shiny + Plotly, with coupled events such that selecting an area on the heatmap would populate a second plot. At first we tried to use the heatmaplypackage since it seemed suitable, however we were unable to retrieve event_data("plotly_selected") required for the coupled events.
The heatmaply devs helped narrow the issue down to Plotly itself. It appears that this event data is not available for these types of plots? Here is a working example of the issue, based on the Plotly docs:
library("shiny")
library("plotly")
library("ggplot2")
library("reshape2")
p <- volcano %>%
melt() %>%
ggplot(aes(Var1, Var2, fill = value)) + geom_tile()
p <- ggplotly(p)
# ~~~~~ UI ~~~~~ #
ui <- shinyUI(fluidPage(
verbatimTextOutput("heatmap_hover"),
verbatimTextOutput("heatmap_selected"),
verbatimTextOutput("eventdata"),
# Shiny
fixedRow(
column(6, plotlyOutput("volcano_plot", height = "400px"))
)
))
# ~~~~~ SERVER ~~~~~ #
server <- shinyServer(function(input, output,session) {
# Heatmap
output$volcano_plot <- renderPlotly({
p %>% layout(dragmode = "select")
})
output$heatmap_hover <- renderPrint({
d <- event_data("plotly_hover")
if (is.null(d)) "Hover on a point!" else d
})
output$heatmap_selected <- renderPrint({
# d <- event_data("plotly_selected")
# if (is.null(d)) "Select some points!" else d
event_data("plotly_selected")
})
output$eventdata <- renderPrint({
str(event_data())
})
})
shinyApp(ui = ui, server = server)
Output:
As you can see in the screenshot, event_data("plotly_selected") returns only an empty list().
As per the original issue in the heatmaply repo, we resorted to instead using geom_point, and manipulating it to appear like a heatmap. However this solution is very inelegant and seems to have its own bugs.
As per the bug report listed here, we were recently trying to implement interactive heatmaps in Shiny + Plotly, with coupled events such that selecting an area on the heatmap would populate a second plot. At first we tried to use the
heatmaply
package since it seemed suitable, however we were unable to retrieveevent_data("plotly_selected")
required for the coupled events.The
heatmaply
devs helped narrow the issue down to Plotly itself. It appears that this event data is not available for these types of plots? Here is a working example of the issue, based on the Plotly docs:Output:
As you can see in the screenshot,
event_data("plotly_selected")
returns only an emptylist()
.As per the original issue in the
heatmaply
repo, we resorted to instead usinggeom_point
, and manipulating it to appear like a heatmap. However this solution is very inelegant and seems to have its own bugs.software versions used:
The text was updated successfully, but these errors were encountered: