rstudio / crosstalk

Inter-htmlwidget communication for R (with and without Shiny)
http://rstudio.github.io/crosstalk
Other
288 stars 52 forks source link

Highlighting doesn't work when filtering on the same variable as the plot coloring #67

Open micahdh opened 5 years ago

micahdh commented 5 years ago

The problem occurs when you select a species from the dropdown and then lasso one graph -- the other graph doesn't change. When you only filter by other_factor (or don't filter at all) highlighting occurs as normal.

For what it's worth this issue occurs in my own script when I filter on any column -- regardless of if it's used for coloring or anything else. I only noticed that it matters which column you filter on while I was reproducing the problem.

Thank you for an otherwise amazing package!


require(crosstalk)
require(plotly)

iris$other_factor <- sample(x = c("a", "b", "c"), size = nrow(iris), replace = T)
iris_shared <- SharedData$new(iris)

bscols(widths = c(6, 6, 6, 6),
  filter_select("species", "species", iris_shared, ~Species, multiple = T),
  filter_select("otherfactor", "other factor", iris_shared, ~other_factor, multiple = T),

  plot_ly(data = iris_shared, x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species) %>%
    add_markers() %>%
    layout(dragmode = "lasso") %>%
    highlight(on = "plotly_selected", off = "plotly_deselect"),

  plot_ly(data = iris_shared, x = ~Petal.Length, y = ~Petal.Width, color = ~Species) %>%
    add_markers() %>%
    layout(dragmode = "lasso") %>%
    highlight(on = "plotly_selected", off = "plotly_deselect")
)
jcheng5 commented 5 years ago

cc @cpsievert

cpsievert commented 5 years ago

Thanks @micahdh, I think this is a plotly issue, so I opened https://github.com/ropensci/plotly/issues/1491.

Feel free to close here @jcheng5