@@ -101,20 +101,23 @@ describe('scatterternary defaults', function() {
101
101
expect ( traceOut . visible ) . toBe ( false ) ;
102
102
} ) ;
103
103
104
- it ( 'should truncate data arrays to the same length (\'c\' is shortest case)' , function ( ) {
104
+ it ( 'should not truncate data arrays to the same length (\'c\' is shortest case)' , function ( ) {
105
+ // this is handled at the calc step now via _length.
105
106
traceIn = {
106
107
a : [ 1 , 2 , 3 ] ,
107
108
b : [ 1 , 2 ] ,
108
109
c : [ 1 ]
109
110
} ;
110
111
111
112
supplyDefaults ( traceIn , traceOut , defaultColor , layout ) ;
112
- expect ( traceOut . a ) . toEqual ( [ 1 ] ) ;
113
- expect ( traceOut . b ) . toEqual ( [ 1 ] ) ;
113
+ expect ( traceOut . a ) . toEqual ( [ 1 , 2 , 3 ] ) ;
114
+ expect ( traceOut . b ) . toEqual ( [ 1 , 2 ] ) ;
114
115
expect ( traceOut . c ) . toEqual ( [ 1 ] ) ;
116
+ expect ( traceOut . _length ) . toBe ( 1 ) ;
115
117
} ) ;
116
118
117
- it ( 'should truncate data arrays to the same length (\'a\' is shortest case)' , function ( ) {
119
+ it ( 'should not truncate data arrays to the same length (\'a\' is shortest case)' , function ( ) {
120
+ // this is handled at the calc step now via _length.
118
121
traceIn = {
119
122
a : [ 1 ] ,
120
123
b : [ 1 , 2 , 3 ] ,
@@ -123,21 +126,24 @@ describe('scatterternary defaults', function() {
123
126
124
127
supplyDefaults ( traceIn , traceOut , defaultColor , layout ) ;
125
128
expect ( traceOut . a ) . toEqual ( [ 1 ] ) ;
126
- expect ( traceOut . b ) . toEqual ( [ 1 ] ) ;
127
- expect ( traceOut . c ) . toEqual ( [ 1 ] ) ;
129
+ expect ( traceOut . b ) . toEqual ( [ 1 , 2 , 3 ] ) ;
130
+ expect ( traceOut . c ) . toEqual ( [ 1 , 2 ] ) ;
131
+ expect ( traceOut . _length ) . toBe ( 1 ) ;
128
132
} ) ;
129
133
130
- it ( 'should truncate data arrays to the same length (\'a\' is shortest case)' , function ( ) {
134
+ it ( 'should not truncate data arrays to the same length (\'a\' is shortest case)' , function ( ) {
135
+ // this is handled at the calc step now via _length.
131
136
traceIn = {
132
137
a : [ 1 , 2 ] ,
133
138
b : [ 1 ] ,
134
139
c : [ 1 , 2 , 3 ]
135
140
} ;
136
141
137
142
supplyDefaults ( traceIn , traceOut , defaultColor , layout ) ;
138
- expect ( traceOut . a ) . toEqual ( [ 1 ] ) ;
143
+ expect ( traceOut . a ) . toEqual ( [ 1 , 2 ] ) ;
139
144
expect ( traceOut . b ) . toEqual ( [ 1 ] ) ;
140
- expect ( traceOut . c ) . toEqual ( [ 1 ] ) ;
145
+ expect ( traceOut . c ) . toEqual ( [ 1 , 2 , 3 ] ) ;
146
+ expect ( traceOut . _length ) . toBe ( 1 ) ;
141
147
} ) ;
142
148
143
149
it ( 'should include \'name\' in \'hoverinfo\' default if multi trace graph' , function ( ) {
@@ -218,32 +224,39 @@ describe('scatterternary calc', function() {
218
224
219
225
trace = {
220
226
subplot : 'ternary' ,
221
- sum : 1
227
+ sum : 1 ,
228
+ _length : 3
222
229
} ;
223
230
} ) ;
224
231
232
+ function get ( cd , component ) {
233
+ return cd . map ( function ( v ) {
234
+ return v [ component ] ;
235
+ } ) ;
236
+ }
237
+
225
238
it ( 'should fill in missing component (case \'c\')' , function ( ) {
226
239
trace . a = [ 0.1 , 0.3 , 0.6 ] ;
227
240
trace . b = [ 0.3 , 0.6 , 0.1 ] ;
228
241
229
- calc ( gd , trace ) ;
230
- expect ( trace . c ) . toBeCloseToArray ( [ 0.6 , 0.1 , 0.3 ] ) ;
242
+ cd = calc ( gd , trace ) ;
243
+ expect ( get ( cd , 'c' ) ) . toBeCloseToArray ( [ 0.6 , 0.1 , 0.3 ] ) ;
231
244
} ) ;
232
245
233
246
it ( 'should fill in missing component (case \'b\')' , function ( ) {
234
247
trace . a = [ 0.1 , 0.3 , 0.6 ] ;
235
248
trace . c = [ 0.1 , 0.3 , 0.2 ] ;
236
249
237
- calc ( gd , trace ) ;
238
- expect ( trace . b ) . toBeCloseToArray ( [ 0.8 , 0.4 , 0.2 ] ) ;
250
+ cd = calc ( gd , trace ) ;
251
+ expect ( get ( cd , 'b' ) ) . toBeCloseToArray ( [ 0.8 , 0.4 , 0.2 ] ) ;
239
252
} ) ;
240
253
241
254
it ( 'should fill in missing component (case \'a\')' , function ( ) {
242
255
trace . b = [ 0.1 , 0.3 , 0.6 ] ;
243
256
trace . c = [ 0.8 , 0.4 , 0.1 ] ;
244
257
245
- calc ( gd , trace ) ;
246
- expect ( trace . a ) . toBeCloseToArray ( [ 0.1 , 0.3 , 0.3 ] ) ;
258
+ cd = calc ( gd , trace ) ;
259
+ expect ( get ( cd , 'a' ) ) . toBeCloseToArray ( [ 0.1 , 0.3 , 0.3 ] ) ;
247
260
} ) ;
248
261
249
262
it ( 'should skip over non-numeric values' , function ( ) {
0 commit comments