Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2da23e

Browse files
committed
replace dragmode: 'pan' with annulus-shaped dragger
1 parent 473643c commit c2da23e

File tree

5 files changed

+167
-111
lines changed

5 files changed

+167
-111
lines changed

src/components/modebar/manage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,15 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
116116
var allAxesFixed = areAllAxesFixed(fullLayout),
117117
dragModeGroup = [];
118118

119-
if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary || hasPolar) {
119+
if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) {
120120
dragModeGroup = ['zoom2d', 'pan2d'];
121121
}
122122
if(hasMapbox || hasGeo) {
123123
dragModeGroup = ['pan2d'];
124124
}
125+
if(hasPolar) {
126+
dragModeGroup = ['zoom2d'];
127+
}
125128
if(isSelectable(fullData)) {
126129
dragModeGroup.push('select2d');
127130
dragModeGroup.push('lasso2d');

src/plots/cartesian/dragbox.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
109109

110110
recomputeAxisLists();
111111

112-
var dragger = makeDragger(plotinfo, ns + ew + 'drag', cursor, x, y, w, h);
112+
var dragger = makeRectDragger(plotinfo, ns + ew + 'drag', cursor, x, y, w, h);
113113

114114
// still need to make the element if the axes are disabled
115115
// but nuke its events (except for maindrag which needs them for hover)
@@ -781,21 +781,26 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
781781
return dragger;
782782
}
783783

784-
function makeDragger(plotinfo, dragClass, cursor, x, y, w, h) {
784+
function makeDragger(plotinfo, nodeName, dragClass, cursor) {
785785
var dragger3 = plotinfo.draglayer.selectAll('.' + dragClass).data([0]);
786786

787-
dragger3.enter().append('rect')
787+
dragger3.enter().append(nodeName)
788788
.classed('drag', true)
789789
.classed(dragClass, true)
790790
.style({fill: 'transparent', 'stroke-width': 0})
791791
.attr('data-subplot', plotinfo.id);
792792

793-
dragger3.call(Drawing.setRect, x, y, w, h)
794-
.call(setCursor, cursor);
793+
dragger3.call(setCursor, cursor);
795794

796795
return dragger3.node();
797796
}
798797

798+
function makeRectDragger(plotinfo, dragClass, cursor, x, y, w, h) {
799+
var dragger = makeDragger(plotinfo, 'rect', dragClass, cursor);
800+
d3.select(dragger).call(Drawing.setRect, x, y, w, h);
801+
return dragger;
802+
}
803+
799804
function isDirectionActive(axList, activeVal) {
800805
for(var i = 0; i < axList.length; i++) {
801806
if(!axList[i].fixedrange) return activeVal;
@@ -1044,6 +1049,7 @@ module.exports = {
10441049
makeDragBox: makeDragBox,
10451050

10461051
makeDragger: makeDragger,
1052+
makeRectDragger: makeRectDragger,
10471053
makeZoombox: makeZoombox,
10481054
makeCorners: makeCorners,
10491055

src/plots/polar/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
],
3030

3131
radialDragBoxSize: 50,
32+
angularDragBoxSize: 30,
3233
cornerLen: 25,
3334
cornerHalfWidth: 2,
3435

0 commit comments

Comments
 (0)