diff --git a/src/traces/contour/plot.js b/src/traces/contour/plot.js index 751cf8a5540..88ce634fb5d 100644 --- a/src/traces/contour/plot.js +++ b/src/traces/contour/plot.js @@ -240,8 +240,7 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { .classed('contourlabels', true); if(showLabels) { - var labelClipPathData = [perimeter]; - + var labelClipPathData = []; var labelData = []; // invalidate the getTextLocation cache in case paths changed @@ -287,6 +286,13 @@ function makeLinesAndLabels(plotgroup, pathinfo, gd, cd0, contours, perimeter) { bounds.middle = (bounds.top + bounds.bottom) / 2; bounds.center = (bounds.left + bounds.right) / 2; + labelClipPathData.push([ + [bounds.left, bounds.top], + [bounds.right, bounds.top], + [bounds.right, bounds.bottom], + [bounds.left, bounds.bottom] + ]); + var plotDiagonal = Math.sqrt(xLen * xLen + yLen * yLen); // the path length to use to scale the number of labels to draw: diff --git a/test/image/baselines/contour_label-reversed-axes.png b/test/image/baselines/contour_label-reversed-axes.png index 41eb891a8e0..fde7fc16683 100644 Binary files a/test/image/baselines/contour_label-reversed-axes.png and b/test/image/baselines/contour_label-reversed-axes.png differ diff --git a/test/image/mocks/contour_label-reversed-axes.json b/test/image/mocks/contour_label-reversed-axes.json index ea4aef29b4a..8736f2aa240 100644 --- a/test/image/mocks/contour_label-reversed-axes.json +++ b/test/image/mocks/contour_label-reversed-axes.json @@ -3,21 +3,61 @@ { "type": "contour", "z": [ - [1, 2, 1], - [2, 1, 2], - [2, 1, 2] + [1, 2, 3], + [2, 0, 0], + [3, 0, 3] ], - "contours": { - "showlabels": true - } + "contours": {"showlabels": true}, + "showscale": false + }, + { + "type": "contour", + "z": [ + [1, 2, 3], + [2, 0, 0], + [3, 0, 3] + ], + "contours": {"showlabels": true}, + "showscale": false, + "xaxis": "x2", + "yaxis": "y2" + }, + { + "type": "contour", + "z": [ + [1, 2, 3], + [2, 0, 0], + [3, 0, 3] + ], + "contours": {"showlabels": true}, + "showscale": false, + "xaxis": "x3", + "yaxis": "y3" + }, + { + "type": "contour", + "z": [ + [1, 2, 3], + [2, 0, 0], + [3, 0, 3] + ], + "contours": {"showlabels": true}, + "showscale": false, + "xaxis": "x4", + "yaxis": "y4" } ], "layout": { - "yaxis": { - "autorange": "reversed" - }, - "xaxis": { - "autorange": "reversed" - } + "grid": {"rows": 2, "columns": 2, "pattern": "independent"}, + + "xaxis": {"autorange": "reversed"}, + "yaxis": {"autorange": "reversed"}, + + "xaxis2": {"autorange": "reversed"}, + + "yaxis3": {"autorange": "reversed"}, + + "xaxis4": {"range": [2.05, -0.05]}, + "yaxis4": {"range": [2.2, -0.2]} } }