python plotly dash treemap get selected child label
Solution 1:
You could use the dcc.Graph
's clickData
property in your callback
clickData (dict; optional): Data from latest click event. Read-only.
@app.callback(
dash.dependencies.Output("output", "children"),
dash.dependencies.Input("graph", "clickData"),
)
def update_other_figure(click_data):
print(click_data)
# Do something with the data...
On clicking Noam
in your example the value of click_data
is
{'points': [{'curveNumber': 0, 'pointNumber': 4, 'currentPath': 'Eve/Seth/', 'root': 'Eve', 'entry': 'Eve', 'percentRoot': 0.16666666666666666, 'percentEntry': 0.16666666666666666, 'percentParent': 0.5, 'parent': 'Seth', 'label': 'Noam'}]}
You could retrieve the value of label
from this and do something with it.