Skip to content

Commit f13f7b1

Browse files
committed
fix axis label being clipped with the clip plot option
closes #1803
1 parent 315d52a commit f13f7b1

File tree

3 files changed

+122
-1
lines changed

3 files changed

+122
-1
lines changed

src/marks/axis.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ function gridDefaults({
482482
}
483483

484484
function labelOptions(
485-
{fill, fillOpacity, fontFamily, fontSize, fontStyle, fontWeight, monospace, pointerEvents, shapeRendering},
485+
{fill, fillOpacity, fontFamily, fontSize, fontStyle, fontWeight, monospace, pointerEvents, shapeRendering, clip},
486486
initializer
487487
) {
488488
// Only propagate these options if constant.
@@ -501,6 +501,7 @@ function labelOptions(
501501
monospace,
502502
pointerEvents,
503503
shapeRendering,
504+
clip: clip === undefined ? false : clip,
504505
initializer
505506
};
506507
}

test/output/aaplCloseClip.svg

Lines changed: 104 additions & 0 deletions
Loading

test/plots/aapl-close.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ export async function aaplClose() {
1515
});
1616
}
1717

18+
export async function aaplCloseClip() {
19+
const AAPL = await d3.csv<any>("data/aapl.csv", d3.autoType);
20+
return Plot.plot({
21+
clip: true,
22+
x: {domain: [new Date(2015, 0, 1), new Date(2015, 3, 1)]},
23+
y: {
24+
grid: true
25+
},
26+
marks: [
27+
Plot.areaY(AAPL, {x: "Date", y: "Close", fillOpacity: 0.1}),
28+
Plot.lineY(AAPL, {x: "Date", y: "Close"}),
29+
Plot.ruleY([0], {clip: false})
30+
]
31+
});
32+
}
33+
1834
export async function aaplCloseDataTicks() {
1935
const AAPL = await d3.csv<any>("data/aapl.csv", d3.autoType);
2036
return Plot.plot({

0 commit comments

Comments
 (0)