@@ -366,14 +366,22 @@ describe('groupby', function() {
366
366
Plotly . plot ( gd , data ) . then ( function ( ) {
367
367
368
368
expect ( gd . data . length ) . toEqual ( 1 ) ;
369
+ expect ( gd . data [ 0 ] . ids ) . toEqual ( [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ) ;
369
370
expect ( gd . data [ 0 ] . x ) . toEqual ( [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ) ;
370
371
expect ( gd . data [ 0 ] . y ) . toEqual ( [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ) ;
372
+ expect ( gd . data [ 0 ] . marker . line . width ) . toEqual ( [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] ) ;
371
373
372
374
expect ( gd . _fullData . length ) . toEqual ( 2 ) ;
375
+
376
+ expect ( gd . _fullData [ 0 ] . ids ) . toEqual ( [ 'q' , 'w' , 't' , 'i' ] ) ;
373
377
expect ( gd . _fullData [ 0 ] . x ) . toEqual ( [ 1 , - 1 , 0 , 3 ] ) ;
374
378
expect ( gd . _fullData [ 0 ] . y ) . toEqual ( [ 0 , 1 , 3 , 6 ] ) ;
379
+ expect ( gd . _fullData [ 0 ] . marker . line . width ) . toEqual ( [ 4 , 2 , 2 , 3 ] ) ;
380
+
381
+ expect ( gd . _fullData [ 1 ] . ids ) . toEqual ( [ 'r' , 'y' , 'u' ] ) ;
375
382
expect ( gd . _fullData [ 1 ] . x ) . toEqual ( [ - 2 , 1 , 2 ] ) ;
376
383
expect ( gd . _fullData [ 1 ] . y ) . toEqual ( [ 2 , 5 , 4 ] ) ;
384
+ expect ( gd . _fullData [ 1 ] . marker . line . width ) . toEqual ( [ 4 , 2 , 3 ] ) ;
377
385
378
386
assertDims ( [ 4 , 3 ] ) ;
379
387
@@ -385,8 +393,10 @@ describe('groupby', function() {
385
393
// basic test
386
394
var mockData1 = [ {
387
395
mode : 'markers' ,
396
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
388
397
x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
389
398
y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
399
+ marker : { line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
390
400
transforms : [ {
391
401
type : 'groupby' ,
392
402
groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ] ,
@@ -397,8 +407,10 @@ describe('groupby', function() {
397
407
// heterogenously present attributes
398
408
var mockData2 = [ {
399
409
mode : 'markers' ,
410
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
400
411
x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
401
412
y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
413
+ marker : { line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
402
414
transforms : [ {
403
415
type : 'groupby' ,
404
416
groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ] ,
@@ -408,25 +420,22 @@ describe('groupby', function() {
408
420
color : 'orange' ,
409
421
size : 20 ,
410
422
line : {
411
- color : 'red' ,
412
- width : 1
423
+ color : 'red'
413
424
}
414
425
}
415
426
} ,
416
427
b : {
417
- mode : 'markers+lines' , // heterogeonos attributes are OK: group "a" doesn't need to define this
428
+ mode : 'markers+lines' , // heterogeonos attributes are OK: group 'a' doesn't need to define this
418
429
marker : {
419
430
color : 'cyan' ,
420
431
size : 15 ,
421
432
line : {
422
- color : 'purple' ,
423
- width : 4
433
+ color : 'purple'
424
434
} ,
425
435
opacity : 0.5 ,
426
436
symbol : 'triangle-up'
427
437
} ,
428
438
line : {
429
- width : 1 ,
430
439
color : 'purple'
431
440
}
432
441
}
@@ -437,12 +446,13 @@ describe('groupby', function() {
437
446
// attributes set at top level and partially overridden in the group item level
438
447
var mockData3 = [ {
439
448
mode : 'markers+lines' ,
449
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
440
450
x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
441
451
y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
442
452
marker : {
443
- color : 'darkred' , // general " default" color
453
+ color : 'darkred' , // general ' default' color
444
454
line : {
445
- width : 8 ,
455
+ width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] ,
446
456
// a general, not overridden array will be interpreted per group
447
457
color : [ 'orange' , 'red' , 'green' , 'cyan' ]
448
458
}
@@ -461,8 +471,10 @@ describe('groupby', function() {
461
471
462
472
var mockData4 = [ {
463
473
mode : 'markers+lines' ,
474
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
464
475
x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
465
476
y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
477
+ marker : { line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
466
478
transforms : [ {
467
479
type : 'groupby' ,
468
480
groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ] ,
@@ -472,20 +484,39 @@ describe('groupby', function() {
472
484
473
485
var mockData5 = [ {
474
486
mode : 'markers+lines' ,
487
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
475
488
x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
476
489
y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
490
+ marker : {
491
+ line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } ,
492
+ size : 10 ,
493
+ color : [ 'red' , '#eee' , 'lightgreen' , 'blue' , 'red' , '#eee' , 'lightgreen' ]
494
+ } ,
477
495
transforms : [ {
478
496
type : 'groupby' ,
479
497
groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ]
480
498
} ]
481
499
} ] ;
482
500
483
- // this passes OK as expected
501
+ var mockData6 = [ {
502
+ mode : 'markers+lines' ,
503
+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
504
+ x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
505
+ y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
506
+ marker : { line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
507
+ transforms : [ {
508
+ type : 'groupby' ,
509
+ groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ] ,
510
+ style : { a : { marker : { color : 'red' } } , b : { marker : { color : 'blue' } } }
511
+ } ]
512
+ } ] ;
513
+
484
514
it ( '`data` preserves user supplied input but `gd._fullData` reflects the grouping' , test ( mockData1 ) ) ;
485
515
it ( 'passes with lots of attributes and heterogenous attrib presence' , test ( mockData2 ) ) ;
486
516
it ( 'passes with group styles partially overriding top level aesthetics' , test ( mockData3 ) ) ;
487
517
it ( 'passes with no explicit styling for the individual group' , test ( mockData4 ) ) ;
488
518
it ( 'passes with no explicit styling in the group transform at all' , test ( mockData5 ) ) ;
519
+ it ( 'passes with no explicit styling in the group transform at all' , test ( mockData6 ) ) ;
489
520
490
521
} ) ;
491
522
0 commit comments