Skip to content
Draft

fit tip #2388

Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion src/marks/tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,15 @@ export class Tip extends Mark {
: fitTop && fitBottom
? fitLeft
? "left"
: "right"
: fitRight
? "right"
: "bottom"
: (fitLeft || fitRight) && (fitTop || fitBottom)
? `${fitBottom ? "bottom" : "top"}-${fitLeft ? "left" : "right"}`
: fitLeft
? "left"
: fitRight
? "right"
: mark.preferredAnchor;
}
const path = this.firstChild; // note: assumes exactly two children!
Expand Down
50 changes: 50 additions & 0 deletions test/output/tipAnchorOverflow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions test/plots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ export * from "./text-overflow.js";
export * from "./this-is-just-to-say.js";
export * from "./tick-format.js";
export * from "./time-axis.js";
export * from "./tip-anchor-overflow.js";
export * from "./tip-format.js";
export * from "./tip.js";
export * from "./title.js";
Expand Down
11 changes: 11 additions & 0 deletions test/plots/tip-anchor-overflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Plot from "@observablehq/plot";

export async function tipAnchorOverflow() {
return Plot.rectX([1, 1, 1, 1, 1], {
x: Plot.identity,
fill: Plot.indexOf,
title: () =>
"Lorem ipsum lorem ipsum lorem ipsum Lorem ipsum lorem ipsum lorem ipsum Lorem ipsum lorem ipsum lorem ipsum",
tip: true
}).plot({height: 100, marginTop: 20});
}
Loading