Skip to content

Commit 1a90501

Browse files
committed
Merge remote-tracking branch 'origin/master' into dont-call-autotype-for-3d
2 parents 9beb88d + 0078626 commit 1a90501

File tree

5 files changed

+125
-14
lines changed

5 files changed

+125
-14
lines changed

src/plots/cartesian/axes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,9 +1585,13 @@ axes.draw = function(gd, arg, opts) {
15851585
plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick').remove();
15861586
plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick').remove();
15871587
plotinfo.xaxislayer.selectAll('.' + xa._id + 'tick2').remove();
1588+
plotinfo.yaxislayer.selectAll('.' + ya._id + 'tick2').remove();
15881589
plotinfo.xaxislayer.selectAll('.' + xa._id + 'divider').remove();
1590+
plotinfo.yaxislayer.selectAll('.' + ya._id + 'divider').remove();
1591+
15891592
if(plotinfo.gridlayer) plotinfo.gridlayer.selectAll('path').remove();
15901593
if(plotinfo.zerolinelayer) plotinfo.zerolinelayer.selectAll('path').remove();
1594+
15911595
fullLayout._infolayer.select('.g-' + xa._id + 'title').remove();
15921596
fullLayout._infolayer.select('.g-' + ya._id + 'title').remove();
15931597
});

src/traces/contour/plot.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) {
240240
.classed('contourlabels', true);
241241

242242
if(showLabels) {
243-
var labelClipPathData = [perimeter];
244-
243+
var labelClipPathData = [];
245244
var labelData = [];
246245

247246
// invalidate the getTextLocation cache in case paths changed
@@ -287,6 +286,13 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) {
287286
bounds.middle = (bounds.top + bounds.bottom) / 2;
288287
bounds.center = (bounds.left + bounds.right) / 2;
289288

289+
labelClipPathData.push([
290+
[bounds.left, bounds.top],
291+
[bounds.right, bounds.top],
292+
[bounds.right, bounds.bottom],
293+
[bounds.left, bounds.bottom]
294+
]);
295+
290296
var plotDiagonal = Math.sqrt(xLen * xLen + yLen * yLen);
291297

292298
// the path length to use to scale the number of labels to draw:
-12.1 KB
Loading

test/image/mocks/contour_label-reversed-axes.json

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,61 @@
33
{
44
"type": "contour",
55
"z": [
6-
[1, 2, 1],
7-
[2, 1, 2],
8-
[2, 1, 2]
6+
[1, 2, 3],
7+
[2, 0, 0],
8+
[3, 0, 3]
99
],
10-
"contours": {
11-
"showlabels": true
12-
}
10+
"contours": {"showlabels": true},
11+
"showscale": false
12+
},
13+
{
14+
"type": "contour",
15+
"z": [
16+
[1, 2, 3],
17+
[2, 0, 0],
18+
[3, 0, 3]
19+
],
20+
"contours": {"showlabels": true},
21+
"showscale": false,
22+
"xaxis": "x2",
23+
"yaxis": "y2"
24+
},
25+
{
26+
"type": "contour",
27+
"z": [
28+
[1, 2, 3],
29+
[2, 0, 0],
30+
[3, 0, 3]
31+
],
32+
"contours": {"showlabels": true},
33+
"showscale": false,
34+
"xaxis": "x3",
35+
"yaxis": "y3"
36+
},
37+
{
38+
"type": "contour",
39+
"z": [
40+
[1, 2, 3],
41+
[2, 0, 0],
42+
[3, 0, 3]
43+
],
44+
"contours": {"showlabels": true},
45+
"showscale": false,
46+
"xaxis": "x4",
47+
"yaxis": "y4"
1348
}
1449
],
1550
"layout": {
16-
"yaxis": {
17-
"autorange": "reversed"
18-
},
19-
"xaxis": {
20-
"autorange": "reversed"
21-
}
51+
"grid": {"rows": 2, "columns": 2, "pattern": "independent"},
52+
53+
"xaxis": {"autorange": "reversed"},
54+
"yaxis": {"autorange": "reversed"},
55+
56+
"xaxis2": {"autorange": "reversed"},
57+
58+
"yaxis3": {"autorange": "reversed"},
59+
60+
"xaxis4": {"range": [2.05, -0.05]},
61+
"yaxis4": {"range": [2.2, -0.2]}
2262
}
2363
}

test/jasmine/tests/cartesian_test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,4 +907,65 @@ describe('subplot creation / deletion:', function() {
907907
.catch(failTest)
908908
.then(done);
909909
});
910+
911+
it('clears secondary labels and divider when updating out of axis type multicategory (y-axis case)', function(done) {
912+
function _assert(msg, exp) {
913+
var gd3 = d3.select(gd);
914+
expect(gd3.selectAll('.ytick > text').size())
915+
.toBe(exp.tickCnt, msg + ' # labels');
916+
expect(gd3.selectAll('.ytick2 > text').size())
917+
.toBe(exp.tick2Cnt, msg + ' # secondary labels');
918+
expect(gd3.selectAll('.ydivider').size())
919+
.toBe(exp.dividerCnt, msg + ' # dividers');
920+
}
921+
922+
Plotly.react(gd, [{
923+
type: 'bar',
924+
orientation: 'h',
925+
y: ['a', 'b', 'c'],
926+
x: [1, 2, 1]
927+
}])
928+
.then(function() {
929+
_assert('base - category axis', {
930+
tickCnt: 3,
931+
tick2Cnt: 0,
932+
dividerCnt: 0
933+
});
934+
})
935+
.then(function() {
936+
return Plotly.react(gd, [{
937+
type: 'bar',
938+
orientation: 'h',
939+
y: [
940+
['d', 'd', 'e'],
941+
['a', 'b', 'c']
942+
],
943+
x: [1, 2, 3]
944+
}]);
945+
})
946+
.then(function() {
947+
_assert('multicategory axis', {
948+
tickCnt: 3,
949+
tick2Cnt: 2,
950+
dividerCnt: 3
951+
});
952+
})
953+
.then(function() {
954+
return Plotly.react(gd, [{
955+
type: 'bar',
956+
orientation: 'h',
957+
y: ['a', 'b', 'c'],
958+
x: [1, 2, 1]
959+
}]);
960+
})
961+
.then(function() {
962+
_assert('back to category axis', {
963+
tickCnt: 3,
964+
tick2Cnt: 0,
965+
dividerCnt: 0
966+
});
967+
})
968+
.catch(failTest)
969+
.then(done);
970+
});
910971
});

0 commit comments

Comments
 (0)