[Feature] Crosshair label: a background box, and a way to paint it above the tooltip

オープン
#132 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript

調査の方向性

issue にはファイル名もテスト名も記載されていません。まず crosshair ラベルの renderer と SVG/export パスを見つけ、次に関連するテストを確認してください。ボックスが設定されていない場合に halo をデフォルトとして維持しながら、ラベルが要求された角丸背景のオプションをレンダリングできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version: reported on @tanstack/charts 0.16.0; still absent in 1.1.0 (57774e1).

crosshair({ x: { label } }) renders the axis label as two <text> nodes: a stroked halo (stroke, strokeWidth, strokeOpacity, round joins) beneath the filled text. That is right for a label over gridlines, but a common tooltip idiom is a "date pill": the focused x value in a rounded box with its own background, padding: 4px 16px, border-radius: 9999px, and a contrasting text colour (Recharts users hand-roll this, Nivo's crosshair has none, ECharts axisPointer.label ships backgroundColor, padding, borderRadius).

Migrating such a component with the halo alone leaves a glyph-shaped blob: with fontSize: 14, strokeWidth: 20 the halo measures 62×30 px where the box was 77×32 px, and the outline follows the letter shapes instead of a rounded rectangle. strokeWidth trades width against height, so no value reproduces the box, and there is no way to give the label horizontal padding different from vertical.

Would it be possible to add a background (or box) option to the crosshair label — fill, fillOpacity, padding (number or { x, y }), radius, stroke — rendered as a <rect> sized from the measured text and emitted through the same SVG/export path as the halo? The halo could stay as the default when no box is set.

Paint order (moved here from #188 C)

The same pill also has to sit above the tooltip, which it cannot today:

  • Guide labels are SVG nodes in g.ts-chart__focus-guide-layer--under|over (svg-renderer.ts:81). placement only orders them against marks (scene.ts:422-425).
  • The tooltip is an HTML element appended after the SVG (tooltip.ts:176) with z-index: 1 (tooltip.ts:419-421), so it covers all SVG content.
  • Not testable in jsdom (needs layout).

Expected: an opt-in way to paint the crosshair label above the tooltip. An HTML label layer would give both the box and the order; a tooltip layer option would give the order alone.

主要言語
TypeScript
スター
870
フォーク
57
平均マージ
11時間 58分
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/charts のほかの issue

TanStack/charts の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。