I have been struggling with this for the last couple of hours aswell. Anyone found a solution?
Diving into the issue it seems to me to be due to the difference in pie plots structure compared to a scatter plot as an example, as on the scatter each series are plotted as a trace, whereas in the pie plot it is one collective trace.
Scatter trace example (figure[‘data’][0]):
{‘x’: [1, 2, 3, 4], ‘y’: [4, 1, 3, 5], ‘text’: [‘a’, ‘b’, ‘c’, ‘d’], ‘customdata’: [‘c.a’, ‘c.b’, ‘c.c’, ‘c.d’], ‘name’: ‘Trace 1’, ‘mode’: ‘markers’, ‘marker’: {‘size’: 12}, ‘visible’: True}
Pie Example (figure[‘data’][0]):
{‘hole’: 0.3, ‘labels’: [‘Oxygen’, ‘Hydrogen’, ‘Carbon_Dioxide’, ‘Nitrogen’], ‘values’: [4500, 2500, 1053, 500], ‘visible’: True, ‘type’: ‘pie’}
It would be super with some option to count each label-value pair as a trace or similar so this functionality is usable for Pie plots aswell
UPDATE: I have found a workaround to achieve similar functionality:
@app.callback(
Output('click-data', 'children'),
Input('basic-interactions', 'relayoutData'),
State('basic-interactions', 'figure')
)
def display_restyle_data(restyleData, figure):
#print(restyleData)
if restyleData and 'hiddenlabels' in restyleData.keys():
hidden_options = restyleData['hiddenlabels']
print(hidden_options)
return hidden_options