more logical zero value tooltip position#562
Conversation
✅ Deploy Preview for svelteplot ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ljodea
left a comment
There was a problem hiding this comment.
Investigation summary
Validated #561 against main. The root cause is the truthy check on tooltipX / tooltipY in HTMLTooltip.svelte (lines 102–103): when a datum has x === 0 or y === 0, the ternary falls through to 0px instead of the projected position. Datum selection is unaffected; only CSS positioning is wrong.
The ?? 0 fix in this PR is correct and minimal. Hidden-tooltip behavior is unchanged.
Approving the fix. One gap before merge: please add regression tests in packages/svelteplot/tests/htmltooltip.test.svelte.ts (existing harness covers datum selection but not position styles).
Requested tests
-
y = 0 — data
[{ x: 50, y: 0 }], plotwidth=200 height=100, domains[0, 100]. Hover near the projected point and asserttooltip.style.topis not'0px'and is close to100(bottom of plot). -
x = 0 with centered domain — data
[{ x: 0, y: 50 }],x.domain = [-50, 50]. Hover at center and asserttooltip.style.leftis not'0px'and is close to100.
These fail on main and pass with this fix — good TDD coverage for the falsy-zero case.
|
@bothness Thanks again for the fix! When you have a moment, could you add the two regression tests from the review? Happy to push them onto this branch if you’d prefer, just say the word. |
This PR fixes an issue with the HTMLTooltip position when the X or Y datum value is exactly zero.
Related issue #561