I am trying to access plotly’s box select values with python through the panel.bind function, but for some reason, the selected_data param does not appear to be updating. Here is an example:
import pandas as pd
import plotly.express as px
import panel as pn
pn.extension('plotly')
data = pd.DataFrame([
('Monday', 7), ('Tuesday', 4), ('Wednesday', 9), ('Thursday', 4),
('Friday', 4), ('Saturday', 4), ('Sunay', 4)], columns=['Day', 'Orders']
)
fig = px.line(data, x="Day", y="Orders")
fig.update_traces(mode="lines+markers", marker=dict(size=10), line=dict(width=4))
fig.update_layout(dragmode='select')
def get_select_range(selected_data):
return selected_data
responsive = pn.pane.Plotly(fig, config={'responsive': True})
bound_fn = pn.bind(get_select_range, responsive.param.selected_data)
pn.Column('# A responsive plot',
responsive,
bound_fn,
sizing_mode='stretch_width')
If you replace the bind function with click data, everything works fine.
bound_fn = pn.bind(get_select_range, responsive.param.click_data)
Any ideas on what might be going on here? Thank you!