Skip to content

Commit 1c5f971

Browse files
authored
respect margins when clipping (#758)
(we'd have caught the bug in the test plot if we had added a Plot.frame)
1 parent 39fdebe commit 1c5f971

File tree

2 files changed

+199
-194
lines changed

2 files changed

+199
-194
lines changed

src/style.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,15 @@ export function applyIndirectStyles(selection, mark, {width, height, marginLeft,
203203
applyAttr(selection, "paint-order", mark.paintOrder);
204204
if (mark.clip === "frame") {
205205
const id = `plot-clip-${++nextClipId}`;
206-
const w = width - marginRight - marginLeft;
207-
const h = height - marginTop - marginBottom;
208-
selection.append("clipPath").attr("id", id).append("rect").attr("width", w).attr("height", h);
209-
applyAttr(selection, "clip-path", `url(#${id})`);
206+
selection
207+
.attr("clip-path", `url(#${id})`)
208+
.append("clipPath")
209+
.attr("id", id)
210+
.append("rect")
211+
.attr("x", marginLeft)
212+
.attr("y", marginTop)
213+
.attr("width", width - marginRight - marginLeft)
214+
.attr("height", height - marginTop - marginBottom);
210215
}
211216
}
212217

0 commit comments

Comments
 (0)