Skip to content

Commit 17e7823

Browse files
committed
adapt contour label clipPath segments for reversed axes
- it needs to have correct direction so that the SVG even-odd fill rule works.
1 parent 0ec6cfa commit 17e7823

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

src/traces/contour/plot.js

+8-2
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:
Loading

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

+31-9
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,39 @@
77
[2, 1, 2],
88
[2, 1, 2]
99
],
10-
"contours": {
11-
"showlabels": true
12-
}
10+
"contours": {"showlabels": true}
11+
},
12+
{
13+
"type": "contour",
14+
"z": [
15+
[1, 2, 1],
16+
[2, 1, 2],
17+
[2, 1, 2]
18+
],
19+
"contours": {"showlabels": true},
20+
"xaxis": "x2",
21+
"yaxis": "y2"
22+
},
23+
{
24+
"type": "contour",
25+
"z": [
26+
[1, 2, 1],
27+
[2, 1, 2],
28+
[2, 1, 2]
29+
],
30+
"contours": {"showlabels": true},
31+
"xaxis": "x3",
32+
"yaxis": "y3"
1333
}
1434
],
1535
"layout": {
16-
"yaxis": {
17-
"autorange": "reversed"
18-
},
19-
"xaxis": {
20-
"autorange": "reversed"
21-
}
36+
"grid": {"rows": 2, "columns": 2, "pattern": "independent"},
37+
38+
"xaxis": {"autorange": "reversed"},
39+
"yaxis": {"autorange": "reversed"},
40+
41+
"xaxis2": {"autorange": "reversed"},
42+
43+
"yaxis3": {"autorange": "reversed"}
2244
}
2345
}

0 commit comments

Comments
 (0)