@vitavision/charts 0.6.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/LICENSE-APACHE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vitaly Vorobyev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # @vitavision/charts
2
+
3
+ Small, hand-rolled SVG charts for the vitavision lab apps, on `@vitavision/ui` tokens.
4
+
5
+ ```bash
6
+ bun add @vitavision/charts @vitavision/ui
7
+ ```
8
+
9
+ ```css
10
+ @import "@vitavision/ui/styles.css";
11
+ @import "@vitavision/charts/styles.css";
12
+ ```
13
+
14
+ Both imports are required: `ui/styles.css` defines the chrome and verdict tokens
15
+ (`--normal`, `--defect`), and `charts/styles.css` defines the categorical series palette
16
+ (`--series-1` … `--series-6`, light and dark). `SERIES_COLOURS`, `seriesColour()`,
17
+ `NORMAL_COLOUR` and `DEFECT_COLOUR` are `var(--…)` paint values that resolve through those
18
+ tokens, so they follow the theme; use them anywhere a CSS colour or an SVG `fill`/`stroke`
19
+ is accepted.
20
+
21
+ **Charts** — hand-rolled SVG over the pure domain/tick/project math in `scale.ts`:
22
+ `Frame` + `Legend` (the axes/grid/label shell every chart composes), `LineChart`
23
+ (multi-series, optional log y), `StackedBars`, `ScoreHistogram` (two-class distribution
24
+ with a threshold rule), and `LineProfile` (one or more series against arc length in pixels
25
+ along a scan line or caliper axis, with detected edges drawn as labelled vertical rules).
26
+
27
+ ## License
28
+
29
+ Licensed under either of
30
+
31
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
32
+ - MIT license ([LICENSE-MIT](LICENSE-MIT))
33
+
34
+ at your option.
35
+
36
+ Unless you explicitly state otherwise, any contribution intentionally submitted
37
+ for inclusion in this package by you, as defined in the Apache-2.0 license, shall
38
+ be dual licensed as above, without any additional terms or conditions.
@@ -0,0 +1,420 @@
1
+ import { MeasureTone } from "@vitavision/ui";
2
+ import { ReactNode } from "react";
3
+ //#region src/scale.d.ts
4
+ /**
5
+ * The arithmetic behind every chart: domains, ticks, and the map from a value to a pixel.
6
+ *
7
+ * Hand-rolled SVG rather than a charting library: the chart types this design system needs
8
+ * are few and simple, and a library that lags the React and Tailwind versions the lab apps
9
+ * are deliberately on would mean either downgrading a consumer or isolating a laggard — a
10
+ * cost that outweighs a few hundred lines of scale maths.
11
+ *
12
+ * Everything here is pure. That is the point: it is the part worth unit-testing, and it
13
+ * leaves the components themselves as thin as an SVG element list.
14
+ */
15
+ /** A tick's position in domain units, with the label to draw beside it. */
16
+ interface Tick {
17
+ /** Where the tick sits, in domain units — pass it to {@link Scale.project}. */
18
+ value: number;
19
+ /** The text to draw beside it, formatted by {@link formatTick}. */
20
+ label: string;
21
+ }
22
+ /**
23
+ * A map from a numeric domain onto a pixel range, with the ticks to label it.
24
+ *
25
+ * @remarks
26
+ * Built by {@link linearScale} or {@link logScale}. `project` is not clamped: a value
27
+ * outside the domain lands outside the range.
28
+ */
29
+ interface Scale {
30
+ /** Domain, after padding and after any log transform's guard. */
31
+ domain: [number, number];
32
+ /** Map one domain value onto the pixel range this scale was built for. */
33
+ project: (value: number) => number;
34
+ /**
35
+ * Ticks inside the domain, in ascending order.
36
+ *
37
+ * @param count - Roughly how many ticks to aim for (default 5). The result may have a
38
+ * few more or fewer: steps are "nice" (see {@link niceStep}), or whole decades on a log
39
+ * scale.
40
+ */
41
+ ticks: (count?: number) => Tick[];
42
+ }
43
+ /**
44
+ * A "nice" step at or above `rough` — one of 1, 2, 2.5 or 5 times a power of ten.
45
+ *
46
+ * Axis labels a reader can hold in their head are the whole reason: 0.25 / 0.50 / 0.75
47
+ * rather than 0.237 / 0.474 / 0.711.
48
+ */
49
+ export declare function niceStep(rough: number): number;
50
+ /**
51
+ * The label for one tick: as many decimals as the step needs, or an exponent for a
52
+ * magnitude below 1e-3 or from 1e6 upwards.
53
+ *
54
+ * @param value - The tick's value.
55
+ * @param step - The spacing between neighbouring ticks; it decides the decimals.
56
+ * @returns The label, or `""` for a non-finite value.
57
+ */
58
+ export declare function formatTick(value: number, step: number): string;
59
+ /**
60
+ * Widen a degenerate domain into one that can be drawn.
61
+ *
62
+ * A single-point series, or a constant one, has `min === max`. Left alone that divides by
63
+ * zero and the line vanishes; widened, the point sits in the middle of a sensible axis,
64
+ * which is what watching the first moments of a training run, or a profile with one sample
65
+ * so far, should look like.
66
+ */
67
+ export declare function padDomain(min: number, max: number): [number, number];
68
+ /**
69
+ * The `[min, max]` of the finite values, ignoring `NaN` and infinities.
70
+ *
71
+ * @returns `[0, 1]` when there is no finite value, so an empty series still has an axis.
72
+ */
73
+ export declare function extent(values: readonly number[]): [number, number];
74
+ /** A linear scale from `domain` onto `[rangeStart, rangeEnd]` pixels. */
75
+ export declare function linearScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale;
76
+ /**
77
+ * A base-10 log scale, for series that span decades.
78
+ *
79
+ * A loss curve is the canonical case: three terms that span decades and start far apart
80
+ * are a flat line along the bottom for two of the three on a linear axis. Non-positive
81
+ * values are clamped to `LOG_FLOOR` rather than dropped: a value that reaches exactly zero
82
+ * is a real observation, and a gap in the line would read as missing data.
83
+ */
84
+ export declare function logScale(domain: [number, number], rangeStart: number, rangeEnd: number): Scale;
85
+ /** An SVG `d` attribute through the projected points, skipping non-finite ones. */
86
+ export declare function linePath(points: readonly {
87
+ x: number;
88
+ y: number;
89
+ }[], xScale: Scale, yScale: Scale): string;
90
+ /**
91
+ * Bin values into `count` equal-width buckets over their own extent.
92
+ *
93
+ * Used for the score histogram, where the two classes must share one set of edges or the
94
+ * bars cannot be compared. Callers pass the shared domain in for exactly that reason.
95
+ */
96
+ export declare function histogram(values: readonly number[], domain: [number, number], count: number): number[];
97
+ //#endregion
98
+ //#region src/Frame.d.ts
99
+ /**
100
+ * Where a chart is going: `panel` (a 480×280 viewBox) for one column of a two-column grid,
101
+ * `wide` (960×320) for a chart that spans a panel on its own.
102
+ *
103
+ * @remarks
104
+ * Pick it by placement, not by pixel width — it keeps the chart's text at the same rendered
105
+ * size as its neighbours'.
106
+ */
107
+ type Variant = "panel" | "wide";
108
+ /**
109
+ * The drawable rectangle for one variant, in that variant's viewBox units.
110
+ *
111
+ * @param variant - Which viewBox the chart is drawn in.
112
+ * @returns The plot area's edges — `x0`/`x1` left to right, `y0` the bottom and `y1` the top
113
+ * (SVG y grows downwards) — and the whole viewBox's `width`/`height`. Build scales over
114
+ * `[x0, x1]` and `[y0, y1]`.
115
+ */
116
+ export declare function areaFor(variant: Variant): {
117
+ x0: 56;
118
+ x1: number;
119
+ y0: number;
120
+ y1: 12;
121
+ width: 480 | 960;
122
+ height: 280 | 320;
123
+ };
124
+ /** The default geometry, for callers that do not care which variant they are in. */
125
+ export declare const plotArea: {
126
+ x0: 56;
127
+ x1: number;
128
+ y0: number;
129
+ y1: 12;
130
+ width: 480 | 960;
131
+ height: 280 | 320;
132
+ };
133
+ /** Props for {@link Frame}. */
134
+ interface FrameProps {
135
+ /** The horizontal scale, built over this variant's `x0`…`x1` (see {@link areaFor}). */
136
+ xScale: Scale;
137
+ /** The vertical scale, built over this variant's `y0`…`y1` (see {@link areaFor}). */
138
+ yScale: Scale;
139
+ /** Axis title under the x axis. Omitted: no title. */
140
+ xLabel?: string | undefined;
141
+ /** Axis title beside the y axis, rotated. Omitted: no title. */
142
+ yLabel?: string | undefined;
143
+ /** Rough number of x ticks to ask the scale for. Default 5. */
144
+ xTicks?: number;
145
+ /** Rough number of y ticks to ask the scale for. Default 4. */
146
+ yTicks?: number;
147
+ /** Drawn inside the plot area, above the grid and below nothing. */
148
+ children?: ReactNode;
149
+ /** Accessible name — every chart must have one; it is what the tests query on. */
150
+ label: string;
151
+ /** Rendered under the plot: a legend, a caption, a truncation note. */
152
+ footer?: ReactNode;
153
+ /** Where this chart is going, so its text renders at the same size as its neighbours. */
154
+ variant?: Variant;
155
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
156
+ className?: string | undefined;
157
+ }
158
+ /**
159
+ * The plot shell every chart here composes: grid, ticks, axes, axis titles, a footer.
160
+ *
161
+ * @remarks
162
+ * Renders a `<figure>` holding an SVG with `role="img"` named by `label`, and the `footer`
163
+ * as its `<figcaption>`. `children` are drawn in viewBox units over the grid.
164
+ */
165
+ export declare function Frame({ xScale, yScale, xLabel, yLabel, xTicks, yTicks, children, label, footer, variant, className }: FrameProps): import("react").JSX.Element;
166
+ /** One entry of a {@link Legend}. */
167
+ interface LegendItem {
168
+ /** The series name, rendered as text — it is what a screen reader announces. */
169
+ label: string;
170
+ /** Any CSS colour: a `var(--series-n)` from {@link seriesColour}, or a verdict token. */
171
+ colour: string;
172
+ }
173
+ /** Props for {@link Legend}. */
174
+ interface LegendProps {
175
+ /** Entries, in the order the series were drawn. */
176
+ items: LegendItem[];
177
+ /** Extra classes for the `<ul>`, merged with `cn`. */
178
+ className?: string | undefined;
179
+ }
180
+ /**
181
+ * A legend row. Kept beside the frame rather than inside the SVG so the swatches are real
182
+ * text and CSS rather than a second typography in viewBox units.
183
+ *
184
+ * @remarks
185
+ * The swatches are `aria-hidden`; each series is identified by its name, never by colour
186
+ * alone.
187
+ */
188
+ export declare function Legend({ items, className }: LegendProps): import("react").JSX.Element;
189
+ /**
190
+ * The shared categorical series palette, as CSS paint values: `var(--series-1)` …
191
+ * `var(--series-6)`.
192
+ *
193
+ * @remarks
194
+ * The colours themselves are tokens in `@vitavision/charts/styles.css`, defined for both
195
+ * themes, so that stylesheet must be imported after `@vitavision/ui/styles.css`. The chrome
196
+ * carries no saturation, which makes this the one place a chart is allowed to be loud.
197
+ *
198
+ * Each slot keeps its hue family across the themes — cyan, orange, violet, blue, pink, then
199
+ * a neutral grey as the sixth — and only its lightness changes, so every colour holds 3:1
200
+ * against the panel in both. The six stay distinguishable under simulated protanopia,
201
+ * deuteranopia and tritanopia, and none of them is a verdict colour (`--normal`,
202
+ * `--defect`, `--warn`): a series is never read as a verdict (PLAN §5).
203
+ *
204
+ * Before 0.6 these were fixed hex strings; the names are unchanged.
205
+ */
206
+ export declare const SERIES_COLOURS: readonly ["var(--series-1)", "var(--series-2)", "var(--series-3)", "var(--series-4)", "var(--series-5)", "var(--series-6)"];
207
+ /**
208
+ * The paint for outcomes judged normal — `var(--normal)`, the design system's verdict token.
209
+ *
210
+ * @remarks
211
+ * Exported so a histogram and any caught/missed bars share one green rather than each
212
+ * restating it: a green that means "normal" has to be one green. Before 0.6 this was a
213
+ * fixed hex string.
214
+ */
215
+ export declare const NORMAL_COLOUR = "var(--normal)";
216
+ /**
217
+ * The paint for outcomes judged defective — `var(--defect)`, the design system's verdict
218
+ * token.
219
+ *
220
+ * @remarks
221
+ * The partner of {@link NORMAL_COLOUR}. Before 0.6 this was a fixed hex string.
222
+ */
223
+ export declare const DEFECT_COLOUR = "var(--defect)";
224
+ /**
225
+ * The series colour for the `index`-th series, cycling through {@link SERIES_COLOURS}.
226
+ *
227
+ * @param index - Zero-based series index. Negative or non-integer indices fall back to the
228
+ * neutral `var(--fg-muted)`.
229
+ * @returns A CSS paint value, usable as an SVG `fill`/`stroke` or a CSS `color`.
230
+ */
231
+ export declare function seriesColour(index: number): string;
232
+ //#endregion
233
+ //#region src/LineChart.d.ts
234
+ /** One line of a {@link LineChart}. */
235
+ interface Series {
236
+ /** Legend text, and the React key — unique within one chart. */
237
+ name: string;
238
+ /**
239
+ * Points in draw order. A non-finite coordinate lifts the pen rather than bridging the
240
+ * gap; a single point draws a dot; no points draws nothing but keeps the legend entry.
241
+ */
242
+ points: {
243
+ x: number;
244
+ y: number;
245
+ }[];
246
+ /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */
247
+ colour?: string;
248
+ }
249
+ /** Props for {@link LineChart}. */
250
+ interface LineChartProps {
251
+ /** The lines, drawn in order — a later series paints over an earlier one. */
252
+ series: Series[];
253
+ /** Accessible name of the chart (the SVG's `aria-label`). Required. */
254
+ label: string;
255
+ /** x-axis title. */
256
+ xLabel?: string;
257
+ /** y-axis title. */
258
+ yLabel?: string;
259
+ /** Losses span decades; a linear axis flattens two of the three onto the floor. */
260
+ logY?: boolean;
261
+ /** Fixed domains, for charts whose axes are known — ROC and PR are both `[0, 1]`. */
262
+ xDomain?: [number, number];
263
+ /** Fixed y domain. Omitted: the extent of every series' `y`. */
264
+ yDomain?: [number, number];
265
+ /** Drawn behind the series, in plot pixels. A chance diagonal or a tolerance band uses this. */
266
+ underlay?: (x: Scale, y: Scale) => ReactNode;
267
+ /** Rendered under the legend, inside the `<figcaption>`. */
268
+ footer?: ReactNode;
269
+ /** Show the legend row. Default `true`. */
270
+ showLegend?: boolean;
271
+ /** Where the chart is going (see {@link Variant}). Default `"panel"`. */
272
+ variant?: Variant;
273
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
274
+ className?: string | undefined;
275
+ }
276
+ /**
277
+ * A multi-series line chart over a shared x axis — training curves, ROC and PR curves.
278
+ *
279
+ * @remarks
280
+ * An SVG `role="img"` named by `label`, with the legend as real text under it. Series are
281
+ * told apart by the legend's names, never by colour alone.
282
+ */
283
+ export declare function LineChart({ series, label, xLabel, yLabel, logY, xDomain, yDomain, underlay, footer, showLegend, variant, className }: LineChartProps): import("react").JSX.Element;
284
+ //#endregion
285
+ //#region src/BarChart.d.ts
286
+ /**
287
+ * Horizontal stacked bars — a per-category breakdown.
288
+ *
289
+ * Horizontal because the categories are free text — a defect type, a part family — and a
290
+ * vertical axis would either truncate them or turn them sideways. Stacked because the
291
+ * usual question is "of this category, how many landed in each outcome", which is a
292
+ * proportion of a known total rather than independent counts.
293
+ */
294
+ /** One category of {@link StackedBars}: a label and its segments. */
295
+ interface BarRow {
296
+ /** The category, shown truncated in a fixed-width column (full text in `title`). */
297
+ label: string;
298
+ /** Segments in draw order, left to right. */
299
+ segments: {
300
+ name: string;
301
+ value: number;
302
+ colour: string;
303
+ }[];
304
+ }
305
+ /** Props for {@link StackedBars}. */
306
+ interface StackedBarsProps {
307
+ /** The categories, top to bottom. */
308
+ rows: BarRow[];
309
+ /** Accessible name of the table. Required. */
310
+ label: string;
311
+ /** Extra classes for the outer element, merged with `cn`. */
312
+ className?: string | undefined;
313
+ }
314
+ /**
315
+ * Horizontal stacked bars, one row per category, all on one shared scale (the widest row's
316
+ * total).
317
+ *
318
+ * @remarks
319
+ * Exposed as an ARIA `table`: each row has a `rowheader` (the category) and a text cell that
320
+ * spells every non-zero segment out as `"<value> <name>"`, so nothing depends on colour or
321
+ * on bar width. A row with no non-zero segment shows its total.
322
+ */
323
+ export declare function StackedBars({ rows, label, className }: StackedBarsProps): import("react").JSX.Element;
324
+ //#endregion
325
+ //#region src/Histogram.d.ts
326
+ /**
327
+ * Score distribution by class, with a threshold drawn on it.
328
+ *
329
+ * This is the chart that makes a threshold decision legible: a confusion matrix says how
330
+ * many were wrong, and this says *why* — two distributions that barely separate, or one
331
+ * long normal tail crossing the line.
332
+ *
333
+ * Both classes share one set of bin edges, computed over the union of their scores. Binned
334
+ * separately they would be drawn on different axes and the overlap — the only thing worth
335
+ * looking at — would be an artefact of the binning.
336
+ */
337
+ /** Props for {@link ScoreHistogram}. */
338
+ interface HistogramProps {
339
+ /** Anomaly scores of the samples labelled normal. */
340
+ normal: number[];
341
+ /** Anomaly scores of the samples labelled defective. */
342
+ defect: number[];
343
+ /** The decision threshold, drawn as a dashed vertical rule. Omitted or non-finite: none. */
344
+ threshold?: number;
345
+ /** Number of equal-width bins over the union of both classes' scores. Default 32. */
346
+ bins?: number;
347
+ /** Accessible name of the chart (the SVG's `aria-label`). Required. */
348
+ label: string;
349
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
350
+ className?: string | undefined;
351
+ }
352
+ /**
353
+ * Overlaid histograms of the normal and defect score distributions, with the threshold on
354
+ * them.
355
+ *
356
+ * @remarks
357
+ * Always the `wide` variant. Painted in the verdict tokens (`--normal`, `--defect`); the
358
+ * legend names both classes with their counts, so the chart does not rely on colour alone.
359
+ */
360
+ export declare function ScoreHistogram({ normal, defect, threshold, bins, label, className }: HistogramProps): import("react").JSX.Element;
361
+ //#endregion
362
+ //#region src/LineProfile.d.ts
363
+ /** One sampled profile of a {@link LineProfile}. */
364
+ interface ProfileSeries {
365
+ /** Legend text, and the React key — unique within one chart. */
366
+ name: string;
367
+ /** `x` is arc length along the scan line or caliper axis, in pixels. */
368
+ points: {
369
+ x: number;
370
+ y: number;
371
+ }[];
372
+ /** Any CSS colour. Omitted: {@link seriesColour} of the series' index. */
373
+ colour?: string;
374
+ }
375
+ /** A detected edge or chosen crossing, drawn as a dashed vertical rule. */
376
+ interface EdgeMark {
377
+ /** Position along the same arc-length axis as `ProfileSeries.points[].x`. */
378
+ position: number;
379
+ /** Text drawn above the rule, in the rule's colour. Omitted: no text. */
380
+ label?: string;
381
+ /** The rule's colour, as a `@vitavision/ui` measurement tone. Default `"signal"`. */
382
+ tone?: MeasureTone;
383
+ }
384
+ /** Props for {@link LineProfile}. */
385
+ interface LineProfileProps {
386
+ /** The profiles, drawn in order. */
387
+ series: ProfileSeries[];
388
+ /** Detected edge positions, drawn as vertical rules over the series. */
389
+ edges?: EdgeMark[];
390
+ /** Accessible name of the chart (the SVG's `aria-label`). Required. */
391
+ label: string;
392
+ /** x-axis title. Default `"arc length (px)"`. */
393
+ xLabel?: string;
394
+ /** y-axis title. Default `"value"`. */
395
+ yLabel?: string;
396
+ /** Fixed x domain. Omitted: the extent of every point's `x` and every edge's position. */
397
+ xDomain?: [number, number];
398
+ /** Fixed y domain. Omitted: the extent of every point's `y`. */
399
+ yDomain?: [number, number];
400
+ /** Rendered under the legend, inside the `<figcaption>`. */
401
+ footer?: ReactNode;
402
+ /** Show the legend row when there is more than one series. Default `true`. */
403
+ showLegend?: boolean;
404
+ /** Where the chart is going (see {@link Variant}). Default `"wide"`. */
405
+ variant?: Variant;
406
+ /** Extra classes for the outer `<figure>`, merged with `cn`. */
407
+ className?: string | undefined;
408
+ }
409
+ /**
410
+ * One or more series against arc length along a scan line or caliper axis, with detected
411
+ * edges as labelled vertical rules.
412
+ *
413
+ * @remarks
414
+ * An SVG `role="img"` named by `label`. The legend appears only for two or more series — a
415
+ * single profile is named by the chart's label.
416
+ */
417
+ export declare function LineProfile({ series, edges, label, xLabel, yLabel, xDomain, yDomain, footer, showLegend, variant, className }: LineProfileProps): import("react").JSX.Element;
418
+ //#endregion
419
+ export type { BarRow, EdgeMark, FrameProps, HistogramProps, LegendItem, LegendProps, LineChartProps, LineProfileProps, ProfileSeries, Scale, Series, StackedBarsProps, Tick, Variant };
420
+ //# sourceMappingURL=index.d.ts.map