plotly / plotly/plotly.R

selectize.js default behavior: remove label and allow for placeholder

Open
#2,240 0 comments 1 reaction 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

I would like to create an R Markdown document with > 1 plotly figure where points can be highlighted with the selectize.js widget. Here a reproducible example

---
title: Test
output: html_document
---

# wt vs mpg

```{r, message=FALSE, warning=FALSE}
library(plotly)
myData <- highlight_key(mtcars, ~rownames(mtcars))
myFig <- plot_ly(myData, x = ~wt, y = ~mpg) 
highlight(myFig, selectize = TRUE)
```

# disp vs mpg

```{r, message=FALSE}
myData <- highlight_key(mtcars, ~rownames(mtcars))
myFig <- plot_ly(myData, x = ~disp, y = ~mpg) 
highlight(myFig, selectize = TRUE)
```

selectize_label

Two Design improvements would be nice

  1. No label above selectize widget
  2. Placeholder text in the <input> field of the widget

For the first problem I found a workaround using highlight_key(..., group = " "). However I need to define for each plot a new "invisible" group identifier otherwise the highlighting of the plots will be linked (i.e. if I highlight a car in one plot it will be highlighted in all plots). At the moment I use group = " ", group = " ", group = " ", and so on but this is stupid.

A workaround for the placeholder text was already described on Stack Overflow. But it does not work out of the box if there are multiple plotly figures in one R Markdown document.

Optimal solution would be to have two additional arguments in the highlight() function

  • label = NULL makes sure that no label is plotted
  • placeholder = "" to define the placeholder in the selectize box.

Let me know what you think of it : )

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 with the R highlight() entry point and the selectize.js behavior exercised by the provided R Markdown reproduction. Verify how multiple plotly figures share selection state, then make label suppression and placeholder text configurable while keeping selections independent across figures.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, r
Domain
data-visualization, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.