From dbdde379765eecc1579052db731fd2e78b49f984 Mon Sep 17 00:00:00 2001 From: 1kamma Date: Tue, 17 Oct 2023 18:44:36 +0300 Subject: [PATCH] better selection --- ratios.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ratios.py b/ratios.py index 5911c44..a9e2691 100644 --- a/ratios.py +++ b/ratios.py @@ -21,12 +21,39 @@ for col in columns_to_summarize: # Customize the layout fig.update_layout( - title="Summary of Categories by Place with Filtering", + title="Summary of Categories by Place with Selection", xaxis_title="Place", yaxis_title="Total Count", xaxis=dict(categoryorder='total descending'), 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 fig.show()