Skip to content

Commit 1f85a6f

Browse files
committed
fix carpet plot clip path
1 parent b5a674f commit 1f85a6f

32 files changed

+10
-13
lines changed

src/traces/carpet/defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayou
2121
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
2222
}
2323

24+
traceOut._clipPathId = 'clip' + traceOut.uid + 'carpet';
25+
2426
var defaultColor = coerce('color', colorAttrs.defaultLine);
2527
Lib.coerceFont(coerce, 'font');
2628

@@ -55,6 +57,5 @@ module.exports = function supplyDefaults(traceIn, traceOut, dfltColor, fullLayou
5557

5658
if(!len) {
5759
traceOut.visible = false;
58-
return;
5960
}
6061
};

src/traces/carpet/plot.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ function plotOne(gd, plotinfo, cd) {
7373
function drawClipPath(trace, t, layer, xaxis, yaxis) {
7474
var seg, xp, yp, i;
7575
// var clip = makeg(layer, 'g', 'carpetclip');
76-
trace.clipPathId = 'clip' + trace.uid + 'carpet';
7776

78-
var clip = layer.select('#' + trace.clipPathId);
77+
var clip = layer.select('#' + trace._clipPathId);
7978

8079
if(!clip.size()) {
8180
clip = layer.append('clipPath')
@@ -96,9 +95,9 @@ function drawClipPath(trace, t, layer, xaxis, yaxis) {
9695
// This could be optimized ever so slightly to avoid no-op L segments
9796
// at the corners, but it's so negligible that I don't think it's worth
9897
// the extra complexity
99-
trace.clipPathData = 'M' + segs.join('L') + 'Z';
100-
clip.attr('id', trace.clipPathId);
101-
path.attr('d', trace.clipPathData);
98+
var clipPathData = 'M' + segs.join('L') + 'Z';
99+
clip.attr('id', trace._clipPathId);
100+
path.attr('d', clipPathData);
102101
// .style('stroke-width', 20)
103102
// .style('vector-effect', 'non-scaling-stroke')
104103
// .style('stroke', 'black')

src/traces/contourcarpet/plot.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,8 @@ function plotOne(gd, plotinfo, cd) {
124124
// Draw contour lines:
125125
makeLines(plotGroup, pathinfo, contours);
126126

127-
// Clip the boundary of the plot:
128-
clipBoundary(plotGroup, carpet);
129-
}
130-
131-
function clipBoundary(plotGroup, carpet) {
132-
plotGroup.attr('clip-path', 'url(#' + carpet.clipPathId + ')');
127+
// Clip the boundary of the plot
128+
Drawing.setClipUrl(plotGroup, carpet._clipPathId);
133129
}
134130

135131
function makeLines(plotgroup, pathinfo, contours) {

src/traces/scattercarpet/plot.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
var scatterPlot = require('../scatter/plot');
1313
var Axes = require('../../plots/cartesian/axes');
14+
var Drawing = require('../../components/drawing');
1415

1516
module.exports = function plot(gd, plotinfoproxy, data) {
1617
var i, trace, node;
@@ -37,6 +38,6 @@ module.exports = function plot(gd, plotinfoproxy, data) {
3738
// separately to all scattercarpet traces, but that would require
3839
// lots of reorganization of scatter traces that is otherwise not
3940
// necessary. That makes this a potential optimization.
40-
node.attr('clip-path', 'url(#clip' + carpet.uid + 'carpet)');
41+
Drawing.setClipUrl(node, carpet._clipPathId);
4142
}
4243
};

test/image/baselines/cheater.png

5 Bytes
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
-77 Bytes
Loading
-223 Bytes
Loading
0 Bytes
Loading

0 commit comments

Comments
 (0)