(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutlines)
| 493 | } |
| 494 | |
| 495 | function 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}; |
no test coverage detected
searching dependent graphs…