basalt-ui 2.10.0 → 2.11.1
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 +25 -0
- package/MIGRATING.md +36 -13
- package/agent/rules/basalt-charts.md +2 -2
- package/agent/skills/basalt-charts/SKILL.md +16 -17
- package/dist/charts/BandStrip.d.ts +3 -2
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/CartesianChart.d.ts +3 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/CartesianChart.js +9 -3
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +21 -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/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +7 -45
- package/dist/charts/MirroredBars.js +2 -2
- 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 +7 -0
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/compile.d.ts +4 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +43 -19
- 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/labels.d.ts +34 -0
- package/dist/charts/labels.d.ts.map +1 -0
- package/dist/charts/labels.js +63 -0
- package/dist/charts/marks.d.ts +8 -1
- package/dist/charts/marks.d.ts.map +1 -1
- package/dist/charts/marks.js +50 -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 +6 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +28 -8
- package/dist/charts/ticks.d.ts +12 -0
- package/dist/charts/ticks.d.ts.map +1 -0
- package/dist/charts/ticks.js +42 -0
- package/dist/charts/types.d.ts +39 -5
- package/dist/charts/types.d.ts.map +1 -1
- 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 +12 -4
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +2 -5
- package/src/charts/CartesianChart.tsx +13 -2
- package/src/charts/DualPanel.tsx +22 -16
- package/src/charts/Heatmap.tsx +181 -76
- package/src/charts/Lines.tsx +11 -57
- package/src/charts/MirroredBars.tsx +2 -2
- package/src/charts/Sparkline.tsx +106 -5
- package/src/charts/band-fold.ts +11 -0
- package/src/charts/compile.ts +60 -20
- 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/labels.ts +118 -0
- package/src/charts/marks.ts +72 -14
- package/src/charts/panel.tsx +18 -5
- package/src/charts/plot-context.ts +109 -0
- package/src/charts/scales.ts +41 -11
- package/src/charts/ticks.ts +61 -0
- package/src/charts/types.ts +39 -5
- package/src/tokens/core.ts +10 -3
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const MAIN_PANE = "main";
|
|
2
|
+
const PLOT_EPSILON_PX = 0.01;
|
|
3
|
+
const samePlot = (a, b) => Math.abs(a.width - b.width) < PLOT_EPSILON_PX && Math.abs(a.height - b.height) < PLOT_EPSILON_PX;
|
|
4
|
+
function samePlots(a, b) {
|
|
5
|
+
if (a === null) return false;
|
|
6
|
+
const keys = Object.keys(b);
|
|
7
|
+
return keys.length === Object.keys(a).length && keys.every((k) => {
|
|
8
|
+
const prev = a[k];
|
|
9
|
+
const next = b[k];
|
|
10
|
+
return prev !== void 0 && next !== void 0 && samePlot(prev, next);
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
const READS = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const readsOf = (definition) => {
|
|
15
|
+
const found = READS.get(definition);
|
|
16
|
+
if (found) return found;
|
|
17
|
+
const created = { read: false, onLateRead: void 0, measured: null };
|
|
18
|
+
READS.set(definition, created);
|
|
19
|
+
return created;
|
|
20
|
+
};
|
|
21
|
+
const readsPlot = (definition) => READS.get(definition)?.read === true;
|
|
22
|
+
function watchPlotReads(definition, onLateRead) {
|
|
23
|
+
readsOf(definition).onLateRead = onLateRead;
|
|
24
|
+
}
|
|
25
|
+
const recordPlots = (definition, sizes) => {
|
|
26
|
+
readsOf(definition).measured = sizes;
|
|
27
|
+
};
|
|
28
|
+
const measuredPlots = (definition) => READS.get(definition)?.measured ?? null;
|
|
29
|
+
function plotAccess(definition, sizes, pane) {
|
|
30
|
+
return {
|
|
31
|
+
size: () => sizes?.[pane] ?? null,
|
|
32
|
+
read: () => {
|
|
33
|
+
const reads = readsOf(definition);
|
|
34
|
+
if (reads.read) return;
|
|
35
|
+
reads.read = true;
|
|
36
|
+
reads.onLateRead?.();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function plotContext(base, access) {
|
|
41
|
+
const measured = (side) => {
|
|
42
|
+
access.read();
|
|
43
|
+
return access.size()?.[side] ?? (side === "width" ? base.width : base.height);
|
|
44
|
+
};
|
|
45
|
+
return Object.defineProperties(
|
|
46
|
+
{ ...base },
|
|
47
|
+
{
|
|
48
|
+
plotWidth: { enumerable: true, get: () => measured("width") },
|
|
49
|
+
plotHeight: { enumerable: true, get: () => measured("height") }
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
MAIN_PANE,
|
|
55
|
+
PLOT_EPSILON_PX,
|
|
56
|
+
measuredPlots,
|
|
57
|
+
plotAccess,
|
|
58
|
+
plotContext,
|
|
59
|
+
readsPlot,
|
|
60
|
+
recordPlots,
|
|
61
|
+
samePlot,
|
|
62
|
+
samePlots,
|
|
63
|
+
watchPlotReads
|
|
64
|
+
};
|
package/dist/charts/scales.d.ts
CHANGED
|
@@ -38,7 +38,12 @@ export type XScaleModel<X extends ChartX> = {
|
|
|
38
38
|
extent?: readonly [number, number];
|
|
39
39
|
step: number;
|
|
40
40
|
};
|
|
41
|
-
export declare function xScaleFor<X extends ChartX>(raw: readonly X[],
|
|
41
|
+
export declare function xScaleFor<X extends ChartX>(raw: readonly X[],
|
|
42
|
+
/** `'flush'`: a band scale with no outer padding, so the first and last band meet the plot's
|
|
43
|
+
* edges (`MirroredBars`); `true` pads half a gap-and-a-bit at each end, as `Bars` does. */
|
|
44
|
+
band: boolean | 'flush',
|
|
45
|
+
/** Continuous scales only: the explicit `[min, max]` that replaces the data's own extent. */
|
|
46
|
+
xDomain?: readonly [X, X]): XScaleModel<X>;
|
|
42
47
|
/** An x-zone's [left, right] as plot fractions, clamped to the plot; `null` when it is empty. */
|
|
43
48
|
export declare function xZoneFractions<X extends ChartX>(zone: XZoneSpec<X>, model: XScaleModel<X>): readonly [number, number] | null;
|
|
44
49
|
//# sourceMappingURL=scales.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../src/charts/scales.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAE5D,OAAO,EAAE,QAAQ,EAAY,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAIzE,gGAAgG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MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IACpB,uFAAuF;IACvF,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,IAAI,CAAA;IACjC,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAA;IAChB,2FAA2F;IAC3F,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAoBD,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,GAAG,EAAE,SAAS,CAAC,EAAE;AACjB;2FAC2F;AAC3F,IAAI,EAAE,OAAO,GAAG,OAAO;AACvB,6FAA6F;AAC7F,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GACxB,WAAW,CAAC,CAAC,CAAC,CAwFhB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAC7C,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAClB,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GACpB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAOlC"}
|
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,16 +70,31 @@ 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;
|
|
78
92
|
const index = new Map(keys.map((k, i) => [keyOf(k), i]));
|
|
79
93
|
if (band) {
|
|
80
|
-
const
|
|
81
|
-
const
|
|
94
|
+
const outer = band === "flush" ? 0 : BAND_PADDING_OUTER;
|
|
95
|
+
const steps = n - BAND_PADDING_INNER + 2 * outer;
|
|
96
|
+
const step2 = 1 / (steps > 0 ? steps : 1);
|
|
97
|
+
const scale2 = scaleBand().domain(keys).paddingInner(BAND_PADDING_INNER).paddingOuter(outer);
|
|
82
98
|
return {
|
|
83
99
|
kind,
|
|
84
100
|
band: true,
|
|
@@ -89,7 +105,7 @@ function xScaleFor(raw, band) {
|
|
|
89
105
|
fraction: (x) => {
|
|
90
106
|
const i = index.get(keyOf(x));
|
|
91
107
|
if (i === void 0) return null;
|
|
92
|
-
return step2 * (
|
|
108
|
+
return step2 * (outer + i + (1 - BAND_PADDING_INNER) / 2);
|
|
93
109
|
}
|
|
94
110
|
};
|
|
95
111
|
}
|
|
@@ -107,7 +123,7 @@ function xScaleFor(raw, band) {
|
|
|
107
123
|
}
|
|
108
124
|
};
|
|
109
125
|
}
|
|
110
|
-
const nums = values.map(
|
|
126
|
+
const nums = values.map(toNumber);
|
|
111
127
|
let lo = Infinity;
|
|
112
128
|
let hi = -Infinity;
|
|
113
129
|
for (const v of nums) {
|
|
@@ -119,7 +135,11 @@ function xScaleFor(raw, band) {
|
|
|
119
135
|
if (v > hi) hi = v;
|
|
120
136
|
}
|
|
121
137
|
if (!Number.isFinite(lo)) [lo, hi] = [0, 1];
|
|
122
|
-
|
|
138
|
+
const explicit = explicitDomain(xDomain);
|
|
139
|
+
if (explicit !== null) {
|
|
140
|
+
;
|
|
141
|
+
[lo, hi] = explicit;
|
|
142
|
+
} else if (lo === hi) {
|
|
123
143
|
const half = kind === "date" ? DAY_MS / 2 : 0.5;
|
|
124
144
|
lo -= half;
|
|
125
145
|
hi += half;
|
|
@@ -138,7 +158,7 @@ function xScaleFor(raw, band) {
|
|
|
138
158
|
extent: [lo, hi],
|
|
139
159
|
step: medianGap,
|
|
140
160
|
fraction: (x) => {
|
|
141
|
-
const v = x
|
|
161
|
+
const v = toNumber(x);
|
|
142
162
|
return typeof v === "number" && Number.isFinite(v) ? (v - lo) / span : null;
|
|
143
163
|
}
|
|
144
164
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Every n-th value, n the smallest stride that leaves at most `count` of them. */
|
|
2
|
+
export declare function strideEvery<V>(values: readonly V[], count: number): V[];
|
|
3
|
+
/**
|
|
4
|
+
* Ticks of a bucketed Date axis: the time scale's own round instants, each snapped to the bucket
|
|
5
|
+
* it falls in. Labelling every bucket and letting the engine thin the collisions leaves an uneven,
|
|
6
|
+
* near-touching subset ("18:13 18:17 18:21"); round instants are evenly spaced whenever the
|
|
7
|
+
* buckets are. A bucket is used once, and a round instant with no bucket within a step of it is
|
|
8
|
+
* dropped. Fewer than two picks falls back to a plain stride over the distinct,
|
|
9
|
+
* sorted buckets. `count` must be finite (`xTickPolicy` guards it). O(ticks · log buckets) after the sort.
|
|
10
|
+
*/
|
|
11
|
+
export declare function bucketTicks(values: readonly Date[], count: number): Date[];
|
|
12
|
+
//# sourceMappingURL=ticks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../src/charts/ticks.ts"],"names":[],"mappings":"AAMA,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,EAAE,CAGvE;AAuBD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAmB1E"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { scaleUtc } from "d3-scale";
|
|
2
|
+
function strideEvery(values, count) {
|
|
3
|
+
const stride = Math.max(1, Math.ceil(values.length / Math.max(1, count)));
|
|
4
|
+
return values.filter((_, i) => i % stride === 0);
|
|
5
|
+
}
|
|
6
|
+
function medianGap(sorted) {
|
|
7
|
+
const gaps = sorted.slice(1).map((t, i) => t - sorted[i]);
|
|
8
|
+
return gaps.toSorted((a, b) => a - b)[gaps.length >> 1];
|
|
9
|
+
}
|
|
10
|
+
function nearestIndex(sorted, target) {
|
|
11
|
+
let lo = 0;
|
|
12
|
+
let hi = sorted.length - 1;
|
|
13
|
+
while (lo < hi) {
|
|
14
|
+
const mid = lo + hi >> 1;
|
|
15
|
+
if (sorted[mid] < target) lo = mid + 1;
|
|
16
|
+
else hi = mid;
|
|
17
|
+
}
|
|
18
|
+
const before = lo - 1;
|
|
19
|
+
return before >= 0 && target - sorted[before] <= sorted[lo] - target ? before : lo;
|
|
20
|
+
}
|
|
21
|
+
function bucketTicks(values, count) {
|
|
22
|
+
const times = [...new Set(values.map((v) => v.getTime()).filter(Number.isFinite))].toSorted(
|
|
23
|
+
(a, b) => a - b
|
|
24
|
+
);
|
|
25
|
+
const asDates = (ts) => ts.map((t) => new Date(t));
|
|
26
|
+
const first = times[0];
|
|
27
|
+
const last = times.at(-1);
|
|
28
|
+
if (first === void 0 || last === void 0 || first === last) return asDates(times);
|
|
29
|
+
const step = medianGap(times);
|
|
30
|
+
const want = Math.max(1, Math.floor(count));
|
|
31
|
+
const picked = /* @__PURE__ */ new Set();
|
|
32
|
+
for (const tick of scaleUtc().domain([new Date(first), new Date(last)]).ticks(want)) {
|
|
33
|
+
const t = tick.getTime();
|
|
34
|
+
const near = times[nearestIndex(times, t)];
|
|
35
|
+
if (near !== void 0 && Math.abs(near - t) < step) picked.add(near);
|
|
36
|
+
}
|
|
37
|
+
return asDates(picked.size >= 2 ? [...picked] : strideEvery(times, want));
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
bucketTicks,
|
|
41
|
+
strideEvery
|
|
42
|
+
};
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -61,10 +61,15 @@ 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. Always-on markers are `Lines`'
|
|
69
|
+
* alone. On a `CartesianChart` with consumer `marks` only the CURSOR dot of a `cursorValue`
|
|
70
|
+
* series reads `getMarker` (its `color`): without `cursorValue` it is ignored there, so draw a
|
|
71
|
+
* persistent dot in `marks` yourself. Each distinct color is one extra mark: keep colors a small
|
|
72
|
+
* categorical set (statuses, buckets), never a continuous scale. */
|
|
68
73
|
getMarker?: ((d: T) => {
|
|
69
74
|
color?: string | undefined;
|
|
70
75
|
r?: number | undefined;
|
|
@@ -220,11 +225,33 @@ export type PlotContext<T, X extends ChartX = ChartX> = {
|
|
|
220
225
|
highlighted: string | null;
|
|
221
226
|
/** The measured container class (`regular` on the server). */
|
|
222
227
|
containerClass: ContainerClass;
|
|
223
|
-
/** The chart's
|
|
228
|
+
/** The chart's FRAME in px (plot plus axis gutters), for a kind that lays out labels against it. */
|
|
224
229
|
width: number;
|
|
225
230
|
height: number;
|
|
231
|
+
/**
|
|
232
|
+
* The plot area in px: the frame less the axis gutters. Pin a mark in pixels with it (a 3 px
|
|
233
|
+
* rail along the top is `yMax - 3 * (yMax - yMin) / plot.plotHeight` down from `yMax`). The
|
|
234
|
+
* engine measures its gutters after `marks` runs, so the first pass (the server HTML, the first
|
|
235
|
+
* client frame) reports the FRAME, one frame-sized draw; the chart then re-renders once with the
|
|
236
|
+
* measured area, and only a chart whose `marks` read these fields pays that render. Every kind,
|
|
237
|
+
* single or composed, reports it the same way.
|
|
238
|
+
*/
|
|
239
|
+
plotWidth: number;
|
|
240
|
+
plotHeight: number;
|
|
241
|
+
/**
|
|
242
|
+
* Every row of `data`, whatever the legend hides: raw datums (`T`), NOT `PlotRow`s. For bucket-level marks only (absent columns,
|
|
243
|
+
* rails: the slot grid must not vanish with its last visible series); a series' own marks still
|
|
244
|
+
* draw `plot.rows(key)` and gate on `plot.visible`.
|
|
245
|
+
*/
|
|
246
|
+
data: readonly T[];
|
|
226
247
|
/** Bind a mark to the right axis with `yScale: plot.y2` (present only with a `y2` config). */
|
|
227
248
|
y2: 'y2' | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* Where an x value sits in the plot, 0 (left edge) to 1 (right edge), on the SAME x scale the
|
|
251
|
+
* axis draws: an explicit `xDomain` or the extent of every datum. Outside [0, 1] a value is
|
|
252
|
+
* clipped; `null` for a value the scale cannot place.
|
|
253
|
+
*/
|
|
254
|
+
xFraction: (x: X) => number | null;
|
|
228
255
|
/** The resolved y domain (and the right axis', with `y2`): basalt's, never the engine's. */
|
|
229
256
|
yDomain: readonly [number, number];
|
|
230
257
|
y2Domain: readonly [number, number] | undefined;
|
|
@@ -245,6 +272,13 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
245
272
|
y2?: AxisConfig<T> | undefined;
|
|
246
273
|
/** A tick count, or the exact x tick values. Default: by container class. */
|
|
247
274
|
xTicks?: number | readonly X[] | undefined;
|
|
275
|
+
/**
|
|
276
|
+
* `[min, max]` of the x scale, in `x`'s type. Default: the data's own extent. Charts given the
|
|
277
|
+
* same domain put the same instant on the same pixel column, whatever their data spans; rows
|
|
278
|
+
* outside it are clipped. A domain that is reversed, flat or not finite falls back to the data
|
|
279
|
+
* extent (and warns in dev). A no-op on a string or band x (`Bars`, `MirroredBars`, `BandStrip`).
|
|
280
|
+
*/
|
|
281
|
+
xDomain?: readonly [X, X] | undefined;
|
|
248
282
|
/** Tick label for an x value. Default: `DD.MM` for dates, compact numbers, strings verbatim. */
|
|
249
283
|
formatX?: ((x: X) => string) | undefined;
|
|
250
284
|
zones?: readonly ZoneSpec[] | undefined;
|
|
@@ -256,8 +290,8 @@ export type CartesianChartProps<T, X extends ChartX = ChartX> = BasaltProps & {
|
|
|
256
290
|
* Default: the height law (measured width × class ratio, 160–420px, ≤ 45vh on touch). Always the
|
|
257
291
|
* FRAME, in every kind: the plot plus the axis the engine measures. A `BandStrip` band is the
|
|
258
292
|
* frame less the x axis (about 21 px at the default font and density, so `height: 65` for a
|
|
259
|
-
* 44 px band).
|
|
260
|
-
*
|
|
293
|
+
* 44 px band). The box is CSS-owned before any measurement exists, so the plot area is read back
|
|
294
|
+
* from the engine's layout (`PlotContext.plotWidth`/`plotHeight`), never an input.
|
|
261
295
|
*/
|
|
262
296
|
height?: number | ResponsiveChartHeight | undefined;
|
|
263
297
|
state?: ChartState | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/charts/types.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G,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IACxC,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,CAAA;IACvC,MAAM,CAAC,EAAE,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAA;IAC5C,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,CAAA;IACzC,gCAAgC;IAChC,MAAM,CAAC,EAAE,iBAAiB,GAAG,KAAK,GAAG,SAAS,CAAA;IAC9C;;;;;;OAMG;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"}
|
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,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvD,8FAA8F;AAC9F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEjD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,OAAO,MAAM,EAAE,GAAG,MAAM,KAAG,MACoB,CAA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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.1
|
|
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.1
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -238,6 +238,7 @@ Signature: BandStrip(props: BandStripProps<T, X, K>): ReactElement<unknown, stri
|
|
|
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,7 +246,7 @@ Signature: BandStrip(props: BandStripProps<T, X, K>): ReactElement<unknown, stri
|
|
|
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
252
|
absentState?: K
|
|
@@ -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>[]
|
|
@@ -422,6 +429,7 @@ Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, str
|
|
|
422
429
|
data: readonly T[]
|
|
423
430
|
x: (d: T) => X
|
|
424
431
|
xTicks?: number | readonly X[]
|
|
432
|
+
xDomain?: readonly [X, X]
|
|
425
433
|
formatX?: ((x: X) => string)
|
|
426
434
|
zones?: readonly ZoneSpec[]
|
|
427
435
|
xZones?: readonly XZoneSpec<X>[]
|
package/package.json
CHANGED
package/src/charts/BandStrip.tsx
CHANGED
|
@@ -21,7 +21,7 @@ import { NON_FINITE } from '../format/shared'
|
|
|
21
21
|
import { VX, alpha } from '../tokens'
|
|
22
22
|
import { CartesianRung } from './CartesianChart'
|
|
23
23
|
import { groupsOf, resolveNamedState } from './band-fold'
|
|
24
|
-
import type { Group } from './band-fold'
|
|
24
|
+
import type { Group, NamedChartState } from './band-fold'
|
|
25
25
|
import { emphasis } from './marks'
|
|
26
26
|
import { rowX } from './types'
|
|
27
27
|
import type {
|
|
@@ -35,10 +35,7 @@ import type {
|
|
|
35
35
|
} from './types'
|
|
36
36
|
|
|
37
37
|
/** A state a strip can draw. A band has no number to plot, so `formatValue` reads the datum. */
|
|
38
|
-
export type BandStripSeries<T> =
|
|
39
|
-
ChartSeries<T>,
|
|
40
|
-
'key' | 'label' | 'color' | 'tooltip' | 'legend' | 'note' | 'fillOpacity'
|
|
41
|
-
> & {
|
|
38
|
+
export type BandStripSeries<T> = NamedChartState & {
|
|
42
39
|
/**
|
|
43
40
|
* The tooltip row's value for a band in this state. `null` is an ABSENT reading and renders an
|
|
44
41
|
* em dash; omit the function when the state's name is the whole reading ("Not measured").
|
|
@@ -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) ──────
|
|
@@ -153,6 +163,7 @@ export function ChartShell<T>(props: ChartShellProps<T>): ReactElement {
|
|
|
153
163
|
height={height}
|
|
154
164
|
idPrefix={idPrefixOf(chartId)}
|
|
155
165
|
coarse={coarse}
|
|
166
|
+
onPlot={onPlot}
|
|
156
167
|
/>
|
|
157
168
|
) : (
|
|
158
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,28 @@ 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
|
+
xFraction: model.fraction,
|
|
248
|
+
y2: undefined,
|
|
249
|
+
yDomain: topDomain,
|
|
250
|
+
y2Domain: undefined,
|
|
238
251
|
},
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
containerClass: cls,
|
|
242
|
-
width,
|
|
243
|
-
height: h,
|
|
244
|
-
y2: undefined,
|
|
245
|
-
yDomain: topDomain,
|
|
246
|
-
y2Domain: undefined,
|
|
247
|
-
}
|
|
252
|
+
access,
|
|
253
|
+
)
|
|
248
254
|
return {
|
|
249
255
|
marks: [
|
|
250
256
|
...(fill
|