Seeing the on_click support:
| defon_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` |
| """ |
| ifnotappend: |
| delself._click_callbacks[:] |
| ifcallback: |
| 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.
Seeing the
on_clicksupport:plotly.py/packages/python/plotly/plotly/basedatatypes.py
Lines 5190 to 5240 in 267c187
I am looking for similar
on_treemapclickandon_sunburstclicksupport referenced:plotly/plotly.js#4454
For something like:
on_clickin the above is not rendering, either.I have plotly version 4.5.0.