plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

`on_selection` callback seems to not get fired

Open Ben-Epstein opened this issue 3 years ago • 2 comments

Thanks for your interest in Plotly.py!

Before opening an issue, please search for existing and closed issues :)

Please accompany bug reports with a reproducible example. Please use the latest version of plotly.py in your report unless not applicable.

Note that GitHub Issues are meant to be used for bug reports and feature requests only. Implementation or usage questions should be asked on community.plotly.com or on Stack Overflow (tagged plotly).

It seems the on_selection callback does not fire anymore. I've seen a number of open and closed issues back from 2020 discussing the usage of it, but based on the newest version 5.10.0 I cannot get anything to fire on a selection.

The simplest code example I could find (from https://github.com/plotly/plotly.py/issues/2698)


import plotly.graph_objects as go
import numpy as np

np.random.seed(1)
x = np.random.randn(500)

def on_selection_print(obj, points, selector):
    print(points.point_inds)

figure_widget = go.FigureWidget(data=[go.Histogram(x=x)])
figure_widget.update_layout(dragmode="select")    
figure_widget.data[0].on_selection(on_selection_print)
figure_widget.show()

Both running this in jupyter or as a python script, nothing seems to print.

I tried the latest docs on selection events but I couldn't actually get that example to run in jupyter or otherwise.

Am I just missing something simple?

Thanks!

Ben-Epstein avatar Oct 02 '22 16:10 Ben-Epstein

@Ben-Epstein Did you resolve this issue. I am getting the same problem

hkhanal avatar Mar 07 '24 15:03 hkhanal

@hkhanal it's still broken for me

Ben-Epstein avatar Mar 07 '24 15:03 Ben-Epstein