@@ -185,7 +185,7 @@ describe('Test sunburst calc:', function() {
185
185
function extractPt ( k ) {
186
186
var out = gd . calcdata . map ( function ( cd ) {
187
187
return cd [ 0 ] . hierarchy . descendants ( ) . map ( function ( pt ) {
188
- return pt [ k ] ;
188
+ return Lib . nestedProperty ( pt , k ) . get ( ) ;
189
189
} ) ;
190
190
} ) ;
191
191
return out . length > 1 ? out : out [ 0 ] ;
@@ -317,6 +317,54 @@ describe('Test sunburst calc:', function() {
317
317
expect ( extract ( 'id' ) ) . toEqual ( [ 'true' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' ] ) ;
318
318
expect ( extract ( 'pid' ) ) . toEqual ( [ '' , 'true' , 'true' , '2' , '2' , 'true' , 'true' , '6' , 'true' ] ) ;
319
319
} ) ;
320
+
321
+ it ( 'should compute correct sector *value* for generated implied root' , function ( ) {
322
+ _calc ( [ {
323
+ labels : [ 'A' , 'B' , 'b' ] ,
324
+ parents : [ 'Root' , 'Root' , 'B' ] ,
325
+ values : [ 1 , 2 , 1 ] ,
326
+ branchvalues : 'remainder'
327
+ } , {
328
+ labels : [ 'A' , 'B' , 'b' ] ,
329
+ parents : [ 'Root' , 'Root' , 'B' ] ,
330
+ values : [ 1 , 2 , 1 ] ,
331
+ branchvalues : 'total'
332
+ } ] ) ;
333
+
334
+ expect ( extractPt ( 'data.data.id' ) ) . toEqual ( [
335
+ [ 'Root' , 'B' , 'A' , 'b' ] ,
336
+ [ 'Root' , 'B' , 'A' , 'b' ]
337
+ ] ) ;
338
+ expect ( extractPt ( 'value' ) ) . toEqual ( [
339
+ [ 4 , 3 , 1 , 1 ] ,
340
+ [ 3 , 2 , 1 , 1 ]
341
+ ] ) ;
342
+ } ) ;
343
+
344
+ it ( 'should compute correct sector *value* for generated "root of roots"' , function ( ) {
345
+ spyOn ( Lib , 'randstr' ) . and . callFake ( function ( ) { return 'dummy' ; } ) ;
346
+
347
+ _calc ( [ {
348
+ labels : [ 'A' , 'B' , 'b' ] ,
349
+ parents : [ '' , '' , 'B' ] ,
350
+ values : [ 1 , 2 , 1 ] ,
351
+ branchvalues : 'remainder'
352
+ } , {
353
+ labels : [ 'A' , 'B' , 'b' ] ,
354
+ parents : [ '' , '' , 'B' ] ,
355
+ values : [ 1 , 2 , 1 ] ,
356
+ branchvalues : 'total'
357
+ } ] ) ;
358
+
359
+ expect ( extractPt ( 'data.data.id' ) ) . toEqual ( [
360
+ [ 'dummy' , 'B' , 'A' , 'b' ] ,
361
+ [ 'dummy' , 'B' , 'A' , 'b' ]
362
+ ] ) ;
363
+ expect ( extractPt ( 'value' ) ) . toEqual ( [
364
+ [ 4 , 3 , 1 , 1 ] ,
365
+ [ 3 , 2 , 1 , 1 ]
366
+ ] ) ;
367
+ } ) ;
320
368
} ) ;
321
369
322
370
describe ( 'Test sunburst hover:' , function ( ) {
0 commit comments