You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working in a Jupyter notebook and when accessing the selectedpoints attribute of a go.Histogram or the points list in the on_selection callback, the list does not contain integer indices of the selected points but instead just a list of objects.
When selecting points in the histogram, the output looks something like: [<object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>]
A call to figure_widget.data[0].selectedpoints returns the same list.
The expected output would be something like: [0, 12, 13, 26, 31, ..., 2534]
As you can see, all objects are identical (memory address 0x7ff062c497f0) and the objects in the list do not have any attributes. The length of the list corresponds to the number of bars selected if that helps.
I am working with plotly version 4.9.0, ipywidgets version 7.5.1 and notebook version 6.0.1.
UPDATE:
I checked how Plotly.js handles selection for histograms and found that it creates an object for each selected bar, which in turn contains all the points for that bar.
e.g.
So the problem seems to be that the points are not correctly serialised for histograms. Without understanding the whole codebase I think there seem to be two options:
Update the setter to _js2py_pointsCallback when the figure is a histogram in
Updating the model for the histogram on the Python side to reflect the behaviour of the JavaScript implementation. I don't know how exactly this would work yet.
Any pointers in the right direction are highly appreciated!
The text was updated successfully, but these errors were encountered:
meffmadd
changed the title
The selectedpoints attribute in histogram does not contain points
The selectedpoints attribute for Histogram plots is being set incorrectly
Aug 10, 2020
After some digging I found that buildPointsObject accesses the incorrect key. Normally all the points are in a field named pointNumber, however, the selection for the histogram contains pointNumbers which are lists corresponding to the selected bars instead of single values. Since the attribute pointNumber does not exist for Histograms it is undefined which is then passed in the message.
In order to resolve the issue I had to flatten the pointNumbers arrays to a single array to conform to the behaviour on the Python side since passing the nested point numbers caused issues with highlighting the selection.
I will shortly create a pull request for the issue.
I am working in a Jupyter notebook and when accessing the
selectedpoints
attribute of ago.Histogram
or the points list in theon_selection
callback, the list does not contain integer indices of the selected points but instead just a list of objects.When selecting points in the histogram, the output looks something like:
[<object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>, <object object at 0x7ff062c497f0>]
A call to
figure_widget.data[0].selectedpoints
returns the same list.The expected output would be something like:
[0, 12, 13, 26, 31, ..., 2534]
As you can see, all objects are identical (memory address
0x7ff062c497f0
) and the objects in the list do not have any attributes. The length of the list corresponds to the number of bars selected if that helps.I am working with plotly version
4.9.0
, ipywidgets version7.5.1
and notebook version6.0.1
.UPDATE:
I checked how Plotly.js handles selection for histograms and found that it creates an object for each selected bar, which in turn contains all the points for that bar.
e.g.
Codepen can be found here: https://codepen.io/meffmadd/pen/zYqGmaw
So the problem seems to be that the points are not correctly serialised for histograms. Without understanding the whole codebase I think there seem to be two options:
_js2py_pointsCallback
when the figure is a histogram inplotly.py/packages/javascript/plotlywidget/src/Figure.js
Line 1134 in efc6650
Any pointers in the right direction are highly appreciated!
The text was updated successfully, but these errors were encountered: