Skip to content

on_sunburstclick, on_treemapclick #2571

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

Closed
thewtex opened this issue Jun 16, 2020 · 1 comment
Closed

on_sunburstclick, on_treemapclick #2571

thewtex opened this issue Jun 16, 2020 · 1 comment

Comments

@thewtex
Copy link

thewtex commented Jun 16, 2020

Seeing the on_click support:

def on_click(self, callback, append=False):
"""
Register function to be called when the user clicks on one or more
points in this trace.
Note: Callbacks will only be triggered when the trace belongs to a
instance of plotly.graph_objs.FigureWidget and it is displayed in an
ipywidget context. Callbacks will not be triggered on figures
that are displayed using plot/iplot.
Parameters
----------
callback
Callable function that accepts 3 arguments
- this trace
- plotly.callbacks.Points object
- plotly.callbacks.InputDeviceState object
append : bool
If False (the default), this callback replaces any previously
defined on_click callbacks for this trace. If True,
this callback is appended to the list of any previously defined
callbacks.
Returns
-------
None
Examples
--------
>>> import plotly.graph_objects as go
>>> from plotly.callbacks import Points, InputDeviceState
>>> points, state = Points(), InputDeviceState()
>>> def click_fn(trace, points, state):
... inds = points.point_inds
... # Do something
>>> trace = go.Scatter(x=[1, 2], y=[3, 0])
>>> trace.on_click(click_fn)
Note: The creation of the `points` and `state` objects is optional,
it's simply a convenience to help the text editor perform completion
on the arguments inside `click_fn`
"""
if not append:
del self._click_callbacks[:]
if callback:
self._click_callbacks.append(callback)

I am looking for similar on_treemapclick and on_sunburstclick support referenced:

plotly/plotly.js#4454

For something like:

import plotly.graph_objects as go

tm = go.Treemap(
    labels = ["Eve","Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
    parents = ["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"]
)
fig = go.FigureWidget(tm)

fig.show()
from ipywidgets import Output

out = Output()
def click_fn(trace, points, state):
    with out:
        print(trace, points, state)
tm.on_click(click_fn)

def treemapclick_fn(trace, data, state):
    with out:
        print(trace, data, state)
tm.on_treemapclick(treemapclick_fn)
out

on_click in the above is not rendering, either.

I have plotly version 4.5.0.

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

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

2 participants