Skip to content

Commit 9985068

Browse files
committed
test arrayOk attributes in scattercarpet
1 parent 5809137 commit 9985068

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/jasmine/tests/carpet_test.js

+58
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,61 @@ describe('Test carpet interactions:', function() {
512512
.then(done);
513513
});
514514
});
515+
516+
describe('scattercarpet array attributes', function() {
517+
var gd;
518+
519+
beforeEach(function() {
520+
gd = createGraphDiv();
521+
});
522+
523+
afterEach(destroyGraphDiv);
524+
525+
it('works in both initial draws and restyles', function(done) {
526+
var mock = Lib.extendDeep({}, require('@mocks/scattercarpet.json'));
527+
528+
var mc = ['#000', '#00f', '#0ff', '#ff0'];
529+
var ms = [10, 20, 30, 40];
530+
var ms2 = [5, 6, 7, 8];
531+
var mlw = [1, 2, 3, 4];
532+
var mlc = ['#00e', '#0ee', '#ee0', '#eee'];
533+
534+
// add some arrayOk array attributes
535+
mock.data[5].marker = {
536+
color: mc,
537+
size: ms,
538+
line: {
539+
width: mlw,
540+
color: mlc
541+
}
542+
};
543+
544+
Plotly.plot(gd, mock)
545+
.then(function() {
546+
for(var i = 0; i < 4; i++) {
547+
var pt = gd.calcdata[5][i];
548+
expect(pt.mc).toBe(mc[i]);
549+
expect(pt.ms).toBe(ms[i]);
550+
expect(pt.mlw).toBe(mlw[i]);
551+
expect(pt.mlc).toBe(mlc[i]);
552+
}
553+
554+
// turn one array into a constant, another into a new array,
555+
return Plotly.restyle(gd, {'marker.color': '#f00', 'marker.size': [ms2]},
556+
null, [5]);
557+
})
558+
.then(function() {
559+
expect(gd._fullData[5].marker.color).toBe('#f00');
560+
561+
for(var i = 0; i < 4; i++) {
562+
var pt = gd.calcdata[5][i];
563+
expect(pt.mc).toBeUndefined();
564+
expect(pt.ms).toBe(ms2[i]);
565+
expect(pt.mlw).toBe(mlw[i]);
566+
expect(pt.mlc).toBe(mlc[i]);
567+
}
568+
})
569+
.catch(fail)
570+
.then(done);
571+
});
572+
});

0 commit comments

Comments
 (0)