@topgrid/grid-pro-chart
Pro: Sparkline cells (zero-dep SVG) + injectable Range Chart panel · 상용 (EULA)
이 페이지는 소스 코드의 TSDoc 주석에서 자동 생성됩니다(내부 표식 정제). 큐레이트된 시작용 요약은 API 레퍼런스 참고.
총 24개 public export — 함수 6 · 훅 0 · 컴포넌트 4 · 타입 14 · 상수 0.
컴포넌트
ChartCard
RangeChart wrapped with an interactive type-switcher toolbar.
The toolbar buttons use inline styles (not Tailwind) so they are testable in the Tailwind-less
storybook harness (P27-1) and visibly reflect the active type via aria-pressed. Clicking a
button re-renders the chart with the new type — the chart shape genuinely changes
(data-chart-type), which is the non-vacuous claim the gate checks.
ChartCard(__namedParameters: ChartCardProps): Element
RangeChart
Built-in cartesian range chart — pure SVG, zero chart-library dependency (/AP-001).
Layout/scaling is delegated to computeChartGeometry (the node-tested core); this
component turns the computed pixel coordinates into <rect>/<polyline>/<polygon>/axis
elements, plus an in-SVG legend and hover tooltip (kept INSIDE the <svg> — no HTML overlay —
to stay consistent with the pure-SVG decision and avoid a wrapper-positioning refactor).
RangeChart(__namedParameters: RangeChartProps): Element
RangeChartPanel
Range chart panel — renders an injected chart for one or more numeric series.
This package bundles no charting library; the caller supplies renderChart
(adapter injection, / AP-001). Without a valid Pro license a watermark
is composited over the panel (the root is relative so the absolutely
positioned <Watermark> anchors to it).
RangeChartPanel(__namedParameters: RangeChartPanelProps): Element
SparklineCell
Sparkline cell — compact inline SVG chart for a numeric series.
Library-agnostic and zero-dependency: the chart is drawn with native SVG
<polyline>/<polygon>/<rect> elements, so no charting peer is required
( / AP-001 — the package imports no chart library).
SparklineCell(__namedParameters: SparklineCellProps): Element
함수
bandScale
Band scale over [r0,r1] for count categories. paddingRatio (0..1) is the fraction of each
slot left empty as gap. Bars/vertices sit at band centres, evenly spaced and symmetric within
the range.
bandScale(count: number, range: [number, number], paddingRatio: number): BandScale
computeChartGeometry
Compute the full pixel geometry for a cartesian (line/bar) chart from raw series.
- y domain is the niced range of ALL finite values across ALL series, so axis ticks land on round numbers and every series shares one scale (comparable).
- x is a band scale over the longest series' length.
- Non-finite values (NaN/±Infinity) keep their slot index but are omitted from
points(a gap), never silently shifting later points left.
computeChartGeometry(seriesList: ChartSeries[], opts: { … }): ChartGeometry
linearScale
Linear scale mapping domain → range. A flat domain (d0===d1) maps everything to the range
midpoint (so a constant series draws a centred flat line, never a divide-by-zero).
linearScale(domain: [number, number], range: [number, number]): LinearScale
niceTicks
"Nice" round tick values covering [min,max] with roughly count intervals. The returned array
starts ≤ min and ends ≥ max (the niced domain), with a round step (1/2/5 × 10ⁿ). A flat input
(min===max) returns a single tick; non-finite input returns [].
niceTicks(min: number, max: number, count: number): number[]
seriesFromMatrix
Turn a labelled 2-D matrix into chart series + x categories.
Orientation decides the pivot of the data: charting a 3-region × 2-quarter matrix 'columns'
gives one series per quarter across regions; 'rows' gives one series per region across quarters.
Same numbers, transposed grouping — the bug this guards is silently charting the wrong axis.
seriesFromMatrix(input: MatrixInput): MatrixChartData
seriesFromPivot
Reduce a pivot result into chart series — pure, node-testable.
★ This is the REAL pivot→chart adapter (not a hand-fed matrix): it keeps only __kind==='data'
rows (dropping subtotal/grandTotal), labels each by its row-dimension values, and reads each leaf
column's value cell <leafKey>__<valueIndex> into the matrix — then defers to
seriesFromMatrix. One measure at a time (valueIndex, default 0); multi-measure charting
is a caller choice (call once per index).
seriesFromPivot(model: PivotLike, opts: { … }): MatrixChartData