Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ismirsehregal opened this issue Aug 25, 2022 · 0 comments

Comments

@ismirsehregal
Copy link

ismirsehregal commented Aug 25, 2022

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: #1864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant