Skip to content

Commit 9c26f10

Browse files
committed
fix f[xy] tooltip
1 parent 0486d24 commit 9c26f10

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/marks/tooltip.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ export class Tooltip extends Mark {
3939
this.indexesBySvg.set(svg, (indexes = [index]));
4040
const dot = select(svg)
4141
.on("pointermove", (event) => {
42-
let i, xi, yi;
42+
let i, xi, yi, fxi, fyi;
4343
if (event.buttons === 0) {
4444
const [xp, yp] = pointer(event);
4545
let ri = maxRadius * maxRadius;
4646
for (const index of indexes) {
47-
const fxj = fx(index.fx);
48-
const fyj = fy(index.fy);
47+
const oxj = fx(index.fx) - marginLeft;
48+
const oyj = fy(index.fy) - marginTop;
4949
for (const j of index) {
50-
const xj = fxj + X[j] - marginLeft;
51-
const yj = fyj + Y[j] - marginTop;
50+
const xj = X[j] + oxj;
51+
const yj = Y[j] + oyj;
5252
const dx = xj - xp;
5353
const dy = yj - yp;
5454
const rj = dx * dx + dy * dy;
55-
if (rj <= ri) (i = j), (ri = rj), (xi = xj), (yi = yj);
55+
if (rj <= ri) (i = j), (ri = rj), (xi = xj), (yi = yj), (fxi = index.fx), (fyi = index.fy);
5656
}
5757
}
5858
}
@@ -65,8 +65,8 @@ export class Tooltip extends Mark {
6565
[
6666
`${x.label ?? "x"} = ${raw.x[i]}`,
6767
`${y.label ?? "y"} = ${raw.y[i]}`,
68-
`${fx.label ?? "fx"} = ${raw.fx[i]}`,
69-
`${fy.label ?? "fy"} = ${raw.fy[i]}`
68+
`${fx.label ?? "fx"} = ${fxi}`,
69+
`${fy.label ?? "fy"} = ${fyi}`
7070
].join("\n")
7171
);
7272
}

0 commit comments

Comments
 (0)