@@ -153,6 +153,31 @@ describe('Test sunburst defaults:', function() {
153153 expect ( gd . _fullLayout . sunburstcolorway )
154154 . toEqual ( [ 'cyan' , 'yellow' , 'black' ] , 'user-defined value' ) ;
155155 } ) ;
156+
157+ it ( 'should not default *marker.colorscale* when not having *marker.colors*' , function ( ) {
158+ _supply ( [
159+ { labels : [ 1 ] , parents : [ '' ] }
160+ ] ) ;
161+
162+ expect ( fullData [ 0 ] . marker . colorscale ) . toBe ( undefined ) ;
163+ } ) ;
164+
165+ it ( 'should default *marker.colorscale* to *Reds* when having *marker.colors*' , function ( ) {
166+ _supply ( [
167+ { labels : [ 1 ] , parents : [ '' ] , marker : {
168+ colors : [ 0 ]
169+ } }
170+ ] ) ;
171+
172+ expect ( fullData [ 0 ] . marker . colorscale ) . toBeCloseToArray ( [
173+ [ 0 , 'rgb(5,10,172)' ] ,
174+ [ 0.35 , 'rgb(106,137,247)' ] ,
175+ [ 0.5 , 'rgb(190,190,190)' ] ,
176+ [ 0.6 , 'rgb(220,170,132)' ] ,
177+ [ 0.7 , 'rgb(230,145,90)' ] ,
178+ [ 1 , 'rgb(178,10,28)' ]
179+ ] ) ;
180+ } ) ;
156181} ) ;
157182
158183describe ( 'Test sunburst calc:' , function ( ) {
@@ -317,6 +342,88 @@ describe('Test sunburst calc:', function() {
317342 expect ( extract ( 'id' ) ) . toEqual ( [ 'true' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' ] ) ;
318343 expect ( extract ( 'pid' ) ) . toEqual ( [ '' , 'true' , 'true' , '2' , '2' , 'true' , 'true' , '6' , 'true' ] ) ;
319344 } ) ;
345+
346+ it ( 'should use *marker.colors*' , function ( ) {
347+ _calc ( {
348+ marker : { colors : [ 'pink' , '#777' , '#f00' , '#ff0' , '#0f0' , '#0ff' , '#00f' , '#f0f' , '#fff' ] } ,
349+ labels : [ 'Eve' , 'Cain' , 'Seth' , 'Enos' , 'Noam' , 'Abel' , 'Awan' , 'Enoch' , 'Azura' ] ,
350+ parents : [ '' , 'Eve' , 'Eve' , 'Seth' , 'Seth' , 'Eve' , 'Eve' , 'Awan' , 'Eve' ]
351+ } ) ;
352+
353+ var cd = gd . calcdata [ 0 ] ;
354+ expect ( cd . length ) . toEqual ( 9 ) ;
355+ expect ( cd [ 0 ] . color ) . toEqual ( 'rgba(255, 192, 203, 1)' ) ;
356+ expect ( cd [ 1 ] . color ) . toEqual ( 'rgba(119, 119, 119, 1)' ) ;
357+ expect ( cd [ 2 ] . color ) . toEqual ( 'rgba(255, 0, 0, 1)' ) ;
358+ expect ( cd [ 3 ] . color ) . toEqual ( 'rgba(255, 255, 0, 1)' ) ;
359+ expect ( cd [ 4 ] . color ) . toEqual ( 'rgba(0, 255, 0, 1)' ) ;
360+ expect ( cd [ 5 ] . color ) . toEqual ( 'rgba(0, 255, 255, 1)' ) ;
361+ expect ( cd [ 6 ] . color ) . toEqual ( 'rgba(0, 0, 255, 1)' ) ;
362+ expect ( cd [ 7 ] . color ) . toEqual ( 'rgba(255, 0, 255, 1)' ) ;
363+ expect ( cd [ 8 ] . color ) . toEqual ( 'rgba(255, 255, 255, 1)' ) ;
364+ } ) ;
365+
366+ it ( 'should use *marker.colors* numbers with colorscale' , function ( ) {
367+ _calc ( {
368+ marker : { colors : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] , colorscale : 'Portland' } ,
369+ labels : [ 'Eve' , 'Cain' , 'Seth' , 'Enos' , 'Noam' , 'Abel' , 'Awan' , 'Enoch' , 'Azura' ] ,
370+ parents : [ '' , 'Eve' , 'Eve' , 'Seth' , 'Seth' , 'Eve' , 'Eve' , 'Awan' , 'Eve' ]
371+ } ) ;
372+
373+ var cd = gd . calcdata [ 0 ] ;
374+ expect ( cd . length ) . toEqual ( 9 ) ;
375+ expect ( cd [ 0 ] . color ) . toEqual ( 'rgb(12, 51, 131)' ) ;
376+ expect ( cd [ 1 ] . color ) . toEqual ( 'rgb(11, 94, 159)' ) ;
377+ expect ( cd [ 2 ] . color ) . toEqual ( 'rgb(10, 136, 186)' ) ;
378+ expect ( cd [ 3 ] . color ) . toEqual ( 'rgb(126, 174, 121)' ) ;
379+ expect ( cd [ 4 ] . color ) . toEqual ( 'rgb(242, 211, 56)' ) ;
380+ expect ( cd [ 5 ] . color ) . toEqual ( 'rgb(242, 177, 56)' ) ;
381+ expect ( cd [ 6 ] . color ) . toEqual ( 'rgb(242, 143, 56)' ) ;
382+ expect ( cd [ 7 ] . color ) . toEqual ( 'rgb(230, 87, 43)' ) ;
383+ expect ( cd [ 8 ] . color ) . toEqual ( 'rgb(217, 30, 30)' ) ;
384+ } ) ;
385+
386+ it ( 'should use *marker.colors* numbers not values with colorscale' , function ( ) {
387+ _calc ( {
388+ values : [ 0.0001 , 0.001 , 0.01 , 0.1 , 1 , 10 , 100 , 1000 , 10000 ] ,
389+ marker : { colors : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] , colorscale : 'Portland' } ,
390+ labels : [ 'Eve' , 'Cain' , 'Seth' , 'Enos' , 'Noam' , 'Abel' , 'Awan' , 'Enoch' , 'Azura' ] ,
391+ parents : [ '' , 'Eve' , 'Eve' , 'Seth' , 'Seth' , 'Eve' , 'Eve' , 'Awan' , 'Eve' ]
392+ } ) ;
393+
394+ var cd = gd . calcdata [ 0 ] ;
395+ expect ( cd . length ) . toEqual ( 9 ) ;
396+ expect ( cd [ 0 ] . color ) . toEqual ( 'rgb(12, 51, 131)' ) ;
397+ expect ( cd [ 1 ] . color ) . toEqual ( 'rgb(11, 94, 159)' ) ;
398+ expect ( cd [ 2 ] . color ) . toEqual ( 'rgb(10, 136, 186)' ) ;
399+ expect ( cd [ 3 ] . color ) . toEqual ( 'rgb(126, 174, 121)' ) ;
400+ expect ( cd [ 4 ] . color ) . toEqual ( 'rgb(242, 211, 56)' ) ;
401+ expect ( cd [ 5 ] . color ) . toEqual ( 'rgb(242, 177, 56)' ) ;
402+ expect ( cd [ 6 ] . color ) . toEqual ( 'rgb(242, 143, 56)' ) ;
403+ expect ( cd [ 7 ] . color ) . toEqual ( 'rgb(230, 87, 43)' ) ;
404+ expect ( cd [ 8 ] . color ) . toEqual ( 'rgb(217, 30, 30)' ) ;
405+ } ) ;
406+
407+ it ( 'should use values with colorscale when *marker.colors* in empty' , function ( ) {
408+ _calc ( {
409+ values : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ,
410+ marker : { colors : [ ] , colorscale : 'Portland' } ,
411+ labels : [ 'Eve' , 'Cain' , 'Seth' , 'Enos' , 'Noam' , 'Abel' , 'Awan' , 'Enoch' , 'Azura' ] ,
412+ parents : [ '' , 'Eve' , 'Eve' , 'Seth' , 'Seth' , 'Eve' , 'Eve' , 'Awan' , 'Eve' ]
413+ } ) ;
414+
415+ var cd = gd . calcdata [ 0 ] ;
416+ expect ( cd . length ) . toEqual ( 9 ) ;
417+ expect ( cd [ 0 ] . color ) . toEqual ( 'rgb(12, 51, 131)' ) ;
418+ expect ( cd [ 1 ] . color ) . toEqual ( 'rgb(11, 94, 159)' ) ;
419+ expect ( cd [ 2 ] . color ) . toEqual ( 'rgb(10, 136, 186)' ) ;
420+ expect ( cd [ 3 ] . color ) . toEqual ( 'rgb(126, 174, 121)' ) ;
421+ expect ( cd [ 4 ] . color ) . toEqual ( 'rgb(242, 211, 56)' ) ;
422+ expect ( cd [ 5 ] . color ) . toEqual ( 'rgb(242, 177, 56)' ) ;
423+ expect ( cd [ 6 ] . color ) . toEqual ( 'rgb(242, 143, 56)' ) ;
424+ expect ( cd [ 7 ] . color ) . toEqual ( 'rgb(230, 87, 43)' ) ;
425+ expect ( cd [ 8 ] . color ) . toEqual ( 'rgb(217, 30, 30)' ) ;
426+ } ) ;
320427} ) ;
321428
322429describe ( 'Test sunburst hover:' , function ( ) {
0 commit comments