@@ -185,7 +185,7 @@ describe('Test sunburst calc:', function() {
185185 function extractPt ( k ) {
186186 var out = gd . calcdata . map ( function ( cd ) {
187187 return cd [ 0 ] . hierarchy . descendants ( ) . map ( function ( pt ) {
188- return pt [ k ] ;
188+ return Lib . nestedProperty ( pt , k ) . get ( ) ;
189189 } ) ;
190190 } ) ;
191191 return out . length > 1 ? out : out [ 0 ] ;
@@ -317,6 +317,54 @@ describe('Test sunburst calc:', function() {
317317 expect ( extract ( 'id' ) ) . toEqual ( [ 'true' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' ] ) ;
318318 expect ( extract ( 'pid' ) ) . toEqual ( [ '' , 'true' , 'true' , '2' , '2' , 'true' , 'true' , '6' , 'true' ] ) ;
319319 } ) ;
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+ } ) ;
320368} ) ;
321369
322370describe ( 'Test sunburst hover:' , function ( ) {
0 commit comments