plotly / plotly/plotly.R

highlight() function: setting the 'off' event to 'plotly_unhover' results in an error.

Open
#1,864 3 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

This is a modified example from here:

library(plotly)

# load the `txhousing` dataset
data(txhousing, package = "ggplot2")

# declare `city` as the SQL 'query by' column
tx <- highlight_key(txhousing, ~city)

# initiate a plotly object
base <- plot_ly(tx, color = I("black")) %>% 
  group_by(city)

# create a time series of median house price
time_series <- base %>%
  group_by(city) %>%
  add_lines(x = ~date, y = ~median)

highlight(
  time_series, 
  on = "plotly_hover",
  off = "plotly_hover", # causes error
  selectize = FALSE, 
  dynamic = FALSE,
  color = "red",
  persistent = FALSE
)

Not providing off results in a warning:

Setting the off event (i.e., 'plotly_doubleclick') to match the on event (i.e., 'plotly_hover'). You can change this default via the highlight() function.

Setting off to plotly_hover or plotly_unhover (my initial intention) results in an error:

Error in match.arg(off, off_options) :
'arg' should be one of “plotly_doubleclick”, “plotly_deselect”, “plotly_relayout”

Found this via: https://stackoverflow.com/a/64387370/9841389

PS: using the latest CRAN version of plotly.

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

Start at the highlight() entry point and reproduce the modified txhousing example with off set to plotly_hover and plotly_unhover. Inspect the off_options validation and compare it with the documented event behavior; done means valid off events no longer raise the reported match.arg error and the example behaves as intended.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.