@@ -291,24 +291,19 @@ describe('calculated data and points', function() {
291
291
} ) ;
292
292
} ) ;
293
293
294
- describe ( 'ordering tests in the presence of multiple traces' , function ( ) {
294
+ describe ( 'ordering tests in the presence of multiple traces - mutually exclusive ' , function ( ) {
295
295
296
296
it ( 'baseline testing for the unordered, disjunct case' , function ( ) {
297
297
298
298
var x1 = [ 'Gear' , 'Bearing' , 'Motor' ] ;
299
299
var x2 = [ 'Switch' , 'Plug' , 'Cord' , 'Fuse' , 'Bulb' ] ;
300
300
var x3 = [ 'Pump' , 'Leak' , 'Seals' ] ;
301
301
302
- Plotly . plot ( gd , [ {
303
- x : x1 ,
304
- y : x1 . map ( function ( d , i ) { return i + 10 ; } )
305
- } , {
306
- x : x2 ,
307
- y : x2 . map ( function ( d , i ) { return i + 20 ; } )
308
- } , {
309
- x : x3 ,
310
- y : x3 . map ( function ( d , i ) { return i + 30 ; } )
311
- } ] ) ;
302
+ Plotly . plot ( gd , [
303
+ { x : x1 , y : x1 . map ( function ( d , i ) { return i + 10 ; } ) } ,
304
+ { x : x2 , y : x2 . map ( function ( d , i ) { return i + 20 ; } ) } ,
305
+ { x : x3 , y : x3 . map ( function ( d , i ) { return i + 30 ; } ) }
306
+ ] ) ;
312
307
313
308
expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 10 } ) ) ;
314
309
expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 11 } ) ) ;
@@ -325,6 +320,132 @@ describe('calculated data and points', function() {
325
320
expect ( gd . calcdata [ 2 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 10 , y : 32 } ) ) ;
326
321
} ) ;
327
322
323
+ it ( 'category order follows the trace order (even if categorylist is specified)' , function ( ) {
324
+
325
+ var x1 = [ 'Gear' , 'Bearing' , 'Motor' ] ;
326
+ var x2 = [ 'Switch' , 'Plug' , 'Cord' , 'Fuse' , 'Bulb' ] ;
327
+ var x3 = [ 'Pump' , 'Leak' , 'Seals' ] ;
328
+
329
+ Plotly . plot ( gd , [
330
+ { x : x1 , y : x1 . map ( function ( d , i ) { return i + 10 ; } ) } ,
331
+ { x : x2 , y : x2 . map ( function ( d , i ) { return i + 20 ; } ) } ,
332
+ { x : x3 , y : x3 . map ( function ( d , i ) { return i + 30 ; } ) }
333
+ ] , { xaxis : {
334
+ // type: 'category', // commented out to rely on autotyping for added realism
335
+ categorymode : 'trace' ,
336
+ categorylist : [ 'Switch' , 'Bearing' , 'Motor' , 'Seals' , 'Pump' , 'Cord' , 'Plug' , 'Bulb' , 'Fuse' , 'Gear' , 'Leak' ]
337
+ } } ) ;
338
+
339
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 10 } ) ) ;
340
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 11 } ) ) ;
341
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 12 } ) ) ;
342
+
343
+ expect ( gd . calcdata [ 1 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 20 } ) ) ;
344
+ expect ( gd . calcdata [ 1 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 21 } ) ) ;
345
+ expect ( gd . calcdata [ 1 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 22 } ) ) ;
346
+ expect ( gd . calcdata [ 1 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 23 } ) ) ;
347
+ expect ( gd . calcdata [ 1 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 7 , y : 24 } ) ) ;
348
+
349
+ expect ( gd . calcdata [ 2 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 8 , y : 30 } ) ) ;
350
+ expect ( gd . calcdata [ 2 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 9 , y : 31 } ) ) ;
351
+ expect ( gd . calcdata [ 2 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 10 , y : 32 } ) ) ;
352
+ } ) ;
353
+
354
+ it ( 'category order is category ascending (even if categorylist is specified)' , function ( ) {
355
+
356
+ var x1 = [ 'Gear' , 'Bearing' , 'Motor' ] ;
357
+ var x2 = [ 'Switch' , 'Plug' , 'Cord' , 'Fuse' , 'Bulb' ] ;
358
+ var x3 = [ 'Pump' , 'Leak' , 'Seals' ] ;
359
+
360
+ Plotly . plot ( gd , [
361
+ { x : x1 , y : x1 . map ( function ( d , i ) { return i + 10 ; } ) } ,
362
+ { x : x2 , y : x2 . map ( function ( d , i ) { return i + 20 ; } ) } ,
363
+ { x : x3 , y : x3 . map ( function ( d , i ) { return i + 30 ; } ) }
364
+ ] , { xaxis : {
365
+ // type: 'category', // commented out to rely on autotyping for added realism
366
+ categorymode : 'category ascending' ,
367
+ categorylist : [ 'Switch' , 'Bearing' , 'Motor' , 'Seals' , 'Pump' , 'Cord' , 'Plug' , 'Bulb' , 'Fuse' , 'Gear' , 'Leak' ]
368
+ // this is the expected sorted outcome: ['Bearing','Bulb','Cord','Fuse','Gear','Leak','Motor','Plug','Pump','Seals','Switch']
369
+ } } ) ;
370
+
371
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 10 } ) ) ;
372
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 11 } ) ) ;
373
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 12 } ) ) ;
374
+
375
+ expect ( gd . calcdata [ 1 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 10 , y : 20 } ) ) ;
376
+ expect ( gd . calcdata [ 1 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 7 , y : 21 } ) ) ;
377
+ expect ( gd . calcdata [ 1 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 22 } ) ) ;
378
+ expect ( gd . calcdata [ 1 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 23 } ) ) ;
379
+ expect ( gd . calcdata [ 1 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 24 } ) ) ;
380
+
381
+ expect ( gd . calcdata [ 2 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 8 , y : 30 } ) ) ;
382
+ expect ( gd . calcdata [ 2 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 31 } ) ) ;
383
+ expect ( gd . calcdata [ 2 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 9 , y : 32 } ) ) ;
384
+ } ) ;
385
+
386
+ it ( 'category order is category descending (even if categorylist is specified)' , function ( ) {
387
+
388
+ var x1 = [ 'Gear' , 'Bearing' , 'Motor' ] ;
389
+ var x2 = [ 'Switch' , 'Plug' , 'Cord' , 'Fuse' , 'Bulb' ] ;
390
+ var x3 = [ 'Pump' , 'Leak' , 'Seals' ] ;
391
+
392
+ Plotly . plot ( gd , [
393
+ { x : x1 , y : x1 . map ( function ( d , i ) { return i + 10 ; } ) } ,
394
+ { x : x2 , y : x2 . map ( function ( d , i ) { return i + 20 ; } ) } ,
395
+ { x : x3 , y : x3 . map ( function ( d , i ) { return i + 30 ; } ) }
396
+ ] , { xaxis : {
397
+ // type: 'category', // commented out to rely on autotyping for added realism
398
+ categorymode : 'category descending' ,
399
+ categorylist : [ 'Switch' , 'Bearing' , 'Motor' , 'Seals' , 'Pump' , 'Cord' , 'Plug' , 'Bulb' , 'Fuse' , 'Gear' , 'Leak' ]
400
+ // this is the expected sorted outcome: ["Switch", "Seals", "Pump", "Plug", "Motor", "Leak", "Gear", "Fuse", "Cord", "Bulb", "Bearing"]
401
+ } } ) ;
402
+
403
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 10 } ) ) ;
404
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 10 , y : 11 } ) ) ;
405
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 12 } ) ) ;
406
+
407
+ expect ( gd . calcdata [ 1 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 20 } ) ) ;
408
+ expect ( gd . calcdata [ 1 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 21 } ) ) ;
409
+ expect ( gd . calcdata [ 1 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 8 , y : 22 } ) ) ;
410
+ expect ( gd . calcdata [ 1 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 7 , y : 23 } ) ) ;
411
+ expect ( gd . calcdata [ 1 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 9 , y : 24 } ) ) ;
412
+
413
+ expect ( gd . calcdata [ 2 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 30 } ) ) ;
414
+ expect ( gd . calcdata [ 2 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 31 } ) ) ;
415
+ expect ( gd . calcdata [ 2 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 32 } ) ) ;
416
+ } ) ;
417
+
418
+ it ( 'category order follows categorylist' , function ( ) {
419
+
420
+ var x1 = [ 'Gear' , 'Bearing' , 'Motor' ] ;
421
+ var x2 = [ 'Switch' , 'Plug' , 'Cord' , 'Fuse' , 'Bulb' ] ;
422
+ var x3 = [ 'Pump' , 'Leak' , 'Seals' ] ;
423
+
424
+ Plotly . plot ( gd , [
425
+ { x : x1 , y : x1 . map ( function ( d , i ) { return i + 10 ; } ) } ,
426
+ { x : x2 , y : x2 . map ( function ( d , i ) { return i + 20 ; } ) } ,
427
+ { x : x3 , y : x3 . map ( function ( d , i ) { return i + 30 ; } ) }
428
+ ] , { xaxis : {
429
+ // type: 'category', // commented out to rely on autotyping for added realism
430
+ categorymode : 'array' ,
431
+ categorylist : [ 'Switch' , 'Bearing' , 'Motor' , 'Seals' , 'Pump' , 'Cord' , 'Plug' , 'Bulb' , 'Fuse' , 'Gear' , 'Leak' ]
432
+ } } ) ;
433
+
434
+ expect ( gd . calcdata [ 0 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 9 , y : 10 } ) ) ;
435
+ expect ( gd . calcdata [ 0 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 1 , y : 11 } ) ) ;
436
+ expect ( gd . calcdata [ 0 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 2 , y : 12 } ) ) ;
437
+
438
+ expect ( gd . calcdata [ 1 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 0 , y : 20 } ) ) ;
439
+ expect ( gd . calcdata [ 1 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 6 , y : 21 } ) ) ;
440
+ expect ( gd . calcdata [ 1 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 5 , y : 22 } ) ) ;
441
+ expect ( gd . calcdata [ 1 ] [ 3 ] ) . toEqual ( jasmine . objectContaining ( { x : 8 , y : 23 } ) ) ;
442
+ expect ( gd . calcdata [ 1 ] [ 4 ] ) . toEqual ( jasmine . objectContaining ( { x : 7 , y : 24 } ) ) ;
443
+
444
+ expect ( gd . calcdata [ 2 ] [ 0 ] ) . toEqual ( jasmine . objectContaining ( { x : 4 , y : 30 } ) ) ;
445
+ expect ( gd . calcdata [ 2 ] [ 1 ] ) . toEqual ( jasmine . objectContaining ( { x : 10 , y : 31 } ) ) ;
446
+ expect ( gd . calcdata [ 2 ] [ 2 ] ) . toEqual ( jasmine . objectContaining ( { x : 3 , y : 32 } ) ) ;
447
+ } ) ;
328
448
} ) ;
449
+
329
450
} ) ;
330
451
} ) ;
0 commit comments