basalt-ui 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/agent/rules/basalt-charts.md +28 -9
- package/agent/templates/CLAUDE-block.md.tpl +9 -6
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/kinds/Bars.d.ts +21 -8
- package/dist/charts/kinds/Bars.d.ts.map +1 -1
- package/dist/charts/kinds/Bars.js +6 -3
- package/dist/charts/kinds/Bars.test.d.ts +2 -0
- package/dist/charts/kinds/Bars.test.d.ts.map +1 -0
- package/dist/charts/kinds/DualPanel.d.ts +13 -0
- package/dist/charts/kinds/DualPanel.d.ts.map +1 -1
- package/dist/charts/kinds/DualPanel.js +55 -8
- package/dist/charts/kinds/DualPanel.test.d.ts +2 -0
- package/dist/charts/kinds/DualPanel.test.d.ts.map +1 -0
- package/dist/charts/kinds/MultiLine.d.ts.map +1 -1
- package/dist/charts/kinds/MultiLine.js +35 -25
- package/dist/charts/kinds/MultiLine.test.d.ts +2 -0
- package/dist/charts/kinds/MultiLine.test.d.ts.map +1 -0
- package/dist/charts/kinds/ZonedLine.d.ts.map +1 -1
- package/dist/charts/kinds/ZonedLine.js +1 -0
- package/dist/charts/kinds/ZonedLine.test.d.ts +2 -0
- package/dist/charts/kinds/ZonedLine.test.d.ts.map +1 -0
- package/dist/charts/primitives/CartesianChart.d.ts +22 -4
- package/dist/charts/primitives/CartesianChart.d.ts.map +1 -1
- package/dist/charts/primitives/CartesianChart.js +18 -8
- package/dist/charts/primitives/CartesianChart.test.d.ts.map +1 -1
- package/dist/charts/primitives/ChartLegend.d.ts +3 -0
- package/dist/charts/primitives/ChartLegend.d.ts.map +1 -1
- package/dist/charts/primitives/ChartLegend.js +4 -0
- package/dist/charts/primitives/XZoneRects.d.ts +22 -8
- package/dist/charts/primitives/XZoneRects.d.ts.map +1 -1
- package/dist/charts/primitives/XZoneRects.js +39 -2
- package/dist/charts/series.d.ts +12 -2
- package/dist/charts/series.d.ts.map +1 -1
- package/dist/charts/series.js +2 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/charts/index.ts +1 -0
- package/src/charts/kinds/Bars.test.tsx +98 -0
- package/src/charts/kinds/Bars.tsx +28 -12
- package/src/charts/kinds/DualPanel.test.tsx +131 -0
- package/src/charts/kinds/DualPanel.tsx +81 -9
- package/src/charts/kinds/MultiLine.test.tsx +37 -0
- package/src/charts/kinds/MultiLine.tsx +45 -28
- package/src/charts/kinds/ZonedLine.test.tsx +37 -0
- package/src/charts/kinds/ZonedLine.tsx +1 -0
- package/src/charts/primitives/{CartesianChart.test.ts → CartesianChart.test.tsx} +62 -1
- package/src/charts/primitives/CartesianChart.tsx +44 -12
- package/src/charts/primitives/ChartLegend.test.tsx +30 -0
- package/src/charts/primitives/ChartLegend.tsx +7 -0
- package/src/charts/primitives/XZoneRects.test.tsx +60 -0
- package/src/charts/primitives/XZoneRects.tsx +75 -10
- package/src/charts/series.test.ts +51 -0
- package/src/charts/series.ts +15 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.16.0](https://github.com/jkrumm/basalt-ui/compare/v1.15.0...v1.16.0) (2026-08-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* close the chart-API gaps the first full consumer migration found ([518a086](https://github.com/jkrumm/basalt-ui/commit/518a086e632c7c010584071f5780d7aa3bbe3bc2))
|
|
7
|
+
|
|
1
8
|
# [1.15.0](https://github.com/jkrumm/basalt-ui/compare/v1.14.0...v1.15.0) (2026-08-18)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -188,17 +188,21 @@ and its crosshair dots entirely):
|
|
|
188
188
|
|
|
189
189
|
- `label?: (d: T) => { text; color } | null` — a right-aligned badge in the header (a status label,
|
|
190
190
|
a zone name).
|
|
191
|
-
- `prependRows?: (d: T) => ReactNode` — rows rendered BEFORE the derived
|
|
192
|
-
context line).
|
|
193
|
-
|
|
191
|
+
- `prependRows?: (d: T, ctx: { visible; hidden }) => ReactNode` — rows rendered BEFORE the derived
|
|
192
|
+
per-series rows (a total, a context line). `ctx` is the same `visible`/`hidden` the plot itself
|
|
193
|
+
draws from, so a hand-authored row tracks legend toggling instead of desyncing from it.
|
|
194
|
+
- `extraRows?: (d: T, ctx: { visible; hidden }) => ReactNode` — rows appended after the derived
|
|
195
|
+
rows. Same `ctx` as `prependRows`.
|
|
194
196
|
- `follow?: boolean` — default `true`, the tooltip tracks the pointer. `follow: false` anchors it to
|
|
195
197
|
the crosshair at the plot's top edge instead, which reads better across a column of charts sharing
|
|
196
198
|
one cursor (every tooltip lines up on the same x). Anchoring costs one `getBoundingClientRect` per
|
|
197
199
|
hovered frame, which is why following is the default.
|
|
198
200
|
|
|
199
201
|
Per-series, `SeriesStyle.tooltip: false` means "draw the mark and legend it, but never give it a
|
|
200
|
-
tooltip row" — it lives on the series, not on the
|
|
201
|
-
|
|
202
|
+
tooltip row" — it lives on the series, not on the kind. `ChartSeries.formatValue` is
|
|
203
|
+
`(v: number, d: T) => string` — a row can cite the hovered datum, not just the plotted number (e.g.
|
|
204
|
+
`97.5 kg (92.5 × 3)`). `Bars` has its own per-key version of the opt-out: `BarsBar.tooltip: false` /
|
|
205
|
+
`BarsLine.tooltip: false` draws and legends a bar series without ever listing it as a tooltip row.
|
|
202
206
|
|
|
203
207
|
A **stacked** chart needs `cursorValue` too: `CartesianChart`'s crosshair dot defaults to
|
|
204
208
|
`series.getValue(point)`, which is correct for an unstacked line but puts a stacked band's dot at
|
|
@@ -259,8 +263,10 @@ per-series `getValue` accessors on `ChartSeries<T>`):
|
|
|
259
263
|
refLines, fixed or auto domain (covers z-score/σ via a fixed symmetric domain + zero refLine).
|
|
260
264
|
Composes `CartesianChart`.
|
|
261
265
|
- **`DualPanel`** — top line-pane + bottom signed-histogram pane sharing one x-scale and one cursor;
|
|
262
|
-
optional fill-between two top lines, zones, refLines
|
|
263
|
-
not one plot rect).
|
|
266
|
+
optional fill-between two top lines, zones, refLines, per-point markers on the top pane
|
|
267
|
+
(`ChartSeries.getMarker`). Composes `ChartFrame` directly (two panes, not one plot rect). The
|
|
268
|
+
bottom pane's tooltip row is `formatBar` (separate from `formatBottom`'s tick labels); its domain
|
|
269
|
+
is configurable via `bottomYDomain`/`bottomMaxAbsFloor`.
|
|
264
270
|
- **`Heatmap`** — category×category intensity grid (`color-mix` alpha), per-cell tooltip, optional
|
|
265
271
|
gradient legend strip. Composes `ChartFrame` directly; self-measures, no separate responsive
|
|
266
272
|
wrapper.
|
|
@@ -269,9 +275,13 @@ per-series `getValue` accessors on `ChartSeries<T>`):
|
|
|
269
275
|
|
|
270
276
|
`ZonedLine` and `MultiLine` also accept `xZones?: XZoneSpec[]` — the vertical counterpart to a
|
|
271
277
|
kind's horizontal zone bands, for marking a time window rather than a value range. Each
|
|
272
|
-
`{ from?, to?, fill }` bound is a `getX` **domain key** (the label string the kind's
|
|
278
|
+
`{ from?, to?, fill, align? }` bound is a `getX` **domain key** (the label string the kind's
|
|
273
279
|
`scalePoint<string>` runs over), not a date or timestamp. An omitted bound is the plot edge; a key
|
|
274
|
-
absent from the scale's domain skips that band entirely rather than clamping to an edge.
|
|
280
|
+
absent from the scale's domain skips that band entirely rather than clamping to an edge. `align`
|
|
281
|
+
defaults `'center'` (a present bound resolves to the point's own center, today's behaviour);
|
|
282
|
+
`align: 'edge'` widens by half a step at each present bound instead — a two-key band covers both
|
|
283
|
+
terminal slots in full, and `from === to` renders one step wide instead of being skipped as
|
|
284
|
+
degenerate. An edge-aligned bound is clamped into the plot range at the first/last sample.
|
|
275
285
|
|
|
276
286
|
How to add a chart:
|
|
277
287
|
|
|
@@ -307,9 +317,13 @@ y={{
|
|
|
307
317
|
ticks: 5,
|
|
308
318
|
format: (v) => `${v}%`,
|
|
309
319
|
grid: true, // horizontal grid rules; default on for `y`, off for `y2`
|
|
320
|
+
nice: false, // default false — opt in to d3's scale.nice() domain rounding
|
|
310
321
|
}}
|
|
311
322
|
```
|
|
312
323
|
|
|
324
|
+
`nice` defaults `false` deliberately: flipping the default would move the domain of every
|
|
325
|
+
already-migrated chart, so it's opt-in per axis.
|
|
326
|
+
|
|
313
327
|
**Passing `y2` is what makes a chart dual-axis** — it draws the right axis and widens the right
|
|
314
328
|
margin by measurement; nothing else flips it on. A series opts into that axis with `axis: 'right'`
|
|
315
329
|
on its `ChartSeries` entry (`SeriesStyle.axis`, default `'left'`).
|
|
@@ -342,6 +356,11 @@ A series that's invisible in the plot (flat at the domain floor, filtered to zer
|
|
|
342
356
|
an explanation: `SeriesStyle.note` (and so `LegendEntry.note`, via `deriveLegend`) renders a short
|
|
343
357
|
muted qualifier after the legend label — e.g. _"Low cloud — 0% all night"_. Keep it to a clause.
|
|
344
358
|
|
|
359
|
+
`SeriesStyle.strokeOpacity` dims the plotted stroke (e.g. a faint moving-average companion) — the
|
|
360
|
+
legend swatch honors it too, parity with `fillOpacity`. The tooltip-row swatch and the crosshair
|
|
361
|
+
dot deliberately do NOT honor it: a sub-1 opacity on a 12px value-readout chip reads as a rendering
|
|
362
|
+
bug, not as data.
|
|
363
|
+
|
|
345
364
|
## Dark/light mode
|
|
346
365
|
|
|
347
366
|
Theme reactivity is **pure CSS**: the `--vx-*` variables are redeclared under the light/dark color
|
|
@@ -8,12 +8,15 @@ or the `basalt-*` rules instead; manual changes here are overwritten on the next
|
|
|
8
8
|
|
|
9
9
|
**Stack:** React 19 + Mantine v9, themed by `basalt-ui` (`BasaltProvider` + `createBasaltTheme`).
|
|
10
10
|
Colors come from the three-tier `--vx-*` token system — read `VX.*` / a `defineSeries` token,
|
|
11
|
-
never a raw hex/`rgb()`/`hsl()`. Charts are visx via `basalt-ui/charts
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
never a raw hex/`rgb()`/`hsl()`. Charts are visx via `basalt-ui/charts`: every single-plot chart
|
|
12
|
+
composes `CartesianChart` (owns margins, scales, axes, grid, cursor, tooltip — draw only marks);
|
|
13
|
+
legends/tooltip rows are DERIVED from `series`, never hand-authored (`basalt/hand-rolled-plot` +
|
|
14
|
+
`basalt/chart-legend-literal` enforce both); `DualPanel`/`Donut`/`Heatmap` are the declared
|
|
15
|
+
exceptions. Add a kind on the third repeat, don't loosen the primitives. `basalt-ui/charts` and
|
|
16
|
+
`basalt-ui/tokens` are Mantine-free internally (a framework invariant, not something your own app
|
|
17
|
+
code must follow) — never import `@visx/*` outside a `charts/` directory (oxlint-enforced).
|
|
18
|
+
Toolchain is oxlint + oxfmt (no ESLint/Biome/Prettier) and `basalt-ui check-theme` guards the
|
|
19
|
+
palette. Runtime is Bun.
|
|
17
20
|
|
|
18
21
|
**Before guessing an import, check the installed package's machine docs**:
|
|
19
22
|
`node_modules/basalt-ui/llms.txt` (per-subpath import map), `node_modules/basalt-ui/AGENTS.md`, or
|
package/dist/charts/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { VxThemeProvider, useVxTheme, type VxTheme } from './theme.js';
|
|
|
16
16
|
export { ChartCursorScope, type ChartCursorScopeProps, useCursorState } from './cursor/scope.js';
|
|
17
17
|
export { createCursorStore, globalCursorStore, type CursorState, type CursorStore, } from './cursor/store.js';
|
|
18
18
|
export { type SeriesMark, type SeriesDash, type SeriesRole, type LegendPlacement, type ChartLegendConfig, type SeriesStyle, type ChartSeries, deriveLegend, deriveTooltipRows, } from './series.js';
|
|
19
|
-
export { CartesianChart, resolveAxisDomain, type CartesianChartProps, type CartesianTooltipConfig, type AxisConfig, type PlotContext, } from './primitives/CartesianChart.js';
|
|
19
|
+
export { CartesianChart, resolveAxisDomain, type CartesianChartProps, type CartesianTooltipConfig, type CartesianTooltipRowContext, type AxisConfig, type PlotContext, } from './primitives/CartesianChart.js';
|
|
20
20
|
export { ChartFrame, type ChartFrameProps, type ChartFrameLegend, type PlotRect, resolveLegend, } from './primitives/ChartFrame.js';
|
|
21
21
|
export { ChartCenter, type ChartCenterProps, ChartPending, type ChartPendingProps, } from './primitives/ChartPending.js';
|
|
22
22
|
export { Crosshair, SeriesDot } from './primitives/Crosshair.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/charts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,EAAE,EACF,KAAK,EACL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,KAAK,WAAW,GACjB,MAAM,WAAW,CAAA;AAGlB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG5C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC7F,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,YAAY,EACZ,iBAAiB,GAClB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,aAAa,GACd,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,YAAY,E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,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG5D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAM1D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,aAAa,CAAA"}
|
|
@@ -2,7 +2,12 @@ import type { ChartMargin } from '../../tokens/index.js';
|
|
|
2
2
|
import type { AxisConfig, CartesianTooltipConfig } from '../primitives/CartesianChart.js';
|
|
3
3
|
import type { ZoneSpec } from '../primitives/ZoneRects.js';
|
|
4
4
|
import type { ChartLegendConfig } from '../series.js';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `T = unknown` is load-bearing, not a shortcut: it keeps a consumer's existing
|
|
7
|
+
* `const bars: BarsBar[] = [...]` compiling (and still assignable to `BarsBar<Row>[]`,
|
|
8
|
+
* contravariantly) even though the type is now generic over the datum.
|
|
9
|
+
*/
|
|
10
|
+
export type BarsBar<T = unknown> = {
|
|
6
11
|
/** Field key — `getValue(d, key)` extracts the number (null = skip this slot, not domain hole). */
|
|
7
12
|
key: string;
|
|
8
13
|
/** Tooltip + legend label. */
|
|
@@ -10,21 +15,29 @@ export type BarsBar = {
|
|
|
10
15
|
/** Fill color (a resolved CSS color / token ref). Per `docs/DESIGN-SPEC.md` §5, the primary bar
|
|
11
16
|
* series should typically resolve to `VX.accent`, a secondary companion to `VX.faint`. */
|
|
12
17
|
color: string;
|
|
13
|
-
/** Per-series tooltip value formatter — overrides the left/right axis's own format.
|
|
14
|
-
|
|
18
|
+
/** Per-series tooltip value formatter — overrides the left/right axis's own format. Receives the
|
|
19
|
+
* hovered datum alongside the value. */
|
|
20
|
+
formatValue?: (v: number, d: T) => string;
|
|
15
21
|
/** Y axis to plot against. Honored only in grouped layout. Default 'left'. */
|
|
16
22
|
axisSide?: 'left' | 'right';
|
|
17
23
|
/** Relative width within the group (only honored in grouped layout). Default 1 — all bars equal. */
|
|
18
24
|
weight?: number;
|
|
25
|
+
/** Default true; false = drawn and legended, but never listed as a tooltip row — threads
|
|
26
|
+
* `SeriesStyle.tooltip` through `Bars`, replacing the removed per-kind `hideBarTooltipRows`. */
|
|
27
|
+
tooltip?: boolean;
|
|
19
28
|
};
|
|
20
|
-
export type BarsLine = {
|
|
29
|
+
export type BarsLine<T = unknown> = {
|
|
21
30
|
key: string;
|
|
22
31
|
label: string;
|
|
23
32
|
color: string;
|
|
24
33
|
axisSide?: 'left' | 'right';
|
|
25
34
|
strokeWidth?: number;
|
|
26
35
|
dashed?: boolean;
|
|
27
|
-
formatValue?: (v: number) => string;
|
|
36
|
+
formatValue?: (v: number, d: T) => string;
|
|
37
|
+
/** Default true; false = drawn and legended, but never listed as a tooltip row. */
|
|
38
|
+
tooltip?: boolean;
|
|
39
|
+
/** Dims the plotted stroke AND the legend swatch, never the tooltip row (`SeriesStyle.strokeOpacity`). */
|
|
40
|
+
strokeOpacity?: number;
|
|
28
41
|
};
|
|
29
42
|
/** @deprecated Use ZoneSpec from primitives/ZoneRects. Kept as an alias. */
|
|
30
43
|
export type BarsZone = ZoneSpec;
|
|
@@ -44,11 +57,11 @@ export type BarsProps<T> = {
|
|
|
44
57
|
/** Generic value accessor — given a data point and a bar/line key, returns the value or null. */
|
|
45
58
|
getValue: (d: T, key: string) => number | null;
|
|
46
59
|
/** 1+ bar series, stacked when ≥2, plotted above baseline (y >= 0). */
|
|
47
|
-
positiveBars: BarsBar[];
|
|
60
|
+
positiveBars: BarsBar<T>[];
|
|
48
61
|
/** Optional bar series stacked below baseline (rendered as flipped negatives). */
|
|
49
|
-
negativeBars?: BarsBar[];
|
|
62
|
+
negativeBars?: BarsBar<T>[];
|
|
50
63
|
/** 0–2 line overlays, each on left or right axis. */
|
|
51
|
-
lines?: BarsLine[];
|
|
64
|
+
lines?: BarsLine<T>[];
|
|
52
65
|
/** Horizontal value-range overlays (target zones, optimal bands). */
|
|
53
66
|
zones?: BarsZone[];
|
|
54
67
|
/** Dashed/solid horizontal reference lines. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Bars.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/Bars.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAe,MAAM,8BAA8B,CAAA;AACnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAA;AAG/D,MAAM,MAAM,OAAO,GAAG;
|
|
1
|
+
{"version":3,"file":"Bars.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/Bars.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,sBAAsB,EAAe,MAAM,8BAA8B,CAAA;AACnG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAe,MAAM,WAAW,CAAA;AAG/D;;;;GAIG;AACH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,iBAAiB,GAAG,KAAK,CAAA;IAClC,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gGAAgG;IAChG,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,+BA+JxC;AA6ND;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAsB,OAAO,SAAS,CAAA"}
|
|
@@ -39,7 +39,8 @@ function BarsInner(props) {
|
|
|
39
39
|
fillOpacity: 0.85,
|
|
40
40
|
...b.axisSide !== void 0 && { axis: b.axisSide },
|
|
41
41
|
getValue: (d) => getValue(d, b.key),
|
|
42
|
-
...b.formatValue !== void 0 && { formatValue: b.formatValue }
|
|
42
|
+
...b.formatValue !== void 0 && { formatValue: b.formatValue },
|
|
43
|
+
...b.tooltip !== void 0 && { tooltip: b.tooltip }
|
|
43
44
|
})),
|
|
44
45
|
[positiveBars, negativeBars, getValue]
|
|
45
46
|
);
|
|
@@ -53,7 +54,9 @@ function BarsInner(props) {
|
|
|
53
54
|
strokeWidth: ln.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH,
|
|
54
55
|
...ln.axisSide !== void 0 && { axis: ln.axisSide },
|
|
55
56
|
getValue: (d) => getValue(d, ln.key),
|
|
56
|
-
...ln.formatValue !== void 0 && { formatValue: ln.formatValue }
|
|
57
|
+
...ln.formatValue !== void 0 && { formatValue: ln.formatValue },
|
|
58
|
+
...ln.tooltip !== void 0 && { tooltip: ln.tooltip },
|
|
59
|
+
...ln.strokeOpacity !== void 0 && { strokeOpacity: ln.strokeOpacity }
|
|
57
60
|
})),
|
|
58
61
|
[lines, getValue]
|
|
59
62
|
);
|
|
@@ -294,7 +297,7 @@ function BarsMarks({
|
|
|
294
297
|
stroke: ln.color,
|
|
295
298
|
strokeWidth: ln.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH,
|
|
296
299
|
strokeDasharray: ln.dashed ? VX.dashArray : void 0,
|
|
297
|
-
strokeOpacity: dim(ln.key),
|
|
300
|
+
strokeOpacity: dim(ln.key) * (ln.strokeOpacity ?? 1),
|
|
298
301
|
curve: curveMonotoneX
|
|
299
302
|
},
|
|
300
303
|
`line-${ln.key}`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bars.test.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/Bars.test.tsx"],"names":[],"mappings":""}
|
|
@@ -33,7 +33,20 @@ export type DualPanelProps<T> = {
|
|
|
33
33
|
/** Top pane share of the inner plot height. Default 0.62. */
|
|
34
34
|
topFraction?: number;
|
|
35
35
|
formatTop: (v: number) => string;
|
|
36
|
+
/** Drives the bottom-pane TICKS. Also the tooltip-row fallback when `formatBar` is omitted. */
|
|
36
37
|
formatBottom: (v: number) => string;
|
|
38
|
+
/** Per-row tooltip formatter for the bottom-pane bar — overrides `formatBottom` for the tooltip
|
|
39
|
+
* row only (ticks keep reading `formatBottom`). Receives the hovered datum alongside the value,
|
|
40
|
+
* so a row can add a unit/decimal `formatBottom` can't (e.g. a velocity reading). */
|
|
41
|
+
formatBar?: (v: number, d: T) => string;
|
|
42
|
+
/**
|
|
43
|
+
* Bottom-pane y-domain. Default `'auto'`: a symmetric `[-maxAbs, maxAbs]` computed from the
|
|
44
|
+
* data, `nice`d. A fixed tuple pins the domain instead (and is used verbatim, un-`nice`d).
|
|
45
|
+
*/
|
|
46
|
+
bottomYDomain?: [number, number] | 'auto';
|
|
47
|
+
/** When `bottomYDomain` is `'auto'`: floors the symmetric max-abs so a plateau doesn't amplify
|
|
48
|
+
* to fill the whole pane (mirrors `AxisConfig.autoMaxFloor`). Ignored with a fixed tuple. */
|
|
49
|
+
bottomMaxAbsFloor?: number;
|
|
37
50
|
/** Tooltip badge — appears at the right of the tooltip header. */
|
|
38
51
|
tooltipLabel?: (d: T) => {
|
|
39
52
|
text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DualPanel.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/DualPanel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DualPanel.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/DualPanel.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAIvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAe,MAAM,WAAW,CAAA;AAK5E,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACtB;8DAC0D;IAC1D,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IACxB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACtC,2EAA2E;IAC3E,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACxD,wGAAwG;IACxG,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAA;IAClE,oDAAoD;IACpD,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;IACrB,8DAA8D;IAC9D,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IAChC,+FAA+F;IAC/F,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACnC;;yFAEqF;IACrF,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAA;IACvC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACzC;iGAC6F;IAC7F,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kEAAkE;IAClE,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC/D;4CACwC;IACxC,MAAM,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAA;IAClC,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAID;;;;;;;;;;;GAWG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,+BAmClD;AAsdD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAA2B,OAAO,cAAc,CAAA"}
|
|
@@ -67,6 +67,9 @@ function DualPanelPlot(props) {
|
|
|
67
67
|
topFraction = 0.62,
|
|
68
68
|
formatTop,
|
|
69
69
|
formatBottom,
|
|
70
|
+
formatBar,
|
|
71
|
+
bottomYDomain = "auto",
|
|
72
|
+
bottomMaxAbsFloor,
|
|
70
73
|
tooltipLabel,
|
|
71
74
|
plot
|
|
72
75
|
} = props;
|
|
@@ -97,7 +100,9 @@ function DualPanelPlot(props) {
|
|
|
97
100
|
() => probeAxisLabels({ domain: topDomain, ticks: 4, format: formatTop, nice: useNiceTop }).labels,
|
|
98
101
|
[topDomain, useNiceTop, formatTop]
|
|
99
102
|
);
|
|
103
|
+
const useNiceBottom = bottomYDomain === "auto";
|
|
100
104
|
const maxAbs = useMemo(() => {
|
|
105
|
+
if (bottomYDomain !== "auto") return 0;
|
|
101
106
|
let m = 0;
|
|
102
107
|
for (const d of data) {
|
|
103
108
|
const v = getBar(d);
|
|
@@ -105,16 +110,21 @@ function DualPanelPlot(props) {
|
|
|
105
110
|
const a = Math.abs(v);
|
|
106
111
|
if (a > m) m = a;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
const floored = bottomMaxAbsFloor !== void 0 ? Math.max(m, bottomMaxAbsFloor) : m;
|
|
114
|
+
return floored === 0 ? 1 : floored;
|
|
115
|
+
}, [data, getBar, bottomYDomain, bottomMaxAbsFloor]);
|
|
116
|
+
const bottomDomain = useMemo(
|
|
117
|
+
() => bottomYDomain === "auto" ? [-maxAbs, maxAbs] : bottomYDomain,
|
|
118
|
+
[bottomYDomain, maxAbs]
|
|
119
|
+
);
|
|
110
120
|
const bottomLabels = useMemo(
|
|
111
121
|
() => probeAxisLabels({
|
|
112
|
-
domain:
|
|
122
|
+
domain: bottomDomain,
|
|
113
123
|
ticks: 3,
|
|
114
124
|
format: formatBottom,
|
|
115
|
-
nice:
|
|
125
|
+
nice: useNiceBottom
|
|
116
126
|
}).labels,
|
|
117
|
-
[
|
|
127
|
+
[bottomDomain, formatBottom, useNiceBottom]
|
|
118
128
|
);
|
|
119
129
|
const xLabelsAll = useMemo(() => data.map((d) => fmtAxisDate(getX(d))), [data, getX]);
|
|
120
130
|
const margin = useMemo(
|
|
@@ -140,8 +150,12 @@ function DualPanelPlot(props) {
|
|
|
140
150
|
[topDomain, useNiceTop, topH]
|
|
141
151
|
);
|
|
142
152
|
const bottomYScale = useMemo(
|
|
143
|
-
() => scaleLinear({
|
|
144
|
-
|
|
153
|
+
() => scaleLinear({
|
|
154
|
+
domain: bottomDomain,
|
|
155
|
+
range: [bottomH, 0],
|
|
156
|
+
...useNiceBottom && { nice: true }
|
|
157
|
+
}),
|
|
158
|
+
[bottomDomain, bottomH, useNiceBottom]
|
|
145
159
|
);
|
|
146
160
|
const cursor = useChartCursor({
|
|
147
161
|
data,
|
|
@@ -209,6 +223,36 @@ function DualPanelPlot(props) {
|
|
|
209
223
|
}
|
|
210
224
|
return out;
|
|
211
225
|
}, [data, visibleSeries]);
|
|
226
|
+
const markerNodes = useMemo(
|
|
227
|
+
() => visibleSeries.flatMap((s) => {
|
|
228
|
+
const getMarker = s.getMarker;
|
|
229
|
+
if (!getMarker) return [];
|
|
230
|
+
const pts = lineValid.get(s.key) ?? [];
|
|
231
|
+
const markers = [];
|
|
232
|
+
for (const p of pts) {
|
|
233
|
+
const m = getMarker(p.__d);
|
|
234
|
+
if (m === null) continue;
|
|
235
|
+
const cx = xScale(getX(p.__d)) ?? 0;
|
|
236
|
+
const cy = topYScale(p.__y);
|
|
237
|
+
markers.push(
|
|
238
|
+
/* @__PURE__ */ jsx(
|
|
239
|
+
"circle",
|
|
240
|
+
{
|
|
241
|
+
cx,
|
|
242
|
+
cy,
|
|
243
|
+
r: m.r ?? VX.dotR,
|
|
244
|
+
fill: m.color ?? s.color,
|
|
245
|
+
stroke: VX.dotStroke,
|
|
246
|
+
strokeWidth: 2
|
|
247
|
+
},
|
|
248
|
+
`mk-${s.key}-${getX(p.__d)}`
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
return markers;
|
|
253
|
+
}),
|
|
254
|
+
[visibleSeries, lineValid, xScale, topYScale, getX]
|
|
255
|
+
);
|
|
212
256
|
const point = cursor.point;
|
|
213
257
|
const sx = point !== null ? xScale(getX(point)) ?? 0 : 0;
|
|
214
258
|
const syncedBar = point !== null ? getBar(point) : null;
|
|
@@ -256,11 +300,13 @@ function DualPanelPlot(props) {
|
|
|
256
300
|
stroke: s.color,
|
|
257
301
|
strokeWidth: s.strokeWidth ?? VX.lineWidth,
|
|
258
302
|
strokeDasharray: s.dash === "dashed" ? VX.dashArray : void 0,
|
|
303
|
+
strokeOpacity: s.strokeOpacity ?? 1,
|
|
259
304
|
curve: curveMonotoneX
|
|
260
305
|
},
|
|
261
306
|
`top-line-${s.key}`
|
|
262
307
|
);
|
|
263
308
|
}),
|
|
309
|
+
markerNodes,
|
|
264
310
|
point !== null && /* @__PURE__ */ jsx(Fragment, { children: visibleSeries.map((s) => {
|
|
265
311
|
const v = s.getValue(point);
|
|
266
312
|
if (v === null || v === void 0 || Number.isNaN(v)) return null;
|
|
@@ -353,12 +399,13 @@ function DualPanelPlot(props) {
|
|
|
353
399
|
barVisible && (() => {
|
|
354
400
|
const v = getBar(point);
|
|
355
401
|
if (v === null || v === void 0 || Number.isNaN(v)) return null;
|
|
402
|
+
const value = formatBar !== void 0 ? formatBar(v, point) : formatBottom(v);
|
|
356
403
|
return /* @__PURE__ */ jsx(
|
|
357
404
|
TooltipRow,
|
|
358
405
|
{
|
|
359
406
|
color: v >= 0 ? barColorPositive : barColorNegative,
|
|
360
407
|
label: barLabel,
|
|
361
|
-
value
|
|
408
|
+
value,
|
|
362
409
|
shape: "bar"
|
|
363
410
|
}
|
|
364
411
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DualPanel.test.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/DualPanel.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiLine.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/MultiLine.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAe,MAAM,8BAA8B,CAAA;AAEnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,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;IAC5D,WAAW,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC/B;4CACwC;IACxC,MAAM,CAAC,EAAE,iBAAiB,GAAG,KAAK,CAAA;IAClC,mGAAmG;IACnG,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gGAAgG;IAChG,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AA4BD;;;;;;;;;;;;GAYG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,+BAgDlD;AAqHD;;;GAGG;AACH,eAAO,MAAM,SAAS,EAA2B,OAAO,cAAc,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { curveMonotoneX } from "@visx/curve";
|
|
3
3
|
import { LinePath } from "@visx/shape";
|
|
4
|
-
import { memo, useMemo } from "react";
|
|
4
|
+
import { memo, useCallback, useMemo } from "react";
|
|
5
5
|
import { CartesianChart } from "../primitives/CartesianChart.js";
|
|
6
6
|
import { LINE_OVERLAY_STROKE_WIDTH } from "../series.js";
|
|
7
7
|
import { VX } from "../../tokens/index.js";
|
|
@@ -80,29 +80,16 @@ function MultiLineMarks({
|
|
|
80
80
|
for (const s of visible) m.set(s.key, seriesPoints(s, data));
|
|
81
81
|
return m;
|
|
82
82
|
}, [visible, data]);
|
|
83
|
-
const dimOpacity = (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
data: valid,
|
|
94
|
-
x: (p) => xScale(getX(p.__d)) ?? 0,
|
|
95
|
-
y: (p) => scale(p.__y),
|
|
96
|
-
stroke: s.color,
|
|
97
|
-
strokeWidth: s.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH,
|
|
98
|
-
strokeDasharray: s.dash === "dashed" ? VX.dashArray : void 0,
|
|
99
|
-
strokeOpacity: dimOpacity(s),
|
|
100
|
-
curve: curveMonotoneX
|
|
101
|
-
},
|
|
102
|
-
`line-${s.key}`
|
|
103
|
-
);
|
|
104
|
-
}),
|
|
105
|
-
visible.flatMap((s) => {
|
|
83
|
+
const dimOpacity = useCallback(
|
|
84
|
+
(s) => highlighted === null || s.key === highlighted || s.parent === highlighted ? 1 : 0.25,
|
|
85
|
+
[highlighted]
|
|
86
|
+
);
|
|
87
|
+
const scaleFor = useCallback(
|
|
88
|
+
(s) => s.axis === "right" && y2Scale !== null ? y2Scale : yScale,
|
|
89
|
+
[y2Scale, yScale]
|
|
90
|
+
);
|
|
91
|
+
const markerNodes = useMemo(
|
|
92
|
+
() => visible.flatMap((s) => {
|
|
106
93
|
const getMarker = s.getMarker;
|
|
107
94
|
if (!getMarker) return [];
|
|
108
95
|
const scale = scaleFor(s);
|
|
@@ -144,7 +131,30 @@ function MultiLineMarks({
|
|
|
144
131
|
);
|
|
145
132
|
}
|
|
146
133
|
return markers;
|
|
147
|
-
})
|
|
134
|
+
}),
|
|
135
|
+
[visible, pointsBySeries, xScale, getX, scaleFor, dimOpacity, markerShape]
|
|
136
|
+
);
|
|
137
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
138
|
+
visible.map((s) => {
|
|
139
|
+
const valid = pointsBySeries.get(s.key) ?? [];
|
|
140
|
+
if (valid.length === 0) return null;
|
|
141
|
+
const scale = scaleFor(s);
|
|
142
|
+
return /* @__PURE__ */ jsx(
|
|
143
|
+
LinePath,
|
|
144
|
+
{
|
|
145
|
+
data: valid,
|
|
146
|
+
x: (p) => xScale(getX(p.__d)) ?? 0,
|
|
147
|
+
y: (p) => scale(p.__y),
|
|
148
|
+
stroke: s.color,
|
|
149
|
+
strokeWidth: s.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH,
|
|
150
|
+
strokeDasharray: s.dash === "dashed" ? VX.dashArray : void 0,
|
|
151
|
+
strokeOpacity: dimOpacity(s) * (s.strokeOpacity ?? 1),
|
|
152
|
+
curve: curveMonotoneX
|
|
153
|
+
},
|
|
154
|
+
`line-${s.key}`
|
|
155
|
+
);
|
|
156
|
+
}),
|
|
157
|
+
markerNodes
|
|
148
158
|
] });
|
|
149
159
|
}
|
|
150
160
|
const MultiLine = memo(MultiLineInner);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MultiLine.test.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/MultiLine.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZonedLine.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/ZonedLine.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAe,MAAM,8BAA8B,CAAA;AAEnG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAG/D,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAA;AAEpC,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,oDAAoD;IACpD,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,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GAAmG;IACnG,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gGAAgG;IAChG,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAiBD;;;;;;;;;;;;GAYG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,+BA2DlD;AA+ED;;;GAGG;AACH,eAAO,MAAM,SAAS,EAA2B,OAAO,cAAc,CAAA"}
|
|
@@ -127,6 +127,7 @@ function ZonedLineMarks({
|
|
|
127
127
|
stroke: primary.color,
|
|
128
128
|
strokeWidth: primary.strokeWidth ?? LINE_OVERLAY_STROKE_WIDTH,
|
|
129
129
|
strokeDasharray: primary.dash === "dashed" ? VX.dashArray : void 0,
|
|
130
|
+
strokeOpacity: primary.strokeOpacity ?? 1,
|
|
130
131
|
curve: curveMonotoneX
|
|
131
132
|
}
|
|
132
133
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZonedLine.test.d.ts","sourceRoot":"","sources":["../../../src/charts/kinds/ZonedLine.test.tsx"],"names":[],"mappings":""}
|
|
@@ -28,6 +28,22 @@ export type AxisConfig<T> = {
|
|
|
28
28
|
format?: (v: number) => string;
|
|
29
29
|
/** Horizontal grid rules. Default: on for the left axis, off for the right. */
|
|
30
30
|
grid?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Round the scale's domain outward to nice tick values (d3's `scale.nice()`). Threaded to BOTH
|
|
33
|
+
* `probeAxisLabels` (measurement) and the real `scaleLinear` (rendering) — they must agree, or
|
|
34
|
+
* the measured margin is computed from ticks the axis never paints.
|
|
35
|
+
*
|
|
36
|
+
* Default `false`, deliberately: flipping the default would move the domain of every
|
|
37
|
+
* already-migrated chart. Opt in per axis.
|
|
38
|
+
*/
|
|
39
|
+
nice?: boolean;
|
|
40
|
+
};
|
|
41
|
+
/** Handed to `prependRows`/`extraRows` alongside the hovered datum — the same `visible`/`hidden`
|
|
42
|
+
* the plot itself draws from, so a hand-authored row can't structurally desync from legend
|
|
43
|
+
* toggling. */
|
|
44
|
+
export type CartesianTooltipRowContext<T> = {
|
|
45
|
+
visible: readonly ChartSeries<T>[];
|
|
46
|
+
hidden: ReadonlySet<string>;
|
|
31
47
|
};
|
|
32
48
|
export type CartesianTooltipConfig<T> = {
|
|
33
49
|
/**
|
|
@@ -42,10 +58,12 @@ export type CartesianTooltipConfig<T> = {
|
|
|
42
58
|
text: string;
|
|
43
59
|
color: string;
|
|
44
60
|
} | null;
|
|
45
|
-
/** Rows rendered BEFORE the derived per-series rows (a total, a context line).
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
/** Rows rendered BEFORE the derived per-series rows (a total, a context line). The second
|
|
62
|
+
* argument carries the same `visible`/`hidden` the plot draws from, so a hand-authored row
|
|
63
|
+
* stays in sync with legend toggling instead of naming a series the plot no longer draws. */
|
|
64
|
+
prependRows?: (d: T, ctx: CartesianTooltipRowContext<T>) => ReactNode;
|
|
65
|
+
/** Rows appended after the derived per-series rows. Same `ctx` as {@link prependRows}. */
|
|
66
|
+
extraRows?: (d: T, ctx: CartesianTooltipRowContext<T>) => ReactNode;
|
|
49
67
|
};
|
|
50
68
|
/** Everything a mark renderer needs. Handed to `CartesianChart`'s child on every render. */
|
|
51
69
|
export type PlotContext<T> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../src/charts/primitives/CartesianChart.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAU/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C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