basalt-ui 2.9.1 → 2.11.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 +61 -38
- package/MIGRATING.md +34 -12
- package/agent/rules/basalt-charts.md +2 -2
- package/agent/skills/basalt-charts/SKILL.md +16 -17
- package/dist/charts/BandStrip.d.ts +9 -6
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +8 -8
- package/dist/charts/CartesianChart.d.ts +3 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +13 -6
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +20 -15
- package/dist/charts/Heatmap.d.ts +33 -3
- package/dist/charts/Heatmap.d.ts.map +1 -1
- package/dist/charts/Heatmap.js +111 -68
- package/dist/charts/MirroredBars.d.ts +16 -5
- package/dist/charts/MirroredBars.d.ts.map +1 -1
- package/dist/charts/MirroredBars.js +46 -9
- package/dist/charts/Sparkline.d.ts +12 -0
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +68 -5
- package/dist/charts/band-fold.d.ts +13 -0
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +11 -1
- package/dist/charts/compile.d.ts +4 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +22 -14
- package/dist/charts/heatmap-fill.d.ts +15 -0
- package/dist/charts/heatmap-fill.d.ts.map +1 -0
- package/dist/charts/heatmap-fill.js +13 -0
- package/dist/charts/host.d.ts +5 -1
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +37 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/legend.d.ts +2 -0
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +14 -10
- package/dist/charts/marks.d.ts +1 -1
- package/dist/charts/marks.d.ts.map +1 -1
- package/dist/charts/marks.js +28 -13
- package/dist/charts/panel.d.ts +7 -1
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +9 -4
- package/dist/charts/plot-context.d.ts +42 -0
- package/dist/charts/plot-context.d.ts.map +1 -0
- package/dist/charts/plot-context.js +64 -0
- package/dist/charts/scales.d.ts +3 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +23 -5
- package/dist/charts/types.d.ts +36 -4
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/controls/enum-filter.d.ts +4 -1
- package/dist/controls/enum-filter.d.ts.map +1 -1
- package/dist/controls/enum-filter.js +2 -1
- package/dist/controls/number-filter.d.ts.map +1 -1
- package/dist/controls/number-filter.js +2 -0
- package/dist/tokens/core.d.ts +6 -0
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +5 -3
- package/llms.txt +17 -8
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +19 -20
- package/src/charts/CartesianChart.tsx +16 -4
- package/src/charts/DualPanel.tsx +21 -16
- package/src/charts/Heatmap.tsx +181 -76
- package/src/charts/MirroredBars.tsx +71 -18
- package/src/charts/Sparkline.tsx +106 -5
- package/src/charts/band-fold.ts +32 -0
- package/src/charts/compile.ts +26 -14
- package/src/charts/heatmap-fill.ts +19 -0
- package/src/charts/host.tsx +59 -0
- package/src/charts/index.ts +1 -1
- package/src/charts/legend.tsx +21 -12
- package/src/charts/marks.ts +31 -14
- package/src/charts/panel.tsx +18 -5
- package/src/charts/plot-context.ts +109 -0
- package/src/charts/scales.ts +33 -5
- package/src/charts/types.ts +36 -4
- package/src/controls/enum-filter.tsx +5 -1
- package/src/controls/number-filter.tsx +6 -1
- package/src/tokens/core.ts +10 -3
package/dist/charts/scales.js
CHANGED
|
@@ -53,6 +53,7 @@ function xKindOf(values) {
|
|
|
53
53
|
if (typeof first === "number") return "number";
|
|
54
54
|
return "string";
|
|
55
55
|
}
|
|
56
|
+
const toNumber = (v) => v instanceof Date ? v.getTime() : v;
|
|
56
57
|
const keyOf = (v) => v instanceof Date ? v.getTime() : v;
|
|
57
58
|
function distinctX(values) {
|
|
58
59
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -69,9 +70,22 @@ const POINT_PADDING = 0.5;
|
|
|
69
70
|
const BAND_PADDING_INNER = 0.2;
|
|
70
71
|
const BAND_PADDING_OUTER = 0.1;
|
|
71
72
|
const DAY_MS = 864e5;
|
|
72
|
-
function
|
|
73
|
+
function explicitDomain(xDomain) {
|
|
74
|
+
if (xDomain === void 0) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const [min, max] = [toNumber(xDomain[0]), toNumber(xDomain[1])];
|
|
78
|
+
if (Number.isFinite(min) && Number.isFinite(max) && min < max) {
|
|
79
|
+
return [min, max];
|
|
80
|
+
}
|
|
81
|
+
if (process.env.NODE_ENV !== "production") {
|
|
82
|
+
console.warn("[basalt] CartesianChart: `xDomain` needs finite min < max; using the data extent");
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
function xScaleFor(raw, band, xDomain) {
|
|
73
87
|
const values = distinctX(raw);
|
|
74
|
-
const kind = xKindOf(values);
|
|
88
|
+
const kind = xKindOf(values.length > 0 || xDomain === void 0 ? values : [xDomain[0]]);
|
|
75
89
|
const n = values.length;
|
|
76
90
|
if (band || kind === "string") {
|
|
77
91
|
const keys = values;
|
|
@@ -107,7 +121,7 @@ function xScaleFor(raw, band) {
|
|
|
107
121
|
}
|
|
108
122
|
};
|
|
109
123
|
}
|
|
110
|
-
const nums = values.map(
|
|
124
|
+
const nums = values.map(toNumber);
|
|
111
125
|
let lo = Infinity;
|
|
112
126
|
let hi = -Infinity;
|
|
113
127
|
for (const v of nums) {
|
|
@@ -119,7 +133,11 @@ function xScaleFor(raw, band) {
|
|
|
119
133
|
if (v > hi) hi = v;
|
|
120
134
|
}
|
|
121
135
|
if (!Number.isFinite(lo)) [lo, hi] = [0, 1];
|
|
122
|
-
|
|
136
|
+
const explicit = explicitDomain(xDomain);
|
|
137
|
+
if (explicit !== null) {
|
|
138
|
+
;
|
|
139
|
+
[lo, hi] = explicit;
|
|
140
|
+
} else if (lo === hi) {
|
|
123
141
|
const half = kind === "date" ? DAY_MS / 2 : 0.5;
|
|
124
142
|
lo -= half;
|
|
125
143
|
hi += half;
|
|
@@ -138,7 +156,7 @@ function xScaleFor(raw, band) {
|
|
|
138
156
|
extent: [lo, hi],
|
|
139
157
|
step: medianGap,
|
|
140
158
|
fraction: (x) => {
|
|
141
|
-
const v = x
|
|
159
|
+
const v = toNumber(x);
|
|
142
160
|
return typeof v === "number" && Number.isFinite(v) ? (v - lo) / span : null;
|
|
143
161
|
}
|
|
144
162
|
};
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -61,10 +61,13 @@ export type ChartSeries<T> = {
|
|
|
61
61
|
/**
|
|
62
62
|
* A cursor dot for a series whose mark the consumer draws itself (`marks`, so `getValue` stays
|
|
63
63
|
* `null`): the y of the dot at each datum, `null` for none. The dot shows while the cursor is on
|
|
64
|
-
* that datum's x and takes the series color
|
|
64
|
+
* that datum's x and takes the series color, or `getMarker(d).color` when the series has one: the
|
|
65
|
+
* dot follows the datum. A series drawn from `plot.rows` already has one.
|
|
65
66
|
*/
|
|
66
67
|
cursorValue?: ((d: T) => number | null) | undefined;
|
|
67
|
-
/** A marker at a point (a PR star, a status dot); `null` for none.
|
|
68
|
+
/** A marker at a point (a PR star, a status dot); `null` for none. On a `cursorValue` series
|
|
69
|
+
* only `color` applies, to the cursor dot, and each distinct color is one extra mark: keep colors
|
|
70
|
+
* a small categorical set (statuses, buckets), never a continuous scale. */
|
|
68
71
|
getMarker?: ((d: T) => {
|
|
69
72
|
color?: string | undefined;
|
|
70
73
|
r?: number | undefined;
|
|
@@ -220,9 +223,25 @@ export type PlotContext<T, X extends ChartX = ChartX> = {
|
|
|
220
223
|
highlighted: string | null;
|
|
221
224
|
/** The measured container class (`regular` on the server). */
|
|
222
225
|
containerClass: ContainerClass;
|
|
223
|
-
/** The chart's
|
|
226
|
+
/** The chart's FRAME in px (plot plus axis gutters), for a kind that lays out labels against it. */
|
|
224
227
|
width: number;
|
|
225
228
|
height: number;
|
|
229
|
+
/**
|
|
230
|
+
* The plot area in px: the frame less the axis gutters. Pin a mark in pixels with it (a 3 px
|
|
231
|
+
* rail along the top is `yMax - 3 * (yMax - yMin) / plot.plotHeight` down from `yMax`). The
|
|
232
|
+
* engine measures its gutters after `marks` runs, so the first pass (the server HTML, the first
|
|
233
|
+
* client frame) reports the FRAME, one frame-sized draw; the chart then re-renders once with the
|
|
234
|
+
* measured area, and only a chart whose `marks` read these fields pays that render. Every kind,
|
|
235
|
+
* single or composed, reports it the same way.
|
|
236
|
+
*/
|
|
237
|
+
plotWidth: number;
|
|
238
|
+
plotHeight: number;
|
|
239
|
+
/**
|
|
240
|
+
* Every row of `data`, whatever the legend hides: raw datums (`T`), NOT `PlotRow`s. For bucket-level marks only (absent columns,
|
|
241
|
+
* rails: the slot grid must not vanish with its last visible series); a series' own marks still
|
|
242
|
+
* draw `plot.rows(key)` and gate on `plot.visible`.
|
|
243
|
+
*/
|
|
244
|
+
data: readonly T[];
|
|
226
245
|
/** Bind a mark to the right axis with `yScale: plot.y2` (present only with a `y2` config). */
|
|
227
246
|
y2: 'y2' | undefined;
|
|
228
247
|
/** The resolved y domain (and the right axis', with `y2`): basalt's, never the engine's. */
|
|
@@ -245,6 +264,13 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
245
264
|
y2?: AxisConfig<T> | undefined;
|
|
246
265
|
/** A tick count, or the exact x tick values. Default: by container class. */
|
|
247
266
|
xTicks?: number | readonly X[] | undefined;
|
|
267
|
+
/**
|
|
268
|
+
* `[min, max]` of the x scale, in `x`'s type. Default: the data's own extent. Charts given the
|
|
269
|
+
* same domain put the same instant on the same pixel column, whatever their data spans; rows
|
|
270
|
+
* outside it are clipped. A domain that is reversed, flat or not finite falls back to the data
|
|
271
|
+
* extent (and warns in dev). A no-op on a string or band x (`Bars`, `MirroredBars`, `BandStrip`).
|
|
272
|
+
*/
|
|
273
|
+
xDomain?: readonly [X, X] | undefined;
|
|
248
274
|
/** Tick label for an x value. Default: `DD.MM` for dates, compact numbers, strings verbatim. */
|
|
249
275
|
formatX?: ((x: X) => string) | undefined;
|
|
250
276
|
zones?: readonly ZoneSpec[] | undefined;
|
|
@@ -252,7 +278,13 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
252
278
|
refLines?: readonly RefLine[] | undefined;
|
|
253
279
|
/** `false` hides the legend. */
|
|
254
280
|
legend?: ChartLegendConfig | false | undefined;
|
|
255
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* Default: the height law (measured width × class ratio, 160–420px, ≤ 45vh on touch). Always the
|
|
283
|
+
* FRAME, in every kind: the plot plus the axis the engine measures. A `BandStrip` band is the
|
|
284
|
+
* frame less the x axis (about 21 px at the default font and density, so `height: 65` for a
|
|
285
|
+
* 44 px band). The box is CSS-owned before any measurement exists, so the plot area is read back
|
|
286
|
+
* from the engine's layout (`PlotContext.plotWidth`/`plotHeight`), never an input.
|
|
287
|
+
*/
|
|
256
288
|
height?: number | ResponsiveChartHeight | undefined;
|
|
257
289
|
state?: ChartState | undefined;
|
|
258
290
|
/** Joins a named cursor group instead of the page-shared default. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;8CAC8C;AAC9C,MAAM,MAAM,MAAM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;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAA;IACnD,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,CAAA;IAC9B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC;qCACiC;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IAC/C,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,GAAG,SAAS,CAAA;CACvD,CAAA;AAED;mBACmB;AACnB,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAU,CAAA"}
|
|
@@ -29,6 +29,9 @@ export type EnumFilterProps<T extends string> = BasaltProps & {
|
|
|
29
29
|
* into, and `exactOptionalPropertyTypes` rejects a possibly-undefined member on a bare optional.
|
|
30
30
|
*/
|
|
31
31
|
readonly options?: readonly FilterOption[] | undefined;
|
|
32
|
+
/** Pill text for a value no rendered option matches, ahead of `label` — the name `.labels()` gave
|
|
33
|
+
* an unset state that is deliberately not a row (`NumberFilter`'s preset form). */
|
|
34
|
+
readonly unmatchedLabel?: string | undefined;
|
|
32
35
|
/**
|
|
33
36
|
* Mono pill label — forwarded to `FilterPill.numeric`. Set by `NumberFilter`, whose values ARE
|
|
34
37
|
* numbers (`1` / `2` / `7`), and by nothing else: the same law `[data-numeric]` applies to a
|
|
@@ -36,5 +39,5 @@ export type EnumFilterProps<T extends string> = BasaltProps & {
|
|
|
36
39
|
*/
|
|
37
40
|
readonly numeric?: boolean | undefined;
|
|
38
41
|
};
|
|
39
|
-
export declare function EnumFilter<T extends string>({ field, label, icon, clearable, numeric, options: optionsProp, className, style, }: EnumFilterProps<T>): ReactNode;
|
|
42
|
+
export declare function EnumFilter<T extends string>({ field, label, icon, clearable, numeric, options: optionsProp, unmatchedLabel, className, style, }: EnumFilterProps<T>): ReactNode;
|
|
40
43
|
//# sourceMappingURL=enum-filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-filter.d.ts","sourceRoot":"","sources":["../../src/controls/enum-filter.tsx"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAMlD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI;IAC3C,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IACpB,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IACxC,GAAG,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,CAAA;IACtC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,CAAA;IACxB;kFAC8E;IAC9E,KAAK,IAAI,IAAI,CAAA;CACd,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,MAAM,IAAI,WAAW,GAAG;IAC5D,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;IACzB,gGAAgG;IAChG,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAA;IACtD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACvC,CAA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EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAA;IACtD;wFACoF;IACpF,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,EAC3C,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,OAAO,EACP,OAAO,EAAE,WAAW,EACpB,cAAc,EACd,SAAS,EACT,KAAK,GACN,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,CA2FhC"}
|
|
@@ -12,6 +12,7 @@ function EnumFilter({
|
|
|
12
12
|
clearable,
|
|
13
13
|
numeric,
|
|
14
14
|
options: optionsProp,
|
|
15
|
+
unmatchedLabel,
|
|
15
16
|
className,
|
|
16
17
|
style
|
|
17
18
|
}) {
|
|
@@ -83,7 +84,7 @@ function EnumFilter({
|
|
|
83
84
|
return /* @__PURE__ */ jsx(
|
|
84
85
|
FilterPill,
|
|
85
86
|
{
|
|
86
|
-
label: selected?.label ?? label,
|
|
87
|
+
label: selected?.label ?? unmatchedLabel ?? label,
|
|
87
88
|
active: !isDefault,
|
|
88
89
|
...numeric === true && { numeric: true },
|
|
89
90
|
...icon !== void 0 && { icon },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-filter.d.ts","sourceRoot":"","sources":["../../src/controls/number-filter.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-filter.d.ts","sourceRoot":"","sources":["../../src/controls/number-filter.tsx"],"names":[],"mappings":"AAmEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAQlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD;6FAC6F;AAC7F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;IACxC;yFACqF;IACrF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;IACzB,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAA;IAChD;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB;kEAC8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAqChE"}
|
|
@@ -52,6 +52,7 @@ function NumberChoice({
|
|
|
52
52
|
}) {
|
|
53
53
|
const [value, setValue] = field.use();
|
|
54
54
|
const rows = options.map((option) => ({ value: String(option.value), label: option.label }));
|
|
55
|
+
const named = field.options.find((option) => option.value === String(value))?.label;
|
|
55
56
|
const choice = {
|
|
56
57
|
fallback: String(field.fallback),
|
|
57
58
|
options: rows,
|
|
@@ -73,6 +74,7 @@ function NumberChoice({
|
|
|
73
74
|
label,
|
|
74
75
|
numeric: true,
|
|
75
76
|
options: rows,
|
|
77
|
+
...named !== void 0 && { unmatchedLabel: named },
|
|
76
78
|
...clearable === true && { clearable: true },
|
|
77
79
|
...icon !== void 0 && { icon },
|
|
78
80
|
...className !== void 0 && { className },
|
package/dist/tokens/core.d.ts
CHANGED
|
@@ -173,6 +173,12 @@ export declare const BREAKPOINTS: {
|
|
|
173
173
|
* vars (`--vx-space-input-height`) can never compute the conversion two different ways.
|
|
174
174
|
*/
|
|
175
175
|
export declare function pxRem(px: number): string;
|
|
176
|
+
/**
|
|
177
|
+
* Reference-line strength: the status solid's share over the panel, in percent. One value for the
|
|
178
|
+
* three lines so they read as one family; 60 keeps the faintest (light-scheme `warn`) at a 2:1
|
|
179
|
+
* composite against the page, where the old 20–30% sat at 1.25–1.5 (`ref-line-contrast.test.ts`).
|
|
180
|
+
*/
|
|
181
|
+
export declare const REF_LINE_ALPHA = 60;
|
|
176
182
|
/**
|
|
177
183
|
* Wrap a map of `{ name: ColorPair }` into `var(--vx-<prefix><name>)` token refs — the runtime
|
|
178
184
|
* companion to `buildPaletteCss`. Lets a consumer define its own series and read stable refs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/tokens/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAUvE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,WAAW,CAAA;AAMjC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnF,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAM5D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAO7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,wFAAwF;AACxF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AAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AASD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,MAAM,CAkB1E;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,CASvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAMtE"}
|
package/dist/tokens/core.js
CHANGED
|
@@ -213,6 +213,7 @@ const decl = (name, value) => ` --vx-${name}: ${value};`;
|
|
|
213
213
|
function pxRem(px) {
|
|
214
214
|
return `${px / 16}rem`;
|
|
215
215
|
}
|
|
216
|
+
const REF_LINE_ALPHA = 60;
|
|
216
217
|
const groupSide = (prefix, map, side) => Object.entries(map).map(([key, pair]) => decl(`${prefix}${key}`, pair[side])).join("\n");
|
|
217
218
|
function frameworkPrimitives(side, data) {
|
|
218
219
|
const n = data.NEUTRAL;
|
|
@@ -499,9 +500,9 @@ function frameworkDerived(data, only) {
|
|
|
499
500
|
decl("good-soft", "color-mix(in srgb, var(--vx-good-solid) 8%, transparent)"),
|
|
500
501
|
decl("bad", "color-mix(in srgb, var(--vx-bad-solid) 18%, transparent)"),
|
|
501
502
|
decl("warn", "color-mix(in srgb, var(--vx-warn-solid) 8%, transparent)"),
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
...["good", "bad", "warn"].map(
|
|
504
|
+
(k) => decl(`${k}-ref`, `color-mix(in srgb, var(--vx-${k}-solid) ${REF_LINE_ALPHA}%, transparent)`)
|
|
505
|
+
)
|
|
505
506
|
].join("\n");
|
|
506
507
|
return canonical;
|
|
507
508
|
}
|
|
@@ -658,6 +659,7 @@ export {
|
|
|
658
659
|
CONTAINER_GRID_BREAKPOINTS,
|
|
659
660
|
CONTAINER_KEYS,
|
|
660
661
|
DEFAULT_DERIVE_CONFIG,
|
|
662
|
+
REF_LINE_ALPHA,
|
|
661
663
|
SIZE_CLASSES2 as SIZE_CLASSES,
|
|
662
664
|
VX,
|
|
663
665
|
alpha,
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.11.0
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.
|
|
16
|
+
Version: 2.11.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -231,13 +231,14 @@ Import: import { ... } from 'basalt-ui/charts'
|
|
|
231
231
|
Description: CartesianChart (the TanStack Charts rung), the Lines and Bars kinds, ChartCard and the shared chartCursor (Mantine-free; @tanstack/charts + d3-scale peers)
|
|
232
232
|
Layer: headless
|
|
233
233
|
Rule: basalt-charts
|
|
234
|
-
Signature: BandStrip(props: BandStripProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
234
|
+
Signature: BandStrip(props: BandStripProps<T, X, K>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
235
235
|
className?: string
|
|
236
236
|
style?: CSSProperties
|
|
237
237
|
ariaLabel: string
|
|
238
238
|
data: readonly T[]
|
|
239
239
|
x: (d: T) => X
|
|
240
240
|
xTicks?: number | readonly X[]
|
|
241
|
+
xDomain?: readonly [X, X]
|
|
241
242
|
formatX?: ((x: X) => string)
|
|
242
243
|
legend?: false | ChartLegendConfig
|
|
243
244
|
height?: number | ResponsiveChartHeight
|
|
@@ -245,10 +246,10 @@ Signature: BandStrip(props: BandStripProps<T, X>): ReactElement<unknown, string
|
|
|
245
246
|
cursorGroup?: string
|
|
246
247
|
cursorResolution?: CursorResolution
|
|
247
248
|
tooltip?: false | ChartTooltipConfig<T, X>
|
|
248
|
-
states: readonly
|
|
249
|
+
states: readonly (NamedChartState & { formatValue?: ((d: T) => stri…
|
|
249
250
|
getBand: (d: T) => BandSpan
|
|
250
251
|
fold?: BandFold<T>
|
|
251
|
-
absentState?:
|
|
252
|
+
absentState?: K
|
|
252
253
|
Signature: Bars(props: BarsProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
253
254
|
className?: string
|
|
254
255
|
style?: CSSProperties
|
|
@@ -258,6 +259,7 @@ Signature: Bars(props: BarsProps<T, X>): ReactElement<unknown, string | JSXEleme
|
|
|
258
259
|
y?: AxisConfig<T>
|
|
259
260
|
y2?: AxisConfig<T>
|
|
260
261
|
xTicks?: number | readonly X[]
|
|
262
|
+
xDomain?: readonly [X, X]
|
|
261
263
|
formatX?: ((x: X) => string)
|
|
262
264
|
zones?: readonly ZoneSpec[]
|
|
263
265
|
xZones?: readonly XZoneSpec<X>[]
|
|
@@ -283,6 +285,7 @@ Signature: CartesianChart(props: CartesianChartProps<T, X>): ReactElement<unknow
|
|
|
283
285
|
y?: AxisConfig<T>
|
|
284
286
|
y2?: AxisConfig<T>
|
|
285
287
|
xTicks?: number | readonly X[]
|
|
288
|
+
xDomain?: readonly [X, X]
|
|
286
289
|
formatX?: ((x: X) => string)
|
|
287
290
|
zones?: readonly ZoneSpec[]
|
|
288
291
|
xZones?: readonly XZoneSpec<X>[]
|
|
@@ -341,7 +344,7 @@ Signature: DualPanel(props: DualPanelProps<T, X>): ReactElement<unknown, string
|
|
|
341
344
|
fillBetween?: { from: string; to: string; fill: string; aboveFill?: strin…
|
|
342
345
|
bar: DualPanelBar<T>
|
|
343
346
|
topFraction?: number
|
|
344
|
-
Signature: Heatmap(props: HeatmapProps<T>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
347
|
+
Signature: Heatmap(props: HeatmapProps<T, K>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
345
348
|
className?: string
|
|
346
349
|
style?: CSSProperties
|
|
347
350
|
ariaLabel: string
|
|
@@ -354,6 +357,9 @@ Signature: Heatmap(props: HeatmapProps<T>): ReactElement<unknown, string | JSXEl
|
|
|
354
357
|
color?: string
|
|
355
358
|
domain?: readonly [number, number]
|
|
356
359
|
formatValue?: ((v: number) => string)
|
|
360
|
+
formatLegend?: ((v: number) => string)
|
|
361
|
+
getState?: ((d: T) => K | undefined)
|
|
362
|
+
states?: readonly HeatmapState<K>[]
|
|
357
363
|
formatRow?: ((row: string) => string)
|
|
358
364
|
formatCol?: ((col: string) => string)
|
|
359
365
|
legend?: false | { label?: string | undefined; }
|
|
@@ -371,6 +377,7 @@ Signature: Lines(props: LinesProps<T, X>): ReactElement<unknown, string | JSXEle
|
|
|
371
377
|
y?: AxisConfig<T>
|
|
372
378
|
y2?: AxisConfig<T>
|
|
373
379
|
xTicks?: number | readonly X[]
|
|
380
|
+
xDomain?: readonly [X, X]
|
|
374
381
|
formatX?: ((x: X) => string)
|
|
375
382
|
zones?: readonly ZoneSpec[]
|
|
376
383
|
xZones?: readonly XZoneSpec<X>[]
|
|
@@ -382,7 +389,7 @@ Signature: Lines(props: LinesProps<T, X>): ReactElement<unknown, string | JSXEle
|
|
|
382
389
|
cursorResolution?: CursorResolution
|
|
383
390
|
tooltip?: false | ChartTooltipConfig<T, X>
|
|
384
391
|
thresholds?: [X] extends [string] ? never : readonly Threshold[]
|
|
385
|
-
Signature: MirroredBars(props: MirroredBarsProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
392
|
+
Signature: MirroredBars(props: MirroredBarsProps<T, X, K>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
386
393
|
className?: string
|
|
387
394
|
style?: CSSProperties
|
|
388
395
|
ariaLabel: string
|
|
@@ -394,11 +401,12 @@ Signature: MirroredBars(props: MirroredBarsProps<T, X>): ReactElement<unknown, s
|
|
|
394
401
|
state?: ChartState
|
|
395
402
|
cursorGroup?: string
|
|
396
403
|
tooltip?: false | ChartTooltipConfig<T, X>
|
|
397
|
-
series: readonly MirroredBarsSeries<T>[]
|
|
404
|
+
series: readonly MirroredBarsSeries<T, K>[]
|
|
398
405
|
up: MirroredBarPane
|
|
399
406
|
down: MirroredBarPane
|
|
400
407
|
upFraction?: number
|
|
401
408
|
getAbsentFraction?: ((d: T) => number)
|
|
409
|
+
absentState?: K
|
|
402
410
|
getBarOpacity?: ((d: T) => number)
|
|
403
411
|
fold?: { minBandPx?: number | undefined; merge: (group: T[]) => T;…
|
|
404
412
|
cursorResolution?: CursorResolution
|
|
@@ -421,6 +429,7 @@ Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, str
|
|
|
421
429
|
data: readonly T[]
|
|
422
430
|
x: (d: T) => X
|
|
423
431
|
xTicks?: number | readonly X[]
|
|
432
|
+
xDomain?: readonly [X, X]
|
|
424
433
|
formatX?: ((x: X) => string)
|
|
425
434
|
zones?: readonly ZoneSpec[]
|
|
426
435
|
xZones?: readonly XZoneSpec<X>[]
|
package/package.json
CHANGED
package/src/charts/BandStrip.tsx
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* `BandStrip` — a 1-D state strip: one gap-free band per slot over the shared x axis, no y
|
|
3
3
|
* dimension (`docs/V2-SPEC.md` § 9.3). Each band is in one of the `states`, tinted by the state's
|
|
4
4
|
* color (or an intensity `fill` of the datum's own), optionally carrying an inset `marker`.
|
|
5
|
-
* Absence is a state like any other: a flat, unhatched fill whose color differs from every
|
|
6
|
-
* with `absentState` and a folded band can carry an
|
|
5
|
+
* Absence is a state like any other: a flat, unhatched fill whose color differs from every
|
|
6
|
+
* measured state's, not only by alpha. Name it with `absentState` and a folded band can carry an
|
|
7
|
+
* `absentFraction` share of it.
|
|
7
8
|
*
|
|
8
9
|
* The rung supplies the legend, cursor, crosshair and tooltip. The visible bands are decorative
|
|
9
10
|
* rects on the rung's `[0, 1]` zone scale (a band scale pads its slots, a strip must not), and an
|
|
@@ -19,8 +20,8 @@ import { oneOf, requiredProp } from '../common/errors'
|
|
|
19
20
|
import { NON_FINITE } from '../format/shared'
|
|
20
21
|
import { VX, alpha } from '../tokens'
|
|
21
22
|
import { CartesianRung } from './CartesianChart'
|
|
22
|
-
import { groupsOf } from './band-fold'
|
|
23
|
-
import type { Group } from './band-fold'
|
|
23
|
+
import { groupsOf, resolveNamedState } from './band-fold'
|
|
24
|
+
import type { Group, NamedChartState } from './band-fold'
|
|
24
25
|
import { emphasis } from './marks'
|
|
25
26
|
import { rowX } from './types'
|
|
26
27
|
import type {
|
|
@@ -34,10 +35,7 @@ import type {
|
|
|
34
35
|
} from './types'
|
|
35
36
|
|
|
36
37
|
/** A state a strip can draw. A band has no number to plot, so `formatValue` reads the datum. */
|
|
37
|
-
export type BandStripSeries<T> =
|
|
38
|
-
ChartSeries<T>,
|
|
39
|
-
'key' | 'label' | 'color' | 'tooltip' | 'legend' | 'note' | 'fillOpacity'
|
|
40
|
-
> & {
|
|
38
|
+
export type BandStripSeries<T> = NamedChartState & {
|
|
41
39
|
/**
|
|
42
40
|
* The tooltip row's value for a band in this state. `null` is an ABSENT reading and renders an
|
|
43
41
|
* em dash; omit the function when the state's name is the whole reading ("Not measured").
|
|
@@ -83,11 +81,11 @@ export type BandFold<T> = {
|
|
|
83
81
|
merge: (group: T[]) => T
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
export type BandStripProps<T, X extends ChartX = ChartX> = Omit<
|
|
84
|
+
export type BandStripProps<T, X extends ChartX = ChartX, K extends string = string> = Omit<
|
|
87
85
|
CartesianChartProps<T, X>,
|
|
88
86
|
'marks' | 'series' | 'y' | 'y2' | 'zones' | 'xZones' | 'refLines'
|
|
89
87
|
> & {
|
|
90
|
-
states: readonly BandStripSeries<T>[]
|
|
88
|
+
states: readonly (BandStripSeries<T> & { key: K })[]
|
|
91
89
|
/** Which state, fill and marker each datum has. Memoize it: a new function recompiles the chart. */
|
|
92
90
|
getBand: (d: T) => BandSpan
|
|
93
91
|
fold?: BandFold<T> | undefined
|
|
@@ -97,7 +95,7 @@ export type BandStripProps<T, X extends ChartX = ChartX> = Omit<
|
|
|
97
95
|
* tooltip adds this state's row. Absent stays a legended, flat state, never a
|
|
98
96
|
* hatch: it reads as "no data" by hue and by sitting at the band's right edge, not as zero.
|
|
99
97
|
*/
|
|
100
|
-
absentState?:
|
|
98
|
+
absentState?: K | undefined
|
|
101
99
|
}
|
|
102
100
|
|
|
103
101
|
const DEFAULT_MIN_BAND_PX = 3
|
|
@@ -294,7 +292,9 @@ function layoutBands<T>(input: LayoutInput<T>): {
|
|
|
294
292
|
return { base: [...ctx.base.values()], markers: [...ctx.markers.values()], hits }
|
|
295
293
|
}
|
|
296
294
|
|
|
297
|
-
export function BandStrip<T, X extends ChartX = ChartX
|
|
295
|
+
export function BandStrip<T, X extends ChartX = ChartX, K extends string = string>(
|
|
296
|
+
props: BandStripProps<T, X, K>,
|
|
297
|
+
): ReactElement {
|
|
298
298
|
const {
|
|
299
299
|
states,
|
|
300
300
|
getBand,
|
|
@@ -306,14 +306,12 @@ export function BandStrip<T, X extends ChartX = ChartX>(props: BandStripProps<T,
|
|
|
306
306
|
} = props
|
|
307
307
|
const { data, x } = rest
|
|
308
308
|
// Resolved once: a misconfigured absent state degrades to primary-only paint, hits and rows.
|
|
309
|
-
const absentKey =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
states.map((s) => s.key),
|
|
316
|
-
)
|
|
309
|
+
const absentKey = resolveNamedState(
|
|
310
|
+
'BandStrip',
|
|
311
|
+
'BandStrip.absentState',
|
|
312
|
+
absentState,
|
|
313
|
+
states.map((s) => s.key),
|
|
314
|
+
)
|
|
317
315
|
|
|
318
316
|
const series = useMemo<ChartSeries<T>[]>(
|
|
319
317
|
() =>
|
|
@@ -322,6 +320,7 @@ export function BandStrip<T, X extends ChartX = ChartX>(props: BandStripProps<T,
|
|
|
322
320
|
label: s.label,
|
|
323
321
|
color: s.color,
|
|
324
322
|
mark: 'bar' as const,
|
|
323
|
+
...(s.fillOpacity !== undefined && { fillOpacity: s.fillOpacity }),
|
|
325
324
|
...(s.tooltip !== undefined && { tooltip: s.tooltip }),
|
|
326
325
|
...(s.legend !== undefined && { legend: s.legend }),
|
|
327
326
|
...(s.note !== undefined && { note: s.note }),
|
|
@@ -11,6 +11,8 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react'
|
|
|
11
11
|
import { useInChartCard } from './card-context'
|
|
12
12
|
import { compileCartesian, refLegendSeries } from './compile'
|
|
13
13
|
import type { CartesianDefinition } from './compile'
|
|
14
|
+
import { samePlots } from './plot-context'
|
|
15
|
+
import type { PlotSizes } from './plot-context'
|
|
14
16
|
import { ChartEngine, idPrefixOf } from './host'
|
|
15
17
|
import { ChartLegend, legendEntries } from './legend'
|
|
16
18
|
import { INITIAL_WIDTH, useChartSize } from './sizing'
|
|
@@ -69,6 +71,8 @@ export type ShellContext = {
|
|
|
69
71
|
coarse: boolean
|
|
70
72
|
/** The measured width; 0 unless the shell was asked to track it (`byWidth`). */
|
|
71
73
|
width: number
|
|
74
|
+
/** The plot area of each pane the engine last laid out; `null` until it has. */
|
|
75
|
+
plot: PlotSizes | null
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
export type ChartShellProps<T> = Pick<
|
|
@@ -99,9 +103,15 @@ export function ChartShell<T>(props: ChartShellProps<T>): ReactElement {
|
|
|
99
103
|
// Unmeasured (the server, the first client frame) is the regular class, as the engine's
|
|
100
104
|
// `initialWidth` is.
|
|
101
105
|
const width = byWidth ? measured || INITIAL_WIDTH : 0
|
|
106
|
+
// The engine lays the plot out AFTER `marks` runs, so a chart whose marks read the plot size
|
|
107
|
+
// (and only that chart) takes it from the layout and recompiles once.
|
|
108
|
+
const [plot, setPlot] = useState<PlotSizes | null>(null)
|
|
109
|
+
const onPlot = useCallback((next: PlotSizes) => {
|
|
110
|
+
setPlot((prev) => (samePlots(prev, next) ? prev : next))
|
|
111
|
+
}, [])
|
|
102
112
|
const definition = useMemo(
|
|
103
|
-
() => compile({ chartId, hidden, highlighted, coarse, width }),
|
|
104
|
-
[compile, chartId, hidden, highlighted, coarse, width],
|
|
113
|
+
() => compile({ chartId, hidden, highlighted, coarse, width, plot }),
|
|
114
|
+
[compile, chartId, hidden, highlighted, coarse, width, plot],
|
|
105
115
|
)
|
|
106
116
|
|
|
107
117
|
// ── legend: micro has none, compact shows dots, regular and wide show chips (CSS, § 9.6) ──────
|
|
@@ -116,6 +126,7 @@ export function ChartShell<T>(props: ChartShellProps<T>): ReactElement {
|
|
|
116
126
|
return next
|
|
117
127
|
})
|
|
118
128
|
}, [])
|
|
129
|
+
const resolved = resolveChartState(state)
|
|
119
130
|
const legendNode: ReactNode = useMemo(
|
|
120
131
|
() =>
|
|
121
132
|
shown ? (
|
|
@@ -127,16 +138,16 @@ export function ChartShell<T>(props: ChartShellProps<T>): ReactElement {
|
|
|
127
138
|
toggle={toggle}
|
|
128
139
|
onToggle={onToggle}
|
|
129
140
|
onHighlight={setHighlighted}
|
|
141
|
+
concealed={resolved !== null}
|
|
130
142
|
/>
|
|
131
143
|
) : null,
|
|
132
|
-
[shown, series, hidden, config?.groups, toggle, onToggle],
|
|
144
|
+
[shown, series, hidden, config?.groups, toggle, onToggle, resolved],
|
|
133
145
|
)
|
|
134
146
|
// `header` is the enclosing card's header row (`top` outside a card); either way the legend is
|
|
135
147
|
// the first thing in the chart's own markup.
|
|
136
148
|
const atTop = config?.placement === 'top' || config?.placement === 'header'
|
|
137
149
|
const asHeaderRow = config?.placement === 'header' && inCard
|
|
138
150
|
|
|
139
|
-
const resolved = resolveChartState(state)
|
|
140
151
|
return (
|
|
141
152
|
<div
|
|
142
153
|
ref={ref}
|
|
@@ -152,6 +163,7 @@ export function ChartShell<T>(props: ChartShellProps<T>): ReactElement {
|
|
|
152
163
|
height={height}
|
|
153
164
|
idPrefix={idPrefixOf(chartId)}
|
|
154
165
|
coarse={coarse}
|
|
166
|
+
onPlot={onPlot}
|
|
155
167
|
/>
|
|
156
168
|
) : (
|
|
157
169
|
<ChartPlaceholder state={state} height={height} />
|
package/src/charts/DualPanel.tsx
CHANGED
|
@@ -18,10 +18,11 @@ import { defaultFormatX, defaultNumberFormat, engineRow, seriesRow, visibleSerie
|
|
|
18
18
|
import { barMark, emphasis, lineMark, markersOf, thinFill } from './marks'
|
|
19
19
|
import { PanelRung, chartHeightOf, paneX, paneY, rowsOf } from './panel'
|
|
20
20
|
import type { PaneBuilder, PanelInput, PanelPlan } from './panel'
|
|
21
|
+
import { plotContext } from './plot-context'
|
|
21
22
|
import type { SignedSeries } from './legend'
|
|
22
23
|
import { xScaleFor } from './scales'
|
|
23
24
|
import { rowX } from './types'
|
|
24
|
-
import type { CartesianChartProps, ChartSeries,
|
|
25
|
+
import type { CartesianChartProps, ChartSeries, PlotRow } from './types'
|
|
25
26
|
|
|
26
27
|
// ── DualPanel ───────────────────────────────────────────────────────────────────────────────────
|
|
27
28
|
|
|
@@ -228,23 +229,27 @@ export function DualPanel<T, X extends Date | number = Date | number>(
|
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
|
|
231
|
-
const topPane: PaneBuilder = ({ width, height: h }) => {
|
|
232
|
+
const topPane: PaneBuilder = ({ width, height: h, plot: access }) => {
|
|
232
233
|
const cls = resolveContainerClass(width)
|
|
233
|
-
const plot
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const plot = plotContext<T, Date | number>(
|
|
235
|
+
{
|
|
236
|
+
rows: (key) => {
|
|
237
|
+
const s = lines.find((l) => l.key === key)
|
|
238
|
+
if (!s) throw new Error(`[basalt] DualPanel: no series "${key}"`)
|
|
239
|
+
return rows(s)
|
|
240
|
+
},
|
|
241
|
+
visible,
|
|
242
|
+
highlighted,
|
|
243
|
+
containerClass: cls,
|
|
244
|
+
width,
|
|
245
|
+
height: h,
|
|
246
|
+
data,
|
|
247
|
+
y2: undefined,
|
|
248
|
+
yDomain: topDomain,
|
|
249
|
+
y2Domain: undefined,
|
|
238
250
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
containerClass: cls,
|
|
242
|
-
width,
|
|
243
|
-
height: h,
|
|
244
|
-
y2: undefined,
|
|
245
|
-
yDomain: topDomain,
|
|
246
|
-
y2Domain: undefined,
|
|
247
|
-
}
|
|
251
|
+
access,
|
|
252
|
+
)
|
|
248
253
|
return {
|
|
249
254
|
marks: [
|
|
250
255
|
...(fill
|