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

Function makeDragBox

src/plots/cartesian/dragbox.js:50–1039  ·  view source on GitHub ↗
(gd, plotinfo, x, y, w, h, ns, ew)

Source from the content-addressed store, hash-verified

48// 'ns' - top and bottom together, difference unchanged
49// ew - same for horizontal axis
50function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
51 // mouseDown stores ms of first mousedown event in the last
52 // `gd._context.doubleClickDelay` ms on the drag bars
53 // numClicks stores how many mousedowns have been seen
54 // within `gd._context.doubleClickDelay` so we can check for click or doubleclick events
55 // dragged stores whether a drag has occurred, so we don't have to
56 // redraw unnecessarily, ie if no move bigger than MINDRAG or MINZOOM px
57 var zoomlayer = gd._fullLayout._zoomlayer;
58 var isMainDrag = (ns + ew === 'nsew');
59 var singleEnd = (ns + ew).length === 1;
60
61 // main subplot x and y (i.e. found in plotinfo - the main ones)
62 var xa0, ya0;
63 // {ax._id: ax} hash objects
64 var xaHash, yaHash;
65 // xaHash/yaHash values (arrays)
66 var xaxes, yaxes;
67 // main axis offsets
68 var xs, ys;
69 // main axis lengths
70 var pw, ph;
71 // contains keys 'xaHash', 'yaHash', 'xaxes', and 'yaxes'
72 // which are the x/y {ax._id: ax} hash objects and their values
73 // for linked axis relative to this subplot
74 var links;
75 // similar to `links` but for matching axes
76 var matches;
77 // set to ew/ns val when active, set to '' when inactive
78 var xActive, yActive;
79 // are all axes in this subplot are fixed?
80 var allFixedRanges;
81 // do we need to edit x/y ranges?
82 var editX, editY;
83 // graph-wide optimization flags
84 var hasScatterGl, hasSplom, hasSVG;
85 // collected changes to be made to the plot by relayout at the end
86 var updates;
87 // scaling factors from css transform
88 var scaleX;
89 var scaleY;
90
91 // offset the x location of the box if needed
92 x += plotinfo.yaxis._shift;
93
94 function recomputeAxisLists() {
95 xa0 = plotinfo.xaxis;
96 ya0 = plotinfo.yaxis;
97 pw = xa0._length;
98 ph = ya0._length;
99 xs = xa0._offset;
100 ys = ya0._offset;
101
102 xaHash = {};
103 xaHash[xa0._id] = xa0;
104 yaHash = {};
105 yaHash[ya0._id] = ya0;
106
107 // if we're dragging two axes at once, also drag overlays

Callers 1

graph_interact.jsFile · 0.85

Calls 8

recomputeAxisListsFunction · 0.85
getDragCursorFunction · 0.85
makeRectDraggerFunction · 0.85
prepSelectFunction · 0.85
clearAndResetSelectFunction · 0.85
updateSubplotsFunction · 0.85
attachWheelEventHandlerFunction · 0.85
zoomPrepFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…