Skip to content

Place touch tooltips above the finger - #927

Merged
techniq merged 7 commits into
mainfrom
techniq/tooltip-increase-default-x-y-offset-on-mobile-to
Oct 13, 2026
Merged

techniq merged 7 commits into
mainfrom
techniq/tooltip-increase-default-x-y-offset-on-mobile-to

Conversation

@techniq

@techniq techniq commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Resolves #485

@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c477828

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
layerchart Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Clamp tooltip placement to the visual viewport so zoomed pages do not place it off screen
- Apply touch-style above-pointer placement to pen input as well as fingers
@techniq
techniq force-pushed the techniq/tooltip-increase-default-x-y-offset-on-mobile-to branch from 0cbf9a0 to 5059972 Compare October 2, 2026 21:11
@pkg-pr-new

pkg-pr-new Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/layerchart@927

commit: c477828

@techniq

techniq commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

@ntainy (continued conversation from: #924 (comment))

Great feedback! I made those changes here (including the rebase). When you get a chance, could you see how these work for you? Thanks!

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
layerchart ✅ Ready (View Log) Visit Preview c477828

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

⚠️ Warnings (1 significant size increase)

Item Current New Change
🔴 Tooltip 152.60 KB
37.13 gz
155.39 KB
37.85 gz
+2.78 KB (+1.8%)
+0.72 gz (+1.9%)

Use-Case Scenarios

Core (7 changed)
Scenario Current New Change
🟡 core-canvas 241.12 KB
62.34 gz
241.44 KB
62.40 gz
+0.32 KB (+0.1%)
+0.06 gz (+0.1%)
🟡 core-line 240.18 KB
61.15 gz
240.50 KB
61.24 gz
+0.32 KB (+0.1%)
+0.08 gz (+0.1%)
🟡 core-scatter 232.77 KB
58.97 gz
233.09 KB
59.05 gz
+0.32 KB (+0.1%)
+0.08 gz (+0.1%)
🟡 core-geo 226.14 KB
58.02 gz
226.46 KB
58.06 gz
+0.32 KB (+0.1%)
+0.04 gz (+0.1%)
🟡 core-html 225.44 KB
57.56 gz
225.76 KB
57.64 gz
+0.32 KB (+0.1%)
+0.08 gz (+0.1%)
🟡 core-svg 223.49 KB
57.09 gz
223.81 KB
57.17 gz
+0.32 KB (+0.1%)
+0.07 gz (+0.1%)
🟡 core 223.48 KB
56.94 gz
223.80 KB
56.98 gz
+0.32 KB (+0.1%)
+0.04 gz (+0.1%)
Base (agnostic) (4 changed)
Scenario Current New Change
🟡 base-svg-agnostic 383.17 KB
89.22 gz
384.13 KB
89.47 gz
+0.96 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 base-canvas-agnostic 383.17 KB
89.22 gz
384.13 KB
89.48 gz
+0.96 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 base-html-agnostic 383.17 KB
89.22 gz
384.13 KB
89.48 gz
+0.96 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 base 383.16 KB
89.22 gz
384.13 KB
89.47 gz
+0.96 KB (+0.3%)
+0.25 gz (+0.3%)
Base (layer-specific) (3 changed)
Scenario Current New Change
🟡 base-canvas 370.41 KB
86.60 gz
371.30 KB
86.86 gz
+0.89 KB (+0.2%)
+0.26 gz (+0.3%)
🟡 base-html 362.20 KB
84.08 gz
363.08 KB
84.33 gz
+0.88 KB (+0.2%)
+0.24 gz (+0.3%)
🟡 base-svg 360.29 KB
83.65 gz
361.17 KB
83.88 gz
+0.88 KB (+0.2%)
+0.23 gz (+0.3%)
Cartesian charts (27 changed)
Scenario Current New Change
🟡 PieChart 426.03 KB
98.48 gz
429.58 KB
99.32 gz
+3.54 KB (+0.8%)
+0.84 gz (+0.9%)
🟡 ArcChart 419.05 KB
97.11 gz
422.59 KB
98.00 gz
+3.54 KB (+0.8%)
+0.89 gz (+0.9%)
🟡 LineChart 414.44 KB
96.58 gz
415.48 KB
96.81 gz
+1.04 KB (+0.3%)
+0.24 gz (+0.2%)
🟡 PieChart-canvas 411.29 KB
95.44 gz
414.76 KB
96.39 gz
+3.47 KB (+0.8%)
+0.95 gz (+1.0%)
🟡 ArcChart-canvas 404.88 KB
94.21 gz
408.35 KB
95.12 gz
+3.47 KB (+0.9%)
+0.91 gz (+1.0%)
🟡 AreaChart 406.75 KB
94.28 gz
407.79 KB
94.55 gz
+1.04 KB (+0.3%)
+0.27 gz (+0.3%)
🟡 PieChart-svg 401.33 KB
92.65 gz
404.80 KB
93.54 gz
+3.47 KB (+0.9%)
+0.89 gz (+1.0%)
🟡 line-chart-interactive 400.37 KB
93.06 gz
403.84 KB
93.95 gz
+3.46 KB (+0.9%)
+0.89 gz (+1.0%)
🟡 area-chart 402.15 KB
93.25 gz
403.11 KB
93.51 gz
+0.96 KB (+0.2%)
+0.26 gz (+0.3%)
🟡 ArcChart-svg 394.91 KB
91.31 gz
398.38 KB
92.20 gz
+3.47 KB (+0.9%)
+0.89 gz (+1.0%)
🟡 pie-chart 396.69 KB
92.20 gz
397.66 KB
92.44 gz
+0.96 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 BarChart 394.52 KB
91.60 gz
395.53 KB
91.84 gz
+1.01 KB (+0.3%)
+0.24 gz (+0.3%)
🟡 AreaChart-canvas 393.36 KB
91.55 gz
394.33 KB
91.85 gz
+0.97 KB (+0.2%)
+0.29 gz (+0.3%)
🟡 bar-chart 388.46 KB
90.31 gz
389.42 KB
90.55 gz
+0.96 KB (+0.2%)
+0.24 gz (+0.3%)
🟡 ScatterChart 388.02 KB
90.28 gz
389.07 KB
90.56 gz
+1.04 KB (+0.3%)
+0.28 gz (+0.3%)
🟡 scatter-chart 384.25 KB
89.51 gz
385.22 KB
89.74 gz
+0.97 KB (+0.3%)
+0.24 gz (+0.3%)
🟡 line-chart 383.66 KB
89.27 gz
384.63 KB
89.52 gz
+0.96 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 AreaChart-svg 383.25 KB
88.58 gz
384.22 KB
88.83 gz
+0.97 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 BarChart-canvas 380.81 KB
88.81 gz
381.75 KB
89.07 gz
+0.94 KB (+0.2%)
+0.26 gz (+0.3%)
🟡 LineChart-canvas 377.39 KB
88.15 gz
378.36 KB
88.40 gz
+0.97 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 ScatterChart-canvas 374.54 KB
87.46 gz
375.51 KB
87.71 gz
+0.97 KB (+0.3%)
+0.25 gz (+0.3%)
🟡 BarChart-svg 370.71 KB
85.85 gz
371.64 KB
86.09 gz
+0.93 KB (+0.3%)
+0.23 gz (+0.3%)
🟡 line-chart-canvas 370.44 KB
86.62 gz
371.33 KB
86.87 gz
+0.89 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 LineChart-svg 367.29 KB
85.20 gz
368.25 KB
85.48 gz
+0.96 KB (+0.3%)
+0.28 gz (+0.3%)
🟡 ScatterChart-svg 364.43 KB
84.49 gz
365.40 KB
84.75 gz
+0.97 KB (+0.3%)
+0.26 gz (+0.3%)
🟡 line-chart-html 362.22 KB
84.09 gz
363.10 KB
84.34 gz
+0.88 KB (+0.2%)
+0.24 gz (+0.3%)
🟡 line-chart-svg 360.31 KB
83.66 gz
361.20 KB
83.89 gz
+0.88 KB (+0.2%)
+0.23 gz (+0.3%)
Geo (3 changed)
Scenario Current New Change
🟡 geo-full 457.87 KB
108.59 gz
458.84 KB
108.83 gz
+0.97 KB (+0.2%)
+0.25 gz (+0.2%)
🟡 geo-tiles 405.42 KB
94.88 gz
406.38 KB
95.13 gz
+0.96 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 geo 400.30 KB
93.21 gz
401.27 KB
93.47 gz
+0.96 KB (+0.2%)
+0.26 gz (+0.3%)
Hierarchy (4 changed)
Scenario Current New Change
🟡 hierarchy-tree 393.95 KB
92.17 gz
394.91 KB
92.42 gz
+0.96 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 hierarchy-treemap 390.84 KB
91.38 gz
391.80 KB
91.64 gz
+0.96 KB (+0.2%)
+0.27 gz (+0.3%)
🟡 hierarchy-pack 390.25 KB
91.29 gz
391.21 KB
91.55 gz
+0.96 KB (+0.2%)
+0.26 gz (+0.3%)
🟡 dodge 387.97 KB
90.64 gz
388.94 KB
90.92 gz
+0.96 KB (+0.2%)
+0.29 gz (+0.3%)
Graph / network (4 changed)
Scenario Current New Change
🟡 dagre 452.77 KB
108.20 gz
453.73 KB
108.41 gz
+0.96 KB (+0.2%)
+0.21 gz (+0.2%)
🟡 force 396.37 KB
93.02 gz
397.33 KB
93.27 gz
+0.96 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 sankey 396.16 KB
92.36 gz
397.11 KB
92.61 gz
+0.95 KB (+0.2%)
+0.25 gz (+0.3%)
🟡 chord 392.84 KB
91.43 gz
393.80 KB
91.68 gz
+0.96 KB (+0.2%)
+0.25 gz (+0.3%)
Components (15 changed)
Scenario Current New Change
🟡 Axis 216.22 KB
49.27 gz
216.76 KB
49.43 gz
+0.54 KB (+0.2%)
+0.16 gz (+0.3%)
🟡 AnnotationPoint 197.88 KB
48.25 gz
198.15 KB
48.31 gz
+0.27 KB (+0.1%)
+0.07 gz (+0.1%)
🟡 Axis.svg 185.95 KB
43.00 gz
186.49 KB
43.15 gz
+0.54 KB (+0.3%)
+0.15 gz (+0.4%)
🟡 Axis.canvas 184.08 KB
42.82 gz
184.62 KB
42.96 gz
+0.54 KB (+0.3%)
+0.14 gz (+0.3%)
🟡 Axis.html 180.38 KB
41.62 gz
180.92 KB
41.77 gz
+0.54 KB (+0.3%)
+0.15 gz (+0.4%)
🟡 AnnotationPoint.svg 173.56 KB
42.90 gz
173.84 KB
42.98 gz
+0.27 KB (+0.2%)
+0.08 gz (+0.2%)
🟡 AnnotationRange 167.22 KB
39.61 gz
167.39 KB
39.64 gz
+0.17 KB (+0.1%)
+0.04 gz (+0.1%)
🟡 AnnotationPoint.canvas 163.00 KB
40.97 gz
163.28 KB
41.05 gz
+0.28 KB (+0.2%)
+0.08 gz (+0.2%)
🔴 Tooltip 152.60 KB
37.13 gz
155.39 KB
37.85 gz
+2.78 KB (+1.8%)
+0.72 gz (+1.9%)
🟡 AnnotationLine 148.37 KB
35.98 gz
148.52 KB
36.00 gz
+0.15 KB (+0.1%)
+0.02 gz (+0.1%)
🟡 AnnotationRange.svg 139.03 KB
33.29 gz
139.19 KB
33.33 gz
+0.17 KB (+0.1%)
+0.04 gz (+0.1%)
🟡 AnnotationRange.canvas 137.77 KB
33.76 gz
137.96 KB
33.83 gz
+0.19 KB (+0.1%)
+0.08 gz (+0.2%)
🟡 AnnotationLine.svg 127.17 KB
30.77 gz
127.31 KB
30.78 gz
+0.14 KB (+0.1%)
+0.01 gz (+0.0%)
🟡 AnnotationLine.canvas 126.64 KB
31.27 gz
126.78 KB
31.30 gz
+0.14 KB (+0.1%)
+0.03 gz (+0.1%)
🟡 Layer 119.61 KB
28.97 gz
119.68 KB
28.97 gz
+0.07 KB (+0.1%)
-0.00 gz (-0.0%)
Worst case (1 changed)
Scenario Current New Change
🟡 all 1111.64 KB
262.54 gz
1116.13 KB
263.55 gz
+4.49 KB (+0.4%)
+1.01 gz (+0.4%)

Understanding this report
  • Use-case scenarios measure the bundle cost of common chart configurations (e.g. a line chart with axes)
  • Individual components measure each component imported in isolation
  • Svelte runtime is excluded; sizes reflect layerchart + its dependencies (d3, etc.)
  • When multiple components share dependencies (e.g. d3-scale), the real-world cost is lower than the sum of individual sizes
  • Changes smaller than 10 bytes or 0.1% are considered insignificant

@ntainy

ntainy commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

hi, sorry for the slow reply, got buried for a bit

pulled and tested properly (arc/chromium at 360px vs 2.5.1). works really really well!

  • touch/pen: visualViewport top actually is much nicer than what i initially suggested, it's much better, didn't see a single issue there (is properly above the finger and clamped)
  • mouse seems identical
  • pinch thing: works perfectly (stays inside), zooming while locked properly repositions itself as ewll.

the only thing noticeable (not a regression though) is that with default contained container, if the box is wider than the container in the first place (minus y axis gutter), visibleBounds falls back to the container and so the left clamp wins, so on a 360px phone 310px box ended up still past the right edge even though it would have fit on the screen. idk what's the right solution for that would be -- maybe for portaled tooltips fall back to the visible viewport before the container? though a good moment to +1 again for making the contained window default in v3 as it doesn't have this issue :)

couple small additional things that were noticed by an agent in a separate pass:

  • pinch re-placement only subscribes when portaled, so portal={false} + window won't follow a pinch
  • facetAll panels get anchor="bottom" passed explicitly, so they don't get the "rise above the chart" min
  • maybe worth adding a test for touch + contained="window"?

Thanks again! and sorry for such a huge delay

ps: also I didnt check ios safari, so I still have no clue how it would look there

@techniq

techniq commented Oct 12, 2026

Copy link
Copy Markdown
Owner Author

Great feedback, and no worries!

I've addressed all of these, and also noticed when pinch-zoomed the position of the tooltip was incorrect (and fixed as well).

I did a good bit of testing on my iPhone, but would love 1 more check before I merge and release,

@techniq
techniq merged commit a92dea6 into main Oct 13, 2026
10 checks passed
@techniq
techniq deleted the techniq/tooltip-increase-default-x-y-offset-on-mobile-to branch October 13, 2026 13:17
@github-actions github-actions Bot mentioned this pull request Oct 13, 2026

This branch was successfully deployed

1 active deployment
Preview — c4778286 Deployed Oct 13, 2026 by github-actions[bot]
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.

[Tooltip] Increase default x/y offset on mobile / touch

2 participants