'capture user click in a variable from a plotly express sunburst chart
I am using the below code to generate a pie chart.
How does one capture name = "female" that appears when you click over a sector into a variable. ?
import plotly.express as px
df = px.data.tips()
fig = px.sunburst(df, path=['day', 'sex'], values='total_bill')
fig.show()
From what I have found so far there is a on_click callback. For testing when I do a print statement, it does not show any thing. I need to open a explorer path based on what user clicks. What's the possible way to do so ?
import plotly.graph_objects as go
import numpy as np
np.random.seed(1)
x = np.random.rand(100)
y = np.random.rand(100)
f = go.FigureWidget([go.Scatter(x=x, y=y, mode='markers')])
scatter = f.data[0]
# create our callback function
def update_point(trace, points, selector):
print(trace, points, selector)
subprocess.Popen(['explorer', 'path_build_after_user_clicks_on_a_sector'])
scatter.on_click(update_point)
f
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
