Skip to content

Fix viewer tooltip clipped at top of viewport (#282) - #283

Merged
emeryberger merged 3 commits into
masterfrom
fix-282-tooltip-cutoff
Jul 8, 2026
Merged

Fix viewer tooltip clipped at top of viewport (#282)#283
emeryberger merged 3 commits into
masterfrom
fix-282-tooltip-cutoff

Conversation

@emeryberger

Copy link
Copy Markdown
Member

Summary

Fixes #282 — tooltips in the coz plot viewer were cut off at the top edge when hovering over data points high on the screen.

Root cause

In viewer/ts/profile.ts the d3-tip tooltip direction was hardcoded to 'n' (above the point) unless speedup > 0.8. For any point near the top of the viewport, placing the tooltip above it pushed it off-screen. The static .direction() callback could not fix this because inside it this is the tip object (not the hovered circle), so it had no access to the point's screen position.

Fix

Decide the tooltip direction inside the mouseover handler, where this is the hovered <circle>, using its real screen position via getBoundingClientRect():

  • Within ~80px of the viewport top → place tooltip below ('s')
  • Else near the right edge (speedup > 0.8) → place it left ('w', previous behavior)
  • Otherwise → above ('n', as before)

The offset is adjusted per direction so the gap/arrow stays correct.

Recompiled the committed viewer/js/profile.js from the TypeScript source (tsc -p tsconfig.json).

Testing

Viewer-only, browser-side change. Verified tsc builds cleanly and the compiled JS contains the new logic. Confirm visually with coz plot by hovering a point in a top-row plot — the tooltip now flips below the point instead of being clipped.

🤖 Generated with Claude Code

emeryberger and others added 3 commits April 19, 2026 11:42
Add documentation for the `coz suggest-points` subcommand (LLM tool-use
agent that proposes progress point placements), the macOS-specific
architecture (`mac_interpose.cpp`, `macho_support.cpp`, `lief_loader.cpp`,
DYLD interposition, dSYM lookup, wall-clock timer handling, nanosleep
overshoot tracking), and the `path_filter.h` Rust stdlib filter.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Tooltips were placed above the hovered point ('n') by default, so points
near the top of the viewport had their tooltip cut off at the top edge.

Decide the tooltip direction from the circle's actual screen position in
the mouseover handler (where `this` is the hovered element) instead of the
static .direction() callback (where only the datum is available): flip to
'south' when the point is near the top, keep 'west' near the right edge,
otherwise 'north'. Offsets are adjusted per direction.

Recompiled viewer/js/profile.js from the TypeScript source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@emeryberger
emeryberger merged commit ba2e79e into master Jul 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Tooltip is cut off at the top

1 participant