MCPcopy Index your code
hub / github.com/plotly/plotly.js / selectOnClick

Function selectOnClick

src/components/selections/select.js:495–572  ·  view source on GitHub ↗
(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutlines)

Source from the content-addressed store, hash-verified

493}
494
495function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutlines) {
496 var hoverData = gd._hoverdata;
497 var fullLayout = gd._fullLayout;
498 var clickmode = fullLayout.clickmode;
499 var sendEvents = clickmode.indexOf('event') > -1;
500 var selection = [];
501 var searchTraces, searchInfo, currentSelectionDef, selectionTesters, traceSelection;
502 var thisTracesSelection, pointOrBinSelected, subtract, eventData, i;
503
504 if(isHoverDataSet(hoverData)) {
505 coerceSelectionsCache(evt, gd, dragOptions);
506 searchTraces = determineSearchTraces(gd, xAxes, yAxes, subplot);
507 var clickedPtInfo = extractClickedPtInfo(hoverData, searchTraces);
508 var isBinnedTrace = clickedPtInfo.pointNumbers.length > 0;
509
510
511 // Note: potentially costly operation isPointOrBinSelected is
512 // called as late as possible through the use of an assignment
513 // in an if condition.
514 if(isBinnedTrace ?
515 isOnlyThisBinSelected(searchTraces, clickedPtInfo) :
516 isOnlyOnePointSelected(searchTraces) &&
517 (pointOrBinSelected = isPointOrBinSelected(clickedPtInfo))) {
518 if(polygonOutlines) polygonOutlines.remove();
519 for(i = 0; i < searchTraces.length; i++) {
520 searchInfo = searchTraces[i];
521 searchInfo._module.selectPoints(searchInfo, false);
522 }
523
524 updateSelectedState(gd, searchTraces);
525
526 clearSelectionsCache(dragOptions);
527
528 if(sendEvents) {
529 emitDeselect(gd);
530 }
531 } else {
532 subtract = evt.shiftKey &&
533 (pointOrBinSelected !== undefined ?
534 pointOrBinSelected :
535 isPointOrBinSelected(clickedPtInfo));
536 currentSelectionDef = newPointSelectionDef(clickedPtInfo.pointNumber, clickedPtInfo.searchInfo, subtract);
537
538 var allSelectionDefs = dragOptions.selectionDefs.concat([currentSelectionDef]);
539 selectionTesters = multiTester(allSelectionDefs, selectionTesters);
540
541 for(i = 0; i < searchTraces.length; i++) {
542 traceSelection = searchTraces[i]._module.selectPoints(searchTraces[i], selectionTesters);
543 thisTracesSelection = fillSelectionItem(traceSelection, searchTraces[i]);
544
545 if(selection.length) {
546 for(var j = 0; j < thisTracesSelection.length; j++) {
547 selection.push(thisTracesSelection[j]);
548 }
549 } else selection = thisTracesSelection;
550 }
551
552 eventData = {points: selection};

Callers 7

prepSelectFunction · 0.85
mapbox.jsFile · 0.85
clickFnFunction · 0.85
map.jsFile · 0.85
geo.jsFile · 0.85
clickZoomPanFunction · 0.85
zoomClickFunction · 0.85

Calls 15

isHoverDataSetFunction · 0.85
coerceSelectionsCacheFunction · 0.85
determineSearchTracesFunction · 0.85
extractClickedPtInfoFunction · 0.85
isOnlyThisBinSelectedFunction · 0.85
isOnlyOnePointSelectedFunction · 0.85
isPointOrBinSelectedFunction · 0.85
updateSelectedStateFunction · 0.85
clearSelectionsCacheFunction · 0.85
emitDeselectFunction · 0.85
newPointSelectionDefFunction · 0.85
multiTesterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…