@@ -14,6 +14,9 @@ var doubleClick = require('../assets/double_click');
14
14
var getNodeCoords = require ( '../assets/get_node_coords' ) ;
15
15
var delay = require ( '../assets/delay' ) ;
16
16
17
+ var customAssertions = require ( '../assets/custom_assertions' ) ;
18
+ var assertNodeDisplay = customAssertions . assertNodeDisplay ;
19
+
17
20
var MODEBAR_DELAY = 500 ;
18
21
19
22
describe ( 'zoom box element' , function ( ) {
@@ -62,7 +65,6 @@ describe('zoom box element', function() {
62
65
63
66
64
67
describe ( 'main plot pan' , function ( ) {
65
-
66
68
var gd , modeBar , relayoutCallback ;
67
69
68
70
beforeEach ( function ( ) {
@@ -183,6 +185,93 @@ describe('main plot pan', function() {
183
185
. catch ( failTest )
184
186
. then ( done ) ;
185
187
} ) ;
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
+ } ) ;
186
275
} ) ;
187
276
188
277
describe ( 'axis zoom/pan and main plot zoom' , function ( ) {
0 commit comments