Skip to content

Commit ba492cf

Browse files
committed
add treemap and sunburst tests to cover the case of using marker.colors numbers without defined colorscale
1 parent 2e17994 commit ba492cf

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

test/jasmine/tests/sunburst_test.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,27 @@ describe('Test sunburst calc:', function() {
363363
expect(cd[8].color).toEqual('rgba(255, 255, 255, 1)');
364364
});
365365

366-
it('should use *marker.colors* numbers with colorscale', function() {
366+
it('should use *marker.colors* numbers with default colorscale', function() {
367+
_calc({
368+
marker: { colors: [-4, -3, -2, -1, 0, 1, 2, 3, 4] },
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(5, 10, 172)');
376+
expect(cd[1].color).toEqual('rgb(41, 55, 199)');
377+
expect(cd[2].color).toEqual('rgb(77, 101, 226)');
378+
expect(cd[3].color).toEqual('rgb(120, 146, 238)');
379+
expect(cd[4].color).toEqual('rgb(190, 190, 190)');
380+
expect(cd[5].color).toEqual('rgb(223, 164, 122)');
381+
expect(cd[6].color).toEqual('rgb(221, 123, 80)');
382+
expect(cd[7].color).toEqual('rgb(200, 66, 54)');
383+
expect(cd[8].color).toEqual('rgb(178, 10, 28)');
384+
});
385+
386+
it('should use *marker.colors* numbers with desired colorscale', function() {
367387
_calc({
368388
marker: { colors: [1, 2, 3, 4, 5, 6, 7, 8, 9], colorscale: 'Portland' },
369389
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],

test/jasmine/tests/treemap_test.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,27 @@ describe('Test treemap calc:', function() {
474474
expect(cd[8].color).toEqual('rgba(255, 255, 255, 1)');
475475
});
476476

477-
it('should use *marker.colors* numbers with colorscale', function() {
477+
it('should use *marker.colors* numbers with default colorscale', function() {
478+
_calc({
479+
marker: { colors: [-4, -3, -2, -1, 0, 1, 2, 3, 4] },
480+
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],
481+
parents: ['', 'Eve', 'Eve', 'Seth', 'Seth', 'Eve', 'Eve', 'Awan', 'Eve']
482+
});
483+
484+
var cd = gd.calcdata[0];
485+
expect(cd.length).toEqual(9);
486+
expect(cd[0].color).toEqual('rgb(5, 10, 172)');
487+
expect(cd[1].color).toEqual('rgb(41, 55, 199)');
488+
expect(cd[2].color).toEqual('rgb(77, 101, 226)');
489+
expect(cd[3].color).toEqual('rgb(120, 146, 238)');
490+
expect(cd[4].color).toEqual('rgb(190, 190, 190)');
491+
expect(cd[5].color).toEqual('rgb(223, 164, 122)');
492+
expect(cd[6].color).toEqual('rgb(221, 123, 80)');
493+
expect(cd[7].color).toEqual('rgb(200, 66, 54)');
494+
expect(cd[8].color).toEqual('rgb(178, 10, 28)');
495+
});
496+
497+
it('should use *marker.colors* numbers with desired colorscale', function() {
478498
_calc({
479499
marker: { colors: [1, 2, 3, 4, 5, 6, 7, 8, 9], colorscale: 'Portland' },
480500
labels: ['Eve', 'Cain', 'Seth', 'Enos', 'Noam', 'Abel', 'Awan', 'Enoch', 'Azura'],

0 commit comments

Comments
 (0)