plotly / plotly/plotly.R

Highlighting doesn't work after filtering on the same variable as the plot coloring

Open
#1,491 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

From @micahdh:

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")
)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the supplied R reproduction using iris, SharedData, filter_select(), plot_ly(), and highlight(). Compare lasso selection behavior after filtering by species or other_factor; done means selecting points in one graph updates the other graph regardless of which column was filtered.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.