better selection

This commit is contained in:
2023-10-17 18:44:36 +03:00
parent e1ec317e0e
commit dbdde37976

View File

@@ -21,12 +21,39 @@ for col in columns_to_summarize:
# Customize the layout # Customize the layout
fig.update_layout( fig.update_layout(
title="Summary of Categories by Place with Filtering", title="Summary of Categories by Place with Selection",
xaxis_title="Place", xaxis_title="Place",
yaxis_title="Total Count", yaxis_title="Total Count",
xaxis=dict(categoryorder='total descending'), xaxis=dict(categoryorder='total descending'),
barmode='group' barmode='group'
) )
# Enable selection by clicking
fig.update_traces(selector=dict(mode='lasso'))
# Enable searching for place names
fig.update_layout(updatemenus=[
{
'buttons': [
{
'args': [{'visible': [True] * len(grouped)}],
'label': 'Show All',
'method': 'restyle'
},
{
'args': [{'visible': [grouped["place"] == place for place in grouped["place"]]}],
'label': 'Select Place',
'method': 'restyle'
}
],
'direction': 'down',
'showactive': False,
'x': 0.1,
'xanchor': 'left',
'y': 1.1,
'yanchor': 'top'
}
])
# Show the interactive graph # Show the interactive graph
fig.show() fig.show()