Skip to content

Commit 48ee0d8

Browse files
committed
🔒 contour with heatmap coloring layer order
- previously, Contour.plot called Heatmap.call for traces with 'contour.coloring': 'heatmap' which plotted a heatmap in <g.imagelayer> always below the contours. Now as <g.heatmaplayer> does not always exist, we plot the heatmap fill inside <g.contourlayer> in a ensureSingle layer.
1 parent fa38ca5 commit 48ee0d8

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/jasmine/tests/contour_test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,55 @@ describe('contour plotting and editing', function() {
407407
.catch(fail)
408408
.then(done);
409409
});
410+
411+
it('should always draw heatmap coloring layer below contour lines', function(done) {
412+
var cnt = 0;
413+
414+
function _assert(exp) {
415+
var msg = ' index in <g.contourlayer> (call #' + cnt + ')';
416+
var contourLayer = gd.querySelector('.xy > .plot > .contourlayer');
417+
var hmIndex = -1;
418+
var contoursIndex = -1;
419+
420+
for(var i in contourLayer.children) {
421+
var child = contourLayer.children[i];
422+
if(child.querySelector) {
423+
if(child.querySelector('.hm')) hmIndex = +i;
424+
else if(child.querySelector('.contourlevel')) contoursIndex = +i;
425+
}
426+
}
427+
428+
expect(hmIndex).toBe(exp.hmIndex, 'heatmap' + msg);
429+
expect(contoursIndex).toBe(exp.contoursIndex, 'contours' + msg);
430+
cnt++;
431+
}
432+
433+
Plotly.newPlot(gd, [{
434+
type: 'contour',
435+
z: [[1, 2, 3], [1, 3, 0]],
436+
contours: {coloring: 'heatmap'}
437+
}])
438+
.then(function() {
439+
_assert({
440+
hmIndex: 0,
441+
contoursIndex: 1
442+
});
443+
return Plotly.restyle(gd, 'contours.coloring', 'lines');
444+
})
445+
.then(function() {
446+
_assert({
447+
hmIndex: -1,
448+
contoursIndex: 1
449+
});
450+
return Plotly.restyle(gd, 'contours.coloring', 'heatmap');
451+
})
452+
.then(function() {
453+
_assert({
454+
hmIndex: 0,
455+
contoursIndex: 1
456+
});
457+
})
458+
.catch(fail)
459+
.then(done);
460+
});
410461
});

0 commit comments

Comments
 (0)