Open JacobBumgarner opened 1 year ago
After further experimentation, it appears that the required argument type is a matrix.
The following correction to the selected()
observer event fixes this.
# update the plot based on table
observeEvent(input$table_cell_clicked, {
selected_rows <- input$table_rows_selected - 1
selected_rows <- t(matrix(selected_rows))
plotly::plotlyProxyInvoke(
plotly::plotlyProxy("graph", session),
"restyle",
list(selectedpoints = selected_rows), # arg wants a row-major matrix
0 # this number represents the plot trace. No arg updates all traces
)
})
Regardless, this should probably be documented somewhere for future users.
Bug/Unexpected Behavior
When updating a scatter plot's
selectedpoints
in a Shiny server using"restyle"
on aplotlyProxy
, single value vectors don't update the graph. E.g., passingc(1)
toselectedpoints
won't update the graph.However, if we duplicate this value, e.g.,
c(1, 1)
and pass it toselectedpoints
, the1
point will be selected.Reproducible example: