Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/7882_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix `Plotly.Fx.hover` crash on `scattermap` traces when called programmatically with a `pointNumber` selection [[#7882](https://github.com/plotly/plotly.js/pull/7882)]
19 changes: 18 additions & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,24 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
if (_mode === 'array') {
var selection = evt[curvenum];
if ('pointNumber' in selection) {
pointData.index = selection.pointNumber;
// populate xval/yval from the targeted calcdata point so trace
// hoverPoints implementations that read them outside getClosest
// (e.g. scattermap's longitude winding) get valid coordinates
const cdi = cd[selection.pointNumber];
if (cdi) {
pointData.index = selection.pointNumber;
// map and geo traces store coords as lonlat: [lon, lat];
// everything else uses Cartesian .x/.y. This is good enough
// for now, but may need to be updated to a per trace accessor
// in the future.
if (cdi.lonlat) {
xval = cdi.lonlat[0];
yval = cdi.lonlat[1];
} else {
xval = cdi.x;
yval = cdi.y;
}
}
_mode = 'closest';
} else {
_mode = '';
Expand Down
Loading
Loading