@@ -12,7 +12,6 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
12
12
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
13
13
var failTest = require ( '../assets/fail_test' ) ;
14
14
15
-
16
15
describe ( 'heatmap supplyDefaults' , function ( ) {
17
16
'use strict' ;
18
17
@@ -542,6 +541,83 @@ describe('heatmap calc', function() {
542
541
expect ( out . z [ 0 ] [ 0 ] ) . toEqual ( 0 ) ;
543
542
} ) ;
544
543
} ) ;
544
+
545
+ describe ( 'should clean z array linked to category x/y coordinates' , function ( ) {
546
+ var z = [
547
+ [ 1 , 20 , 30 , 50 , 1 ] ,
548
+ [ 20 , 1 , 60 , 80 , 30 ] ,
549
+ [ 30 , 60 , 1 , - 10 , 20 ]
550
+ ] ;
551
+
552
+ it ( '- base case' , function ( ) {
553
+ var out = _calc ( {
554
+ z : z ,
555
+ x : [ 'a' , 'b' , 'c' , 'd' , 'f' ] ,
556
+ y : [ 'A' , 'B' , 'C' ]
557
+ } ) ;
558
+ expect ( out . z ) . toBeCloseTo2DArray ( [
559
+ [ 1 , 20 , 30 , 50 , 1 ] ,
560
+ [ 20 , 1 , 60 , 80 , 30 ] ,
561
+ [ 30 , 60 , 1 , - 10 , 20 ]
562
+ ] ) ;
563
+ } ) ;
564
+
565
+ it ( '- with extra x items' , function ( ) {
566
+ var out = _calc ( {
567
+ z : z ,
568
+ x : [ 'a' , 'b' , 'c' , 'd' , 'f' , '' ] ,
569
+ y : [ 'A' , 'B' , 'C' ]
570
+ } ) ;
571
+ expect ( out . z ) . toBeCloseTo2DArray ( [
572
+ [ 1 , 20 , 30 , 50 , 1 , undefined ] ,
573
+ [ 20 , 1 , 60 , 80 , 30 , undefined ] ,
574
+ [ 30 , 60 , 1 , - 10 , 20 , undefined ]
575
+ ] ) ;
576
+ } ) ;
577
+
578
+ it ( '- with extra y items' , function ( ) {
579
+ var out = _calc ( {
580
+ z : z ,
581
+ x : [ 'a' , 'b' , 'c' , 'd' , 'f' ] ,
582
+ y : [ 'A' , 'B' , 'C' , '' ]
583
+ } ) ;
584
+ expect ( out . z ) . toBeCloseTo2DArray ( [
585
+ [ 1 , 20 , 30 , 50 , 1 ] ,
586
+ [ 20 , 1 , 60 , 80 , 30 ] ,
587
+ [ 30 , 60 , 1 , - 10 , 20 ] ,
588
+ new Array ( 5 )
589
+ ] ) ;
590
+ } ) ;
591
+
592
+ it ( '- with extra x and y items' , function ( ) {
593
+ var out = _calc ( {
594
+ z : z ,
595
+ x : [ 'a' , 'b' , 'c' , 'd' , 'f' , '' ] ,
596
+ y : [ 'A' , 'B' , 'C' , '' ]
597
+ } ) ;
598
+ expect ( out . z ) . toBeCloseTo2DArray ( [
599
+ [ 1 , 20 , 30 , 50 , 1 , undefined ] ,
600
+ [ 20 , 1 , 60 , 80 , 30 , undefined ] ,
601
+ [ 30 , 60 , 1 , - 10 , 20 , undefined ] ,
602
+ new Array ( 6 )
603
+ ] ) ;
604
+ } ) ;
605
+
606
+ it ( '- transposed, with extra x and y items' , function ( ) {
607
+ var out = _calc ( {
608
+ transpose : true ,
609
+ z : z ,
610
+ x : [ 'a' , 'b' , 'c' , 'd' , 'f' , '' ] ,
611
+ y : [ 'A' , 'B' , 'C' , '' ]
612
+ } ) ;
613
+ expect ( out . z ) . toBeCloseTo2DArray ( [
614
+ [ 1 , 20 , 30 , undefined , undefined , undefined ] ,
615
+ [ 20 , 1 , 60 , undefined , undefined , undefined ] ,
616
+ [ 30 , 60 , 1 , undefined , undefined , undefined ] ,
617
+ [ 50 , 80 , - 10 , undefined , undefined , undefined ]
618
+ ] ) ;
619
+ } ) ;
620
+ } ) ;
545
621
} ) ;
546
622
547
623
describe ( 'heatmap plot' , function ( ) {
0 commit comments