Skip to content

Commit be598d9

Browse files
committed
merge #1517 and fix http://localhost:8009/?test=federalFunds
1 parent 6322597 commit be598d9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/marks/axis.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ function axisKy(
146146
this.frameAnchor = `${cla}-${anchor}`;
147147
this.rotate = 0;
148148
}
149-
this.dy = cla === "top" ? 3 - marginTop + inset : cla === "bottom" ? marginBottom - 3 - inset : inset;
150-
this.dx = anchor === "right" ? clo : -clo;
149+
this.dy =
150+
(options.dy ?? 0) +
151+
(cla === "top" ? 3 - marginTop + inset : cla === "bottom" ? marginBottom - 3 - inset : inset);
152+
this.dx = (options.dx ?? 0) + (anchor === "right" ? clo : -clo);
151153
this.ariaLabel = `${k}-axis label`;
152154
return {
153155
facets: [[0]],
@@ -247,8 +249,10 @@ function axisKx(
247249
this.textAnchor = cla === "right" ? "end" : "start";
248250
}
249251
this.lineAnchor = anchor;
250-
this.dy = anchor === "top" ? -clo : clo;
251-
this.dx = cla === "right" ? marginRight - 3 - inset : cla === "left" ? 3 - marginLeft + inset : inset;
252+
this.dy = (options.dy ?? 0) + (anchor === "top" ? -clo : clo);
253+
this.dx =
254+
(options.dx ?? 0) +
255+
(cla === "right" ? marginRight - 3 - inset : cla === "left" ? 3 - marginLeft + inset : inset);
252256
this.ariaLabel = `${k}-axis label`;
253257
return {
254258
facets: [[0]],

test/plots/federal-funds.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export async function federalFunds() {
1313
tickSize: 0, // don’t draw ticks
1414
dx: 32, // offset right
1515
dy: -6, // offset up
16+
labelOffset: 29, // compensate label offset,
17+
inset: 6,
1618
lineAnchor: "bottom", // draw labels above grid lines
1719
tickFormat: (d) => (d === 10 ? `${d}%` : `${d} `) // right-align numbers, not %
1820
}),

0 commit comments

Comments
 (0)