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

Skip to content

Commit b9513a2

Browse files
committed
fixup and 🔒 cliponaxis: false pan interactions
1 parent 2ed5879 commit b9513a2

File tree

2 files changed

+91
-2
lines changed

2 files changed

+91
-2
lines changed

src/components/drawing/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ drawing.hideOutsideRangePoint = function(d, sel, xa, ya, xcalendar, ycalendar) {
103103
drawing.hideOutsideRangePoints = function(traceGroups, subplot, selector) {
104104
if(!subplot._hasClipOnAxisFalse) return;
105105

106-
selector = selector || '.point,textpoint';
106+
selector = selector || '.point,.textpoint';
107107

108108
var xa = subplot.xaxis;
109109
var ya = subplot.yaxis;

test/jasmine/tests/cartesian_interact_test.js

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ var doubleClick = require('../assets/double_click');
1414
var getNodeCoords = require('../assets/get_node_coords');
1515
var delay = require('../assets/delay');
1616

17+
var customAssertions = require('../assets/custom_assertions');
18+
var assertNodeDisplay = customAssertions.assertNodeDisplay;
19+
1720
var MODEBAR_DELAY = 500;
1821

1922
describe('zoom box element', function() {
@@ -62,7 +65,6 @@ describe('zoom box element', function() {
6265

6366

6467
describe('main plot pan', function() {
65-
6668
var gd, modeBar, relayoutCallback;
6769

6870
beforeEach(function() {
@@ -183,6 +185,93 @@ describe('main plot pan', function() {
183185
.catch(failTest)
184186
.then(done);
185187
});
188+
189+
it('should show/hide `cliponaxis: false` pts according to range', function(done) {
190+
function _assert(markerDisplay, textDisplay, barTextDisplay) {
191+
var gd3 = d3.select(gd);
192+
193+
assertNodeDisplay(
194+
gd3.select('.scatterlayer').selectAll('.point'),
195+
markerDisplay,
196+
'marker pts'
197+
);
198+
assertNodeDisplay(
199+
gd3.select('.scatterlayer').selectAll('.textpoint'),
200+
textDisplay,
201+
'text pts'
202+
);
203+
assertNodeDisplay(
204+
gd3.select('.barlayer').selectAll('.bartext'),
205+
barTextDisplay,
206+
'bar text'
207+
);
208+
}
209+
210+
function _run(p0, p1, markerDisplay, textDisplay, barTextDisplay) {
211+
mouseEvent('mousedown', p0[0], p0[1]);
212+
mouseEvent('mousemove', p1[0], p1[1]);
213+
214+
_assert(markerDisplay, textDisplay, barTextDisplay);
215+
216+
mouseEvent('mouseup', p1[0], p1[1]);
217+
}
218+
219+
Plotly.newPlot(gd, [{
220+
mode: 'markers+text',
221+
x: [1, 2, 3],
222+
y: [1, 2, 3],
223+
text: ['a', 'b', 'c'],
224+
cliponaxis: false
225+
}, {
226+
type: 'bar',
227+
x: [1, 2, 3],
228+
y: [1, 2, 3],
229+
text: ['a', 'b', 'c'],
230+
textposition: 'outside',
231+
cliponaxis: false
232+
}], {
233+
xaxis: {range: [0, 4]},
234+
yaxis: {range: [0, 4]},
235+
width: 500,
236+
height: 500,
237+
dragmode: 'pan'
238+
})
239+
.then(function() {
240+
_assert(
241+
[null, null, null],
242+
[null, null, null],
243+
[null, null, null]
244+
);
245+
})
246+
.then(function() {
247+
_run(
248+
[250, 250], [250, 150],
249+
[null, null, 'none'],
250+
[null, null, 'none'],
251+
[null, null, 'none']
252+
);
253+
expect(gd._fullLayout.yaxis.range[1]).toBeLessThan(3);
254+
})
255+
.then(function() {
256+
_run(
257+
[250, 250], [150, 250],
258+
['none', null, 'none'],
259+
['none', null, 'none'],
260+
['none', null, 'none']
261+
);
262+
expect(gd._fullLayout.xaxis.range[0]).toBeGreaterThan(1);
263+
})
264+
.then(function() {
265+
_run(
266+
[250, 250], [350, 350],
267+
[null, null, null],
268+
[null, null, null],
269+
[null, null, null]
270+
);
271+
})
272+
.catch(failTest)
273+
.then(done);
274+
});
186275
});
187276

188277
describe('axis zoom/pan and main plot zoom', function() {

0 commit comments

Comments
 (0)