Skip to content

Commit 99c8995

Browse files
authored
only truncate the long visible text, not the title (#1913)
1 parent 7452deb commit 99c8995

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/marks/tip.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export class Tip extends Mark {
189189
const [k] = cut(value, w - widthof(label), widthof, ee);
190190
if (k >= 0) {
191191
// value is truncated
192-
value = value.slice(0, k).trimEnd() + ellipsis;
193192
title = value.trim();
193+
value = value.slice(0, k).trimEnd() + ellipsis;
194194
}
195195
}
196196
const line = selection.append("tspan").attr("x", 0).attr("dy", `${lineHeight}em`).text("\u200b"); // zwsp for double-click

test/output/tipLongText.svg

Lines changed: 31 additions & 0 deletions
Loading

test/plots/tip.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ export async function tipLineY() {
181181
return Plot.lineY(aapl, {x: "Date", y: "Close", tip: true}).plot();
182182
}
183183

184+
export async function tipLongText() {
185+
return Plot.tip([{x: "Long sentence that gets cropped after a certain length"}], {x: "x"}).plot();
186+
}
187+
184188
export async function tipNewLines() {
185189
return Plot.plot({
186190
height: 40,

0 commit comments

Comments
 (0)