Skip to content

Commit 540994d

Browse files
author
Robert Paskowitz
committed
Allow disabling the drag handles
Also renamed the range entry option as per PR.
1 parent 5645787 commit 540994d

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

src/plot_api/plot_config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ module.exports = {
4848
// new users see some hints about interactivity
4949
showTips: true,
5050

51-
// enable/disable direct range entry at the pan/zoom drag points
52-
enableRangeEntry: true,
51+
// enable axis pan/zoom drag handles
52+
showAxisDragHandles: true,
53+
54+
// enable direct range entry at the pan/zoom drag points (drag handles must be enabled above)
55+
showAxisRangeEntryBoxes: true,
5356

5457
// link to open this plot in plotly
5558
showLink: false,

src/plots/cartesian/dragbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
353353
}
354354
else if(ew === 'e') hAlign = 'right';
355355

356-
if(gd._context.enableRangeEntry) {
356+
if(gd._context.showAxisRangeEntryBoxes) {
357357
dragger3
358358
.call(svgTextUtils.makeEditable, null, {
359359
immediate: true,

src/plots/cartesian/graph_interact.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,36 +153,39 @@ fx.init = function(gd) {
153153
};
154154

155155
// corner draggers
156-
dragBox(gd, plotinfo, -DRAGGERSIZE, -DRAGGERSIZE,
157-
DRAGGERSIZE, DRAGGERSIZE, 'n', 'w');
158-
dragBox(gd, plotinfo, xa._length, -DRAGGERSIZE,
159-
DRAGGERSIZE, DRAGGERSIZE, 'n', 'e');
160-
dragBox(gd, plotinfo, -DRAGGERSIZE, ya._length,
161-
DRAGGERSIZE, DRAGGERSIZE, 's', 'w');
162-
dragBox(gd, plotinfo, xa._length, ya._length,
163-
DRAGGERSIZE, DRAGGERSIZE, 's', 'e');
164-
}
165-
166-
// x axis draggers - if you have overlaid plots,
167-
// these drag each axis separately
168-
if(isNumeric(y0)) {
169-
if(xa.anchor === 'free') y0 -= fullLayout._size.h * (1 - ya.domain[1]);
170-
dragBox(gd, plotinfo, xa._length * 0.1, y0,
171-
xa._length * 0.8, DRAGGERSIZE, '', 'ew');
172-
dragBox(gd, plotinfo, 0, y0,
173-
xa._length * 0.1, DRAGGERSIZE, '', 'w');
174-
dragBox(gd, plotinfo, xa._length * 0.9, y0,
175-
xa._length * 0.1, DRAGGERSIZE, '', 'e');
156+
if(gd._context.showAxisDragHandles) {
157+
dragBox(gd, plotinfo, -DRAGGERSIZE, -DRAGGERSIZE,
158+
DRAGGERSIZE, DRAGGERSIZE, 'n', 'w');
159+
dragBox(gd, plotinfo, xa._length, -DRAGGERSIZE,
160+
DRAGGERSIZE, DRAGGERSIZE, 'n', 'e');
161+
dragBox(gd, plotinfo, -DRAGGERSIZE, ya._length,
162+
DRAGGERSIZE, DRAGGERSIZE, 's', 'w');
163+
dragBox(gd, plotinfo, xa._length, ya._length,
164+
DRAGGERSIZE, DRAGGERSIZE, 's', 'e');
165+
}
176166
}
177-
// y axis draggers
178-
if(isNumeric(x0)) {
179-
if(ya.anchor === 'free') x0 -= fullLayout._size.w * xa.domain[0];
180-
dragBox(gd, plotinfo, x0, ya._length * 0.1,
181-
DRAGGERSIZE, ya._length * 0.8, 'ns', '');
182-
dragBox(gd, plotinfo, x0, ya._length * 0.9,
183-
DRAGGERSIZE, ya._length * 0.1, 's', '');
184-
dragBox(gd, plotinfo, x0, 0,
185-
DRAGGERSIZE, ya._length * 0.1, 'n', '');
167+
if(gd._context.showAxisDragHandles) {
168+
// x axis draggers - if you have overlaid plots,
169+
// these drag each axis separately
170+
if(isNumeric(y0)) {
171+
if(xa.anchor === 'free') y0 -= fullLayout._size.h * (1 - ya.domain[1]);
172+
dragBox(gd, plotinfo, xa._length * 0.1, y0,
173+
xa._length * 0.8, DRAGGERSIZE, '', 'ew');
174+
dragBox(gd, plotinfo, 0, y0,
175+
xa._length * 0.1, DRAGGERSIZE, '', 'w');
176+
dragBox(gd, plotinfo, xa._length * 0.9, y0,
177+
xa._length * 0.1, DRAGGERSIZE, '', 'e');
178+
}
179+
// y axis draggers
180+
if(isNumeric(x0)) {
181+
if(ya.anchor === 'free') x0 -= fullLayout._size.w * xa.domain[0];
182+
dragBox(gd, plotinfo, x0, ya._length * 0.1,
183+
DRAGGERSIZE, ya._length * 0.8, 'ns', '');
184+
dragBox(gd, plotinfo, x0, ya._length * 0.9,
185+
DRAGGERSIZE, ya._length * 0.1, 's', '');
186+
dragBox(gd, plotinfo, x0, 0,
187+
DRAGGERSIZE, ya._length * 0.1, 'n', '');
188+
}
186189
}
187190
});
188191

0 commit comments

Comments
 (0)