[Feature] Expose the focus position to the host: CSS variables on the root, plot-space pointer in `onFocusChange`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- d3, typescript
调研方向
Start with packages/charts-core/src/renderer.ts, especially notifyFocus and sameFocusObservation, which the issue identifies as the focus notification and deduplication points. Trace how the renderer resolves pointer positions and how tooltip positions are represented before deciding where to expose them. Done means an opt-in can expose focus index and plot coordinates on the chart root, clear them when focus ends, and report pointer position through the focus callback or a new pointer callback.
由索引模型根据 Issue 内容生成。
描述
Version: @tanstack/charts 1.1.0 (57774e1).
Today the focused point is only available through onFocusChange. Styling something from focus, such as fading axis ticks near the hovered x or dimming the other bars, means writing the value yourself on every focus change from that callback.
We do exactly this in a chart migration: the host sets --hover-x and its siblings on the chart root, and CSS reads them. It works, but each chart has to wire the same callback-to-style plumbing, and the write happens on a separate path from the library's own focus paint.
Ask: an opt-in to have the renderer set the focused datum's index and position on the chart root, for example data-focus-index and --ts-focus-x/--ts-focus-y in plot coordinates, and clear them when focus ends. That would let charts style focus from CSS alone, without a scene rebuild or extra JS per move.
Checked against 57774e14a1a86081eddb3a23523724a40da05640 (v1.1.0).
The pointer position is never reported (moved here from #190's comment)
notifyFocus calls onFocusChange only when the primary point's (key, markId, datumIndex) or Object.is(datum) changes (renderer.ts:561-581, sameFocusObservation at renderer.ts:1404-1416). Moves inside one point's hit region produce no callback, and the callback carries no coordinates.
Example: a live line chart whose crosshair and pill follow the raw pointer x between samples cannot get that x from the focus pipeline. It needs a separate pointermove listener on the container, and it then has to convert client coordinates to plot space itself.
Proposal: pass the resolved pointer position (plot-space x/y, or the ChartTooltipPosition already used for tooltips) as a second argument to onFocusChange, or add an opt-in onPointerMove with scene coordinates. This does not conflict with the dedupe in #178; it only adds data to the call that already happens. The CSS variables above would be filled from the same position.
- 主要语言
- TypeScript
- 星标
- 870
- 派生
- 57
- 平均合并
- 11 小时 58 分钟
- 30 天内合并 PR
- 18
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/charts 的其他 Issue
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per node未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`可能已有人在做 @getdownandcode 于 37 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Add reverse options to waffleY and waffleX可能已有人在做 @tannerlinsley 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复