@@ -17,6 +17,79 @@ describe('Test hover and click interactions', function() {
17
17
if ( ! hasWebGLSupport ( 'gl2d_click_test' ) ) return ;
18
18
19
19
var mock = require ( '@mocks/gl2d_14.json' ) ;
20
+ var mock2 = require ( '@mocks/gl2d_pointcloud-basic.json' ) ;
21
+ var mock3 = {
22
+ 'data' : [
23
+ {
24
+ 'type' : 'contourgl' ,
25
+ 'z' : [
26
+ [
27
+ 10 ,
28
+ 10.625 ,
29
+ 12.5 ,
30
+ 15.625 ,
31
+ 20
32
+ ] ,
33
+ [
34
+ 5.625 ,
35
+ 6.25 ,
36
+ 8.125 ,
37
+ 11.25 ,
38
+ 15.625
39
+ ] ,
40
+ [
41
+ 2.5 ,
42
+ 3.125 ,
43
+ 5 ,
44
+ 8.125 ,
45
+ 12.5
46
+ ] ,
47
+ [
48
+ 0.625 ,
49
+ 1.25 ,
50
+ 3.125 ,
51
+ 6.25 ,
52
+ 10.625
53
+ ] ,
54
+ [
55
+ 0 ,
56
+ 0.625 ,
57
+ 2.5 ,
58
+ 5.625 ,
59
+ 10
60
+ ]
61
+ ] ,
62
+ 'colorscale' : 'Jet' ,
63
+ 'contours' : {
64
+ 'start' : 2 ,
65
+ 'end' : 10 ,
66
+ 'size' : 1
67
+ } ,
68
+ 'uid' : 'ad5624' ,
69
+ 'zmin' : 0 ,
70
+ 'zmax' : 20
71
+ }
72
+ ] ,
73
+ 'layout' : {
74
+ 'xaxis' : {
75
+ 'range' : [
76
+ 0 ,
77
+ 4
78
+ ] ,
79
+ 'autorange' : true
80
+ } ,
81
+ 'yaxis' : {
82
+ 'range' : [
83
+ 0 ,
84
+ 4
85
+ ] ,
86
+ 'autorange' : true
87
+ } ,
88
+ 'height' : 450 ,
89
+ 'width' : 1000 ,
90
+ 'autosize' : true
91
+ }
92
+ } ;
20
93
21
94
var mockCopy , gd ;
22
95
@@ -183,6 +256,91 @@ describe('Test hover and click interactions', function() {
183
256
184
257
} ) ;
185
258
259
+ describe ( 'hover event is fired for other gl2d plot types' , function ( ) {
260
+ var futureData ;
261
+
262
+ it ( 'pointcloud' , function ( done ) {
263
+
264
+ var modifiedMockCopy = Lib . extendDeep ( { } , mock2 ) ;
265
+
266
+ Plotly . plot ( gd , modifiedMockCopy . data , modifiedMockCopy . layout )
267
+
268
+ . then ( new Promise ( function ( ) {
269
+
270
+ gd . on ( 'plotly_hover' , function ( data ) {
271
+ futureData = data ;
272
+ } ) ;
273
+
274
+ hover ( 540 , 150 ) ;
275
+
276
+ window . setTimeout ( function ( ) {
277
+
278
+ expect ( futureData . points . length ) . toEqual ( 1 ) ;
279
+
280
+ var pt = futureData . points [ 0 ] ;
281
+
282
+ expect ( Object . keys ( pt ) ) . toEqual ( [
283
+ 'x' , 'y' , 'curveNumber' , 'pointNumber' , 'data' , 'fullData' , 'xaxis' , 'yaxis'
284
+ ] ) ;
285
+
286
+ expect ( pt . x ) . toEqual ( 4.5 ) ;
287
+ expect ( pt . y ) . toEqual ( 9 ) ;
288
+ expect ( pt . curveNumber ) . toEqual ( 2 ) ;
289
+ expect ( pt . pointNumber ) . toEqual ( 1 ) ;
290
+ expect ( pt . fullData . length ) . toEqual ( 3 ) ;
291
+ expect ( typeof pt . data . uid ) . toEqual ( 'string' ) ;
292
+ expect ( pt . xaxis . domain . length ) . toEqual ( 2 ) ;
293
+ expect ( pt . yaxis . domain . length ) . toEqual ( 2 ) ;
294
+
295
+ done ( ) ;
296
+ } , 350 ) ;
297
+ } ) ) ;
298
+
299
+
300
+ } ) ;
301
+
302
+ it ( 'heatmapgl' , function ( done ) {
303
+
304
+ var modifiedMockCopy = Lib . extendDeep ( { } , mock3 ) ;
305
+ modifiedMockCopy . data [ 0 ] . type = 'heatmapgl' ;
306
+
307
+ Plotly . plot ( gd , modifiedMockCopy . data , modifiedMockCopy . layout )
308
+
309
+ . then ( new Promise ( function ( ) {
310
+
311
+ gd . on ( 'plotly_hover' , function ( data ) {
312
+ futureData = data ;
313
+ } ) ;
314
+
315
+ hover ( 540 , 150 ) ;
316
+
317
+ window . setTimeout ( function ( ) {
318
+
319
+ expect ( futureData . points . length ) . toEqual ( 1 ) ;
320
+
321
+ var pt = futureData . points [ 0 ] ;
322
+
323
+ expect ( Object . keys ( pt ) ) . toEqual ( [
324
+ 'x' , 'y' , 'curveNumber' , 'pointNumber' , 'data' , 'fullData' , 'xaxis' , 'yaxis'
325
+ ] ) ;
326
+
327
+ expect ( pt . x ) . toEqual ( 2 ) ;
328
+ expect ( pt . y ) . toEqual ( 3 ) ;
329
+ expect ( pt . curveNumber ) . toEqual ( 0 ) ;
330
+ expect ( pt . pointNumber ) . toEqual ( [ 2 , 3 , 17 ] ) ;
331
+ expect ( pt . fullData . length ) . toEqual ( 1 ) ;
332
+ expect ( typeof pt . data . uid ) . toEqual ( 'string' ) ;
333
+ expect ( pt . xaxis . domain . length ) . toEqual ( 2 ) ;
334
+ expect ( pt . yaxis . domain . length ) . toEqual ( 2 ) ;
335
+
336
+ done ( ) ;
337
+ } , 350 ) ;
338
+ } ) ) ;
339
+
340
+
341
+ } ) ;
342
+ } ) ;
343
+
186
344
describe ( 'click event is fired on click' , function ( ) {
187
345
var futureData ;
188
346
0 commit comments