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

Function prepSelect

src/components/selections/select.js:58–493  ·  view source on GitHub ↗
(evt, startX, startY, dragOptions, mode)

Source from the content-addressed store, hash-verified

56}
57
58function prepSelect(evt, startX, startY, dragOptions, mode) {
59 var isCartesian = !hasSubplot(dragOptions);
60
61 var isFreeMode = freeMode(mode);
62 var isRectMode = rectMode(mode);
63 var isOpenMode = openMode(mode);
64 var isDrawMode = drawMode(mode);
65 var isSelectMode = selectMode(mode);
66
67 var isLine = mode === 'drawline';
68 var isEllipse = mode === 'drawcircle';
69 var isLineOrEllipse = isLine || isEllipse; // cases with two start & end positions
70
71 var gd = dragOptions.gd;
72 var fullLayout = gd._fullLayout;
73 var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
74 isCartesian; // N.B. only cartesian subplots have persistent selection
75
76 var zoomLayer = fullLayout._zoomlayer;
77 var dragBBox = dragOptions.element.getBoundingClientRect();
78 var plotinfo = dragOptions.plotinfo;
79 var transform = getTransform(plotinfo);
80 var x0 = startX - dragBBox.left;
81 var y0 = startY - dragBBox.top;
82
83 fullLayout._calcInverseTransform(gd);
84 var transformedCoords = Lib.apply3DTransform(fullLayout._invTransform)(x0, y0);
85 x0 = transformedCoords[0];
86 y0 = transformedCoords[1];
87 var scaleX = fullLayout._invScaleX;
88 var scaleY = fullLayout._invScaleY;
89
90 var x1 = x0;
91 var y1 = y0;
92 var path0 = 'M' + x0 + ',' + y0;
93 var xAxis = dragOptions.xaxes[0];
94 var yAxis = dragOptions.yaxes[0];
95 var pw = xAxis._length;
96 var ph = yAxis._length;
97
98 var subtract = evt.altKey &&
99 !(drawMode(mode) && isOpenMode);
100
101 var filterPoly, selectionTesters, mergedPolygons, currentPolygon;
102 var i, searchInfo, eventData;
103
104 coerceSelectionsCache(evt, gd, dragOptions);
105
106 if(isFreeMode) {
107 filterPoly = filteredPolygon([[x0, y0]], constants.BENDPX);
108 }
109
110 var outlines = zoomLayer.selectAll('path.select-outline-' + plotinfo.id).data([1]);
111 var newStyle = isDrawMode ?
112 fullLayout.newshape :
113 fullLayout.newselection;
114
115 if(isDrawMode) {

Callers 7

subplotUpdateFxFunction · 0.85
mapbox.jsFile · 0.85
makeDragBoxFunction · 0.85
map.jsFile · 0.85
geo.jsFile · 0.85
ternary.jsFile · 0.85
polar.jsFile · 0.85

Calls 15

hasSubplotFunction · 0.85
getTransformFunction · 0.85
coerceSelectionsCacheFunction · 0.85
determineSearchTracesFunction · 0.85
deselectSubplotFunction · 0.85
getFillRangeItemsFunction · 0.85
mergePolygonsFunction · 0.85
multiTesterFunction · 0.85
convertPolyFunction · 0.85
reselectFunction · 0.85
castMultiPolygonFunction · 0.85
_doSelectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…