taipy
taipy copied to clipboard
Need to get several indexes when doing a box/ lasso selection from a plotly graph
Description When using the new feature to integrate plotly charts, we do get the index of the selected point on the chart. However, when performing a box or lasso selection, the selected_state is empty instead of returning a list of indexes corresponding to the selected points.
How to reproduce You can check using the following code below
- A code fragment
from taipy.gui import Gui import plotly.express as px df = px.data.gapminder() df_first = df[df['year']==2007].reset_index(drop=True) bubble_fig = px.scatter(df_first, x="gdpPercap", y="lifeExp",size="pop", hover_name="country", log_x=True, size_max=60) selected_state = [] def on_change(state,var,val): print("val = ", val) if var == 'selected_state': print(state.selected_state) print("selected state", val, "row:", state.df_first.iloc[val]) md = """ <|chart|figure={bubble_fig}|selected={selected_state}|> ``` Gui(md).run(port=4563)
Expected behavior selected_state variable shouldn't be empty, it should contain a list of indexes corresponding to the selected points.
Runtime environment Taipy develop branch Windows 11
Works for me
selected state [103, 104, 109]
row: country continent year lifeExp pop gdpPercap iso_alpha iso_num
103 Portugal Europe 2007 78.098 10642836 20509.64777 PRT 620
104 Puerto Rico Americas 2007 78.746 3942491 19328.70901 PRI 630
109 Saudi Arabia Asia 2007 72.777 27601038 21654.83194 SAU 682
What I see is that there are 2 events fired on box selection:
- the first one contains the list of indexes
- the second one is empty ...
Yes, not sure why we get 2 events here. This happens for both box and lasso selection.