Skip to content

Commit dbf4e29

Browse files
committed
add parcoords line.color restyle test
1 parent 6b76026 commit dbf4e29

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/jasmine/tests/parcoords_test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,51 @@ describe('parcoords Lifecycle methods', function() {
790790
.then(done);
791791
});
792792
});
793+
794+
it('@gl line.color `Plotly.restyle` should work', function(done) {
795+
function getAvgPixelByChannel() {
796+
var canvas = d3.select('.gl-canvas-focus').node();
797+
var imgData = readPixel(canvas, 0, 0, canvas.width, canvas.height);
798+
var n = imgData.length / 4;
799+
var r = 0;
800+
var g = 0;
801+
var b = 0;
802+
803+
for(var i = 0; i < imgData.length; i++) {
804+
r += imgData[i++];
805+
g += imgData[i++];
806+
b += imgData[i++];
807+
}
808+
return [r / n, g / n, b / n];
809+
}
810+
811+
Plotly.plot(gd, [{
812+
type: 'parcoords',
813+
dimensions: [{
814+
values: [1, 2]
815+
}, {
816+
values: [2, 4]
817+
}],
818+
line: {color: 'blue'}
819+
}], {
820+
width: 300,
821+
height: 200
822+
})
823+
.then(function() {
824+
var rbg = getAvgPixelByChannel();
825+
expect(rbg[0]).toBe(0, 'no red');
826+
expect(rbg[2]).not.toBe(0, 'all blue');
827+
828+
return Plotly.restyle(gd, 'line.color', 'red');
829+
})
830+
.then(function() {
831+
var rbg = getAvgPixelByChannel();
832+
expect(rbg[0]).not.toBe(0, 'all red');
833+
expect(rbg[2]).toBe(0, 'no blue');
834+
})
835+
.catch(failTest)
836+
.then(done);
837+
});
793838
});
794839

795840
describe('parcoords basic use', function() {

0 commit comments

Comments
 (0)