@@ -31,18 +31,20 @@ describe('sankey', () => {
31
31
expect ( sankey . options . appendPadding ) . toEqual ( 8 ) ;
32
32
33
33
// node
34
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . type ) . toBe ( 'polygon' ) ;
35
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . data . length ) . toBe ( 48 ) ;
36
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . data [ 0 ] ) . toEqual ( {
34
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . type ) . toBe ( 'polygon' ) ;
35
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . data . length ) . toBe ( 48 ) ;
36
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . data [ 0 ] ) . toEqual ( {
37
+ isNode : true ,
37
38
name : "Agricultural 'waste'" ,
38
39
x : [ 0 , 0.008 , 0.008 , 0 ] ,
39
40
y : [ 0.26075939300940637 , 0.26075939300940637 , 0.2963247055394385 , 0.2963247055394385 ] ,
40
41
} ) ;
41
42
42
43
// edge
43
- expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . type ) . toBe ( 'edge' ) ;
44
- expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . data . length ) . toBe ( 68 ) ;
45
- expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . data [ 0 ] ) . toEqual ( {
44
+ expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . type ) . toBe ( 'edge' ) ;
45
+ expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . data . length ) . toBe ( 68 ) ;
46
+ expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . data [ 0 ] ) . toEqual ( {
47
+ isNode : false ,
46
48
name : "Agricultural 'waste'" ,
47
49
source : "Agricultural 'waste'" ,
48
50
target : 'Bio-conversion' ,
@@ -52,11 +54,11 @@ describe('sankey', () => {
52
54
} ) ;
53
55
54
56
// label
55
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . labelsContainer . getChildren ( ) . length ) . toBe ( 48 ) ;
56
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . labelsContainer . getChildByIndex ( 0 ) . cfg . children [ 0 ] . attr ( 'text' ) ) . toBe (
57
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . labelsContainer . getChildren ( ) . length ) . toBe ( 48 ) ;
58
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . labelsContainer . getChildByIndex ( 0 ) . cfg . children [ 0 ] . attr ( 'text' ) ) . toBe (
57
59
"Agricultural 'waste'"
58
60
) ;
59
- expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . labelsContainer . getChildren ( ) . length ) . toBe ( 0 ) ;
61
+ expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . labelsContainer . getChildren ( ) . length ) . toBe ( 0 ) ;
60
62
61
63
// tooltip
62
64
sankey . chart . showTooltip ( { x : 100 , y : 100 } ) ;
@@ -105,15 +107,15 @@ describe('sankey', () => {
105
107
sankey . render ( ) ;
106
108
107
109
// @ts -ignore
108
- expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . styleOption . cfg ) . toEqual ( {
110
+ expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . styleOption . cfg ) . toEqual ( {
109
111
fill : '#ccc' ,
110
112
fillOpacity : 0.5 ,
111
113
lineWidth : 0 ,
112
114
opacity : 0.3 ,
113
115
} ) ;
114
116
115
117
// @ts -ignore
116
- expect ( sankey . chart . views [ 0 ] . geometries [ 0 ] . styleOption . fields ) . toEqual ( [ 'x' , 'y' , 'name' ] ) ;
118
+ expect ( sankey . chart . views [ 1 ] . geometries [ 0 ] . styleOption . fields ) . toEqual ( [ 'x' , 'y' , 'name' ] ) ;
117
119
118
120
expect ( d ) . toEqual ( {
119
121
name : '其他流向' ,
@@ -142,7 +144,7 @@ describe('sankey', () => {
142
144
sankey . render ( ) ;
143
145
144
146
// 被去掉环
145
- expect ( sankey . chart . views [ 1 ] . getOptions ( ) . data . length ) . toBe ( 3 ) ;
147
+ expect ( sankey . chart . views [ 0 ] . getOptions ( ) . data . length ) . toBe ( 3 ) ;
146
148
147
149
sankey . destroy ( ) ;
148
150
} ) ;
0 commit comments