Skip to content

Commit 231fa6d

Browse files
committed
Consider first eventData element only as clicked point [1852]
- Reason: box trace type stuffing not even points but also hoverData about boxes which appears on mouseover into gd._hoverdata. - So based on analysis of fx/hover.js, which sorts the hoverdata array so that the closest point comes first, it is assumed now that only the first element in hoverData represents a clicked point. - For box trace type particulary if a box is clicked the first hoverdata element is not a point but a box with pointnumber being the index of the point group that's represented as a box plot element visually.
1 parent 4d8b274 commit 231fa6d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/plots/cartesian/select.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,15 @@ function selectOnClick(gd, numClicks, evt, xAxes, yAxes, outlines) {
397397

398398
function clickedPtsFor(searchInfo, hoverData) {
399399
var clickedPts = [];
400+
var hoverDatum;
400401

401-
for(var i = 0; i < hoverData.length; i++) {
402-
var hoverDatum = hoverData[i];
402+
if(hoverData.length > 0) {
403+
hoverDatum = hoverData[0];
403404
if(hoverDatum.fullData._expandedIndex === searchInfo.cd[0].trace._expandedIndex) {
405+
// TODO hoverDatum not having a pointNumber but a binNumber seems to be an oddity of histogram only
406+
// Not deleting .pointNumber in histogram/event_data.js would simplify code here and in addition
407+
// would not break the hover event structure officially
408+
// documented at https://plot.ly/javascript/hover-events/
404409
if(hoverDatum.pointNumber !== undefined) {
405410
clickedPts.push({
406411
pointNumber: hoverDatum.pointNumber

0 commit comments

Comments
 (0)