plotly / plotly/plotly.R

FR: Add support for plotly_sunburstclick and plotly_treemapclick in highlight()

Open
#2,176 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

As sunburst/treemap charts have their own click-events: plotly_sunburstclick / plotly_treemapclick it would be nice to support them in highlight.

The following (plotly_click) doesn't work as expected:

library(plotly)
library(crosstalk)

sunburstDF <- structure(list(labels = structure(c(1L, 3L, 4L, 2L, 7L, 6L, 5L, 
7L, 6L, 5L, 7L, 6L, 5L), levels = c("Total", "mixed", "private", 
"public", "commercial", "recreation", "residential"), class = "factor"), 
    values = c(1658, 353, 1120, 185, 108, 143, 102, 300, 320, 
    500, 37, 58, 90), parents = c(NA, "Total", "Total", "Total", 
    "Total - private", "Total - private", "Total - private", 
    "Total - public", "Total - public", "Total - public", "Total - mixed", 
    "Total - mixed", "Total - mixed"), ids = c("Total", "Total - private", 
    "Total - public", "Total - mixed", "Total - private - residential", 
    "Total - private - recreation", "Total - private - commercial", 
    "Total - public - residential", "Total - public - recreation", 
    "Total - public - commercial", "Total - mixed - residential", 
    "Total - mixed - recreation", "Total - mixed - commercial"
    )), row.names = c(NA, -13L), class = "data.frame")


d <- highlight_key(sunburstDF, ~ids)
fig <- plot_ly(data = d, ids = ~ids, labels= ~labels, parents = ~parents, values= ~values, type='sunburst', branchvalues = 'total')
fig1 <- fig2 <- highlight(fig, on = "plotly_click", off = "plotly_doubleclick", dynamic = FALSE)
crosstalk::bscols(fig1, fig2)

Related: allow plotly_unhover as an off event: https://github.com/plotly/plotly.R/issues/1864

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 by tracing how highlight() handles the plotly_click and plotly_doubleclick event names, then compare that behavior with the supplied sunburst and treemap example. Verify the crosstalk views respond to plotly_sunburstclick and plotly_treemapclick, while retaining the existing highlight behavior; the issue also identifies plotly_unhover as a related off-event request.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.