Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix axis label being clipped with the clip plot option #1804

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/marks/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ function gridDefaults({
}

function labelOptions(
{fill, fillOpacity, fontFamily, fontSize, fontStyle, fontWeight, monospace, pointerEvents, shapeRendering},
{fill, fillOpacity, fontFamily, fontSize, fontStyle, fontWeight, monospace, pointerEvents, shapeRendering, clip},
initializer
) {
// Only propagate these options if constant.
Expand All @@ -501,6 +501,7 @@ function labelOptions(
monospace,
pointerEvents,
shapeRendering,
clip: clip === undefined ? false : clip,
mbostock marked this conversation as resolved.
Show resolved Hide resolved
initializer
};
}
Expand Down
104 changes: 104 additions & 0 deletions test/output/aaplCloseClip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions test/plots/aapl-close.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ export async function aaplClose() {
});
}

export async function aaplCloseClip() {
const AAPL = await d3.csv<any>("data/aapl.csv", d3.autoType);
return Plot.plot({
clip: true,
x: {domain: [new Date(Date.UTC(2015, 0, 1)), new Date(Date.UTC(2015, 3, 1))]},
y: {
grid: true
},
marks: [
Plot.areaY(AAPL, {x: "Date", y: "Close", fillOpacity: 0.1}),
Plot.lineY(AAPL, {x: "Date", y: "Close"}),
Plot.ruleY([0], {clip: false})
]
});
}

export async function aaplCloseDataTicks() {
const AAPL = await d3.csv<any>("data/aapl.csv", d3.autoType);
return Plot.plot({
Expand Down