@k2b/ui 0.51.0 → 0.52.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.
Files changed (206) hide show
  1. package/dist/base.css +3 -0
  2. package/dist/browser/actions/Toolbar.js +8 -2
  3. package/dist/browser/actions/Toolbar.js.map +1 -1
  4. package/dist/browser/charts/core/bar-labels.js +5 -0
  5. package/dist/browser/charts/core/bar-labels.js.map +1 -0
  6. package/dist/browser/charts/core/bubble.js +166 -0
  7. package/dist/browser/charts/core/bubble.js.map +1 -0
  8. package/dist/browser/charts/core/default-styles.js +83 -0
  9. package/dist/browser/charts/core/default-styles.js.map +1 -0
  10. package/dist/browser/charts/core/funnel-layout.js +79 -0
  11. package/dist/browser/charts/core/funnel-layout.js.map +1 -0
  12. package/dist/browser/charts/core/funnel.js +27 -0
  13. package/dist/browser/charts/core/funnel.js.map +1 -0
  14. package/dist/browser/charts/core/index.js +6 -1
  15. package/dist/browser/charts/core/index.js.map +1 -1
  16. package/dist/browser/charts/core/pareto.js +120 -0
  17. package/dist/browser/charts/core/pareto.js.map +1 -0
  18. package/dist/browser/charts/core/radar.js +101 -0
  19. package/dist/browser/charts/core/radar.js.map +1 -0
  20. package/dist/browser/charts/core/registry.js +11 -1
  21. package/dist/browser/charts/core/registry.js.map +1 -1
  22. package/dist/browser/charts/core/render-size.js +3 -1
  23. package/dist/browser/charts/core/render-size.js.map +1 -1
  24. package/dist/browser/charts/core/render.js +19 -0
  25. package/dist/browser/charts/core/render.js.map +1 -1
  26. package/dist/browser/charts/core/snapshot.js +1 -1
  27. package/dist/browser/charts/core/snapshot.js.map +1 -1
  28. package/dist/browser/charts/core/svg-barGauge.js +67 -0
  29. package/dist/browser/charts/core/svg-barGauge.js.map +1 -0
  30. package/dist/browser/charts/core/svg-boxplot.js +127 -0
  31. package/dist/browser/charts/core/svg-boxplot.js.map +1 -0
  32. package/dist/browser/charts/core/svg-common.js +1065 -0
  33. package/dist/browser/charts/core/svg-common.js.map +1 -0
  34. package/dist/browser/charts/core/svg-gauge.js +185 -0
  35. package/dist/browser/charts/core/svg-gauge.js.map +1 -0
  36. package/dist/browser/charts/core/svg-heatmap.js +80 -0
  37. package/dist/browser/charts/core/svg-heatmap.js.map +1 -0
  38. package/dist/browser/charts/core/svg-histogram.js +73 -0
  39. package/dist/browser/charts/core/svg-histogram.js.map +1 -0
  40. package/dist/browser/charts/core/svg-renderers.js +9 -1777
  41. package/dist/browser/charts/core/svg-renderers.js.map +1 -1
  42. package/dist/browser/charts/core/svg-scatter.js +114 -0
  43. package/dist/browser/charts/core/svg-scatter.js.map +1 -0
  44. package/dist/browser/charts/core/treemap.js +138 -0
  45. package/dist/browser/charts/core/treemap.js.map +1 -0
  46. package/dist/browser/charts/description.js.map +1 -1
  47. package/dist/browser/content/ChartRoot.js +21 -7
  48. package/dist/browser/content/ChartRoot.js.map +1 -1
  49. package/dist/browser/content/ChartSnapshotView.js +4 -1
  50. package/dist/browser/content/ChartSnapshotView.js.map +1 -1
  51. package/dist/browser/content/DataTable.js +186 -193
  52. package/dist/browser/content/DataTable.js.map +1 -1
  53. package/dist/browser/content/Lightbox.js +55 -23
  54. package/dist/browser/content/Lightbox.js.map +1 -1
  55. package/dist/browser/content/ThumbnailStrip.js +174 -0
  56. package/dist/browser/content/ThumbnailStrip.js.map +1 -0
  57. package/dist/browser/content/chart-bar.js +98 -0
  58. package/dist/browser/content/chart-bar.js.map +1 -1
  59. package/dist/browser/content/chart-inspection-core.js +28 -8
  60. package/dist/browser/content/chart-inspection-core.js.map +1 -1
  61. package/dist/browser/content/chart-message-catalog.js +18 -0
  62. package/dist/browser/content/chart-message-catalog.js.map +1 -1
  63. package/dist/browser/content/index.js +1 -0
  64. package/dist/browser/content/index.js.map +1 -1
  65. package/dist/browser/content/thumbnail-strip-messages.js +24 -0
  66. package/dist/browser/content/thumbnail-strip-messages.js.map +1 -0
  67. package/dist/browser/inputs/ChoiceInputs.js +132 -101
  68. package/dist/browser/inputs/ChoiceInputs.js.map +1 -1
  69. package/dist/browser/inputs/index.js +1 -0
  70. package/dist/browser/inputs/index.js.map +1 -1
  71. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js +330 -0
  72. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  73. package/dist/browser/internal/field.js +96 -77
  74. package/dist/browser/internal/field.js.map +1 -1
  75. package/dist/browser/layout/AppWorkspace.js +7 -5
  76. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  77. package/dist/browser/layout/PanelDialog.js +92 -68
  78. package/dist/browser/layout/PanelDialog.js.map +1 -1
  79. package/dist/browser/surfaces/StatCell.js +82 -70
  80. package/dist/browser/surfaces/StatCell.js.map +1 -1
  81. package/dist/browser/surfaces/stat-cell-messages.js +4 -2
  82. package/dist/browser/surfaces/stat-cell-messages.js.map +1 -1
  83. package/dist/browser/widgets/DashboardFrame.js +93 -88
  84. package/dist/browser/widgets/DashboardFrame.js.map +1 -1
  85. package/dist/ssr/actions/Toolbar.js +8 -2
  86. package/dist/ssr/actions/Toolbar.js.map +1 -1
  87. package/dist/ssr/charts/core/bar-labels.js +5 -0
  88. package/dist/ssr/charts/core/bar-labels.js.map +1 -0
  89. package/dist/ssr/charts/core/bubble.js +166 -0
  90. package/dist/ssr/charts/core/bubble.js.map +1 -0
  91. package/dist/ssr/charts/core/default-styles.js +83 -0
  92. package/dist/ssr/charts/core/default-styles.js.map +1 -0
  93. package/dist/ssr/charts/core/funnel-layout.js +79 -0
  94. package/dist/ssr/charts/core/funnel-layout.js.map +1 -0
  95. package/dist/ssr/charts/core/funnel.js +27 -0
  96. package/dist/ssr/charts/core/funnel.js.map +1 -0
  97. package/dist/ssr/charts/core/index.js +6 -1
  98. package/dist/ssr/charts/core/index.js.map +1 -1
  99. package/dist/ssr/charts/core/pareto.js +120 -0
  100. package/dist/ssr/charts/core/pareto.js.map +1 -0
  101. package/dist/ssr/charts/core/radar.js +101 -0
  102. package/dist/ssr/charts/core/radar.js.map +1 -0
  103. package/dist/ssr/charts/core/registry.js +11 -1
  104. package/dist/ssr/charts/core/registry.js.map +1 -1
  105. package/dist/ssr/charts/core/render-size.js +3 -1
  106. package/dist/ssr/charts/core/render-size.js.map +1 -1
  107. package/dist/ssr/charts/core/render.js +19 -0
  108. package/dist/ssr/charts/core/render.js.map +1 -1
  109. package/dist/ssr/charts/core/snapshot.js +1 -1
  110. package/dist/ssr/charts/core/snapshot.js.map +1 -1
  111. package/dist/ssr/charts/core/svg-barGauge.js +67 -0
  112. package/dist/ssr/charts/core/svg-barGauge.js.map +1 -0
  113. package/dist/ssr/charts/core/svg-boxplot.js +127 -0
  114. package/dist/ssr/charts/core/svg-boxplot.js.map +1 -0
  115. package/dist/ssr/charts/core/svg-common.js +1065 -0
  116. package/dist/ssr/charts/core/svg-common.js.map +1 -0
  117. package/dist/ssr/charts/core/svg-gauge.js +185 -0
  118. package/dist/ssr/charts/core/svg-gauge.js.map +1 -0
  119. package/dist/ssr/charts/core/svg-heatmap.js +80 -0
  120. package/dist/ssr/charts/core/svg-heatmap.js.map +1 -0
  121. package/dist/ssr/charts/core/svg-histogram.js +73 -0
  122. package/dist/ssr/charts/core/svg-histogram.js.map +1 -0
  123. package/dist/ssr/charts/core/svg-renderers.js +9 -1777
  124. package/dist/ssr/charts/core/svg-renderers.js.map +1 -1
  125. package/dist/ssr/charts/core/svg-scatter.js +114 -0
  126. package/dist/ssr/charts/core/svg-scatter.js.map +1 -0
  127. package/dist/ssr/charts/core/treemap.js +138 -0
  128. package/dist/ssr/charts/core/treemap.js.map +1 -0
  129. package/dist/ssr/charts/description.js.map +1 -1
  130. package/dist/ssr/content/ChartRoot.js +21 -7
  131. package/dist/ssr/content/ChartRoot.js.map +1 -1
  132. package/dist/ssr/content/ChartSnapshotView.js +1 -0
  133. package/dist/ssr/content/ChartSnapshotView.js.map +1 -1
  134. package/dist/ssr/content/DataTable.js +12 -16
  135. package/dist/ssr/content/DataTable.js.map +1 -1
  136. package/dist/ssr/content/Lightbox.js +32 -3
  137. package/dist/ssr/content/Lightbox.js.map +1 -1
  138. package/dist/ssr/content/ThumbnailStrip.js +103 -0
  139. package/dist/ssr/content/ThumbnailStrip.js.map +1 -0
  140. package/dist/ssr/content/chart-bar.js +98 -0
  141. package/dist/ssr/content/chart-bar.js.map +1 -1
  142. package/dist/ssr/content/chart-inspection-core.js +28 -8
  143. package/dist/ssr/content/chart-inspection-core.js.map +1 -1
  144. package/dist/ssr/content/chart-message-catalog.js +18 -0
  145. package/dist/ssr/content/chart-message-catalog.js.map +1 -1
  146. package/dist/ssr/content/index.js +1 -0
  147. package/dist/ssr/content/index.js.map +1 -1
  148. package/dist/ssr/content/thumbnail-strip-messages.js +24 -0
  149. package/dist/ssr/content/thumbnail-strip-messages.js.map +1 -0
  150. package/dist/ssr/inputs/ChoiceInputs.js +55 -40
  151. package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
  152. package/dist/ssr/inputs/index.js +1 -0
  153. package/dist/ssr/inputs/index.js.map +1 -1
  154. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js +293 -0
  155. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  156. package/dist/ssr/internal/field.js +36 -24
  157. package/dist/ssr/internal/field.js.map +1 -1
  158. package/dist/ssr/layout/AppWorkspace.js +5 -1
  159. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  160. package/dist/ssr/layout/PanelDialog.js +40 -26
  161. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  162. package/dist/ssr/surfaces/StatCell.js +29 -18
  163. package/dist/ssr/surfaces/StatCell.js.map +1 -1
  164. package/dist/ssr/surfaces/stat-cell-messages.js +4 -2
  165. package/dist/ssr/surfaces/stat-cell-messages.js.map +1 -1
  166. package/dist/ssr/widgets/DashboardFrame.js +6 -11
  167. package/dist/ssr/widgets/DashboardFrame.js.map +1 -1
  168. package/dist/styles.css +1 -1
  169. package/dist/types/actions/Toolbar.d.ts +2 -0
  170. package/dist/types/charts/core/bar-labels.d.ts +1 -0
  171. package/dist/types/charts/core/bubble.d.ts +66 -0
  172. package/dist/types/charts/core/default-styles.d.ts +1 -0
  173. package/dist/types/charts/core/funnel-layout.d.ts +43 -0
  174. package/dist/types/charts/core/funnel.d.ts +13 -0
  175. package/dist/types/charts/core/index.d.ts +6 -1
  176. package/dist/types/charts/core/pareto.d.ts +40 -0
  177. package/dist/types/charts/core/radar.d.ts +47 -0
  178. package/dist/types/charts/core/registry.d.ts +10 -0
  179. package/dist/types/charts/core/render-size.d.ts +1 -1
  180. package/dist/types/charts/core/svg-barGauge.d.ts +3 -0
  181. package/dist/types/charts/core/svg-boxplot.d.ts +18 -0
  182. package/dist/types/charts/core/svg-common.d.ts +612 -0
  183. package/dist/types/charts/core/svg-gauge.d.ts +6 -0
  184. package/dist/types/charts/core/svg-heatmap.d.ts +6 -0
  185. package/dist/types/charts/core/svg-histogram.d.ts +16 -0
  186. package/dist/types/charts/core/svg-renderers.d.ts +8 -612
  187. package/dist/types/charts/core/svg-scatter.d.ts +23 -0
  188. package/dist/types/charts/core/treemap.d.ts +45 -0
  189. package/dist/types/charts/description.d.ts +63 -0
  190. package/dist/types/content/ChartRoot.d.ts +1 -1
  191. package/dist/types/content/Lightbox.d.ts +2 -0
  192. package/dist/types/content/ThumbnailStrip.d.ts +29 -0
  193. package/dist/types/content/chart-bar.d.ts +38 -2
  194. package/dist/types/content/chart-inspection-core.d.ts +7 -0
  195. package/dist/types/content/chart-inspection.d.ts +1 -0
  196. package/dist/types/content/chart-message-catalog.d.ts +8 -0
  197. package/dist/types/content/index.d.ts +1 -0
  198. package/dist/types/content/thumbnail-strip-messages.d.ts +10 -0
  199. package/dist/types/inputs/ChoiceInputs.d.ts +2 -0
  200. package/dist/types/inputs/index.d.ts +2 -0
  201. package/dist/types/inputs/markdown/MarkdownSelectionToolbar.d.ts +19 -0
  202. package/dist/types/internal/field.d.ts +2 -0
  203. package/dist/types/layout/PanelDialog.d.ts +5 -0
  204. package/dist/types/surfaces/stat-cell-messages.d.ts +1 -0
  205. package/dist/types/widgets/DashboardFrame.d.ts +4 -1
  206. package/package.json +2 -2
@@ -1,410 +1,11 @@
1
- import type { IntentTone } from "../../semantics";
2
- import type { ChartDatum } from "./types";
3
- export type Point = {
4
- x: number;
5
- y: number;
6
- /** Optional third dimension. Honored by `scatter` (controls dot radius);
7
- * ignored by `line` and `sparkline`. */
8
- size?: number;
9
- /** Symmetric ±error on the y value. Used by error-bar rendering on
10
- * `scatter` and `line`. Overridden by `errYHigh`/`errYLow` if set. */
11
- errY?: number;
12
- /** Asymmetric upper bound on y (relative magnitude added to y). */
13
- errYHigh?: number;
14
- /** Asymmetric lower bound on y (relative magnitude subtracted from y). */
15
- errYLow?: number;
16
- /** Symmetric ±error on the x value. Renders horizontal error bars. */
17
- errX?: number;
18
- /** Asymmetric upper bound on x. */
19
- errXHigh?: number;
20
- /** Asymmetric lower bound on x. */
21
- errXLow?: number;
22
- };
23
- /** Marker shapes for `scatter` data points. Auto-cycles per series when
24
- * `autoVariant` is enabled on the chart. */
25
- export type MarkerShape = "circle" | "square" | "triangle" | "diamond" | "plus" | "cross";
26
- /** Line dash patterns for `line` series. Auto-cycles per series when
27
- * `autoVariant` is enabled. */
28
- export type LineStyle = "solid" | "dashed" | "dotted" | "dashdot";
29
- export type Series = {
30
- /** Optional label for this series. Used by `legend` rendering. */
31
- label?: string;
32
- data: Point[];
33
- /** Override the marker shape for this series. Default: `circle`, or
34
- * cycled from `DEFAULT_MARKERS` when the chart's `autoVariant` is true. */
35
- marker?: MarkerShape;
36
- /** Override the line dash pattern for this series. Default: `solid`, or
37
- * cycled from `DEFAULT_LINE_STYLES` when the chart's `autoVariant` is true. */
38
- lineStyle?: LineStyle;
39
- };
40
- export type MapPoint = {
41
- /** Latitude in decimal degrees, from -90 to 90. */
42
- latitude: number;
43
- /** Longitude in decimal degrees, from -180 to 180. */
44
- longitude: number;
45
- /** Optional label emitted as an escaped SVG `<title>`. */
46
- label?: string;
47
- /** Optional magnitude used to scale the point radius. */
48
- size?: number;
49
- };
50
- export type MapSeries = {
51
- /** Optional label used by the legend. */
52
- label?: string;
53
- data: MapPoint[];
54
- };
55
- export type MapViewport = {
56
- /** Latitude at the center of the viewport. */
57
- latitude: number;
58
- /** Longitude at the center of the viewport. */
59
- longitude: number;
60
- /** Zoom level from 0 (full world) to 5. Each level doubles the scale. */
61
- zoom: number;
62
- };
63
- export type MapOptions = ChartOptions & {
64
- series: MapSeries[];
65
- /** Deterministic map center and zoom. Values are normalized to the map bounds. */
66
- viewport?: MapViewport;
67
- /** Pixel-radius range used when at least one finite `size` exists. */
68
- sizeRange?: [number, number];
69
- /** Render a series legend below the map. Default false. */
70
- legend?: boolean;
71
- };
72
- export type BarItem = {
73
- label: string;
74
- value: number;
75
- colorIndex?: number;
76
- };
77
- export type SliceItem = {
78
- label: string;
79
- value: number;
80
- colorIndex?: number;
81
- };
82
- export type AxisOptions = {
83
- /** Exact inclusive bounds for comparisons. Must contain all finite plotted
84
- * values (including error bounds/baselines); invalid bounds throw RangeError. */
85
- domain?: [number, number];
86
- /** Opt in to space beside exact endpoint labels. Numeric X labels align
87
- * inward; adjacent nice ticks within one interval are omitted. Default false. */
88
- insetEndpointLabels?: boolean;
89
- /** Suggested tick count. Actual count may differ to keep ticks "nice". */
90
- ticks?: number;
91
- /** Format a tick value into a label string. Default: `String(v)`. */
92
- format?: (value: number) => string;
93
- /** Optional axis title rendered alongside the axis. */
94
- label?: string;
95
- /** Axis scale. `"linear"` (default) or `"log"`. Log axis requires all
96
- * data on this axis to be strictly positive; non-positive values are
97
- * filtered out before domain computation. */
98
- scale?: "linear" | "log";
99
- /** Render small subdivision ticks between major ticks. Default false. */
100
- minorTicks?: boolean;
101
- };
102
- export type Padding = {
103
- top: number;
104
- right: number;
105
- bottom: number;
106
- left: number;
107
- };
108
- /** One selectable datum in an inspected SVG. Indices refer to the source arrays.
109
- * `anchor` uses the containing SVG coordinate system, including nested map SVGs.
110
- * Values are raw data; `formatted` contains the renderer's axis/value formatting.
111
- */
112
- /** Wrap renderer-owned geometry with escaped, inert inspection metadata. */
113
- export declare const chartDatumSvg: (svg: string, datum: ChartDatum, inspect?: boolean, titleText?: string) => string;
114
- export type ChartOptions = {
115
- /** Emit inert datum metadata and SVG titles for progressive inspection. */
116
- inspect?: boolean;
117
- /** Default 400. */
118
- width?: number;
119
- /** Default 240. */
120
- height?: number;
121
- /** Default `{ top: 16, right: 16, bottom: 32, left: 40 }`. A single number
122
- * is applied to all four sides. */
123
- padding?: number | Partial<Padding>;
124
- /** Appended to the root `<svg>`'s class attribute (after `stdlib-chart`). */
125
- className?: string;
126
- /** Optional centered title rendered above the plot area. */
127
- title?: string;
128
- /** Optional centered subtitle rendered below the title. */
129
- subtitle?: string;
130
- };
131
- /**
132
- * A horizontal or vertical reference line drawn on a cartesian chart, e.g.
133
- * for thresholds, targets, or averages.
134
- */
135
- export type ReferenceLine = {
136
- /** Data value at which to draw the line. */
137
- value: number;
138
- /** Axis the line is anchored to. `"y"` (default) draws a horizontal line
139
- * at the given y-value; `"x"` draws a vertical line at the x-value. */
140
- axis?: "x" | "y";
141
- /** Optional inline label rendered at the end of the line. */
142
- label?: string;
143
- /** Omit to retain the existing dashed line. */
144
- style?: "solid" | "dashed" | "dotted";
145
- /** Semantic color shared by the line and its label, with standalone SVG fallbacks. */
146
- tone?: IntentTone;
147
- };
148
- /** Internal shared attributes for raw cartesian charts and UI bar layouts. */
149
- export declare const referenceLineAttributes: (ref: ReferenceLine, label?: boolean) => string;
150
- /** XML-escape a string for safe inclusion in attribute values or text content. */
151
- export declare const escapeXml: (s: string) => string;
152
- /** Normalize a `Padding` input (number or partial object) to a full `Padding`. */
153
- export declare const normalizePadding: (p: number | Partial<Padding> | undefined) => Padding;
154
- /**
155
- * Compute `[min, max]` from a list of numeric values, ignoring non-finite
156
- * entries. Returns `[0, 1]` for an empty/all-non-finite list and pads ±1
157
- * around a single finite value.
158
- */
159
- export declare const computeDomain: (values: readonly number[]) => [number, number];
160
- /**
161
- * Pick a "nice" axis step (1, 2, 5, 10, 20, 50, ...) that splits `range`
162
- * into roughly `target` intervals. Avoids ugly tick labels like 0.473.
163
- */
164
- export declare const niceStep: (range: number, target: number) => number;
165
- /** The most ticks one linear axis counts, the same budget as a time axis; more never fit a readable axis. */
166
- export declare const MAX_AXIS_TICKS = 1000;
167
- /**
168
- * Round `min` down and `max` up to the nearest multiples of `step`, so the
169
- * domain edges fall on tick boundaries. Returns the extended domain plus the
170
- * tick values within it (inclusive of both ends).
171
- */
172
- export declare const extendDomainToNice: (min: number, max: number, step: number) => {
173
- domain: [number, number];
174
- ticks: number[];
175
- };
176
- /** Linear map of `value` from input domain `[d0, d1]` to output range `[r0, r1]`. */
177
- export declare const mapRange: (value: number, [d0, d1]: readonly [number, number], [r0, r1]: readonly [number, number]) => number;
178
- /**
179
- * Logarithmic (base-10) map of `value` from input domain `[d0, d1]` to
180
- * output range `[r0, r1]`. Both domain endpoints must be strictly positive.
181
- * Non-positive values are clamped to a small epsilon to avoid `-Infinity`.
182
- */
183
- export declare const mapLog: (value: number, [d0, d1]: readonly [number, number], [r0, r1]: readonly [number, number]) => number;
184
- /**
185
- * Compute logarithmic ticks (powers of 10) within `[min, max]`. The
186
- * returned array always includes both decade boundaries enclosing the
187
- * domain so the axis line spans the data.
188
- */
189
- export declare const niceLogTicks: (min: number, max: number) => {
190
- domain: [number, number];
191
- ticks: number[];
192
- };
193
- /**
194
- * Least-squares linear regression. Returns slope, intercept, and r² for the
195
- * regression line `y = slope * x + intercept`. Returns null for fewer than
196
- * two finite points or all-x-equal input.
197
- */
198
- export declare const linearRegression: (points: ReadonlyArray<{
199
- x: number;
200
- y: number;
201
- }>) => {
202
- slope: number;
203
- intercept: number;
204
- r2: number;
205
- } | null;
206
- /**
207
- * Compute box-plot statistics for a set of observations:
208
- * min/max, quartiles (q1/q2/q3 via R-7 linear interpolation), Tukey whiskers
209
- * (1.5×IQR rule clamped to data extents), and outliers beyond the whiskers.
210
- *
211
- * Returns null for an empty/all-non-finite input.
212
- */
213
- export declare const computeBoxStats: (values: readonly number[]) => {
214
- min: number;
215
- max: number;
216
- q1: number;
217
- q2: number;
218
- q3: number;
219
- whiskerLow: number;
220
- whiskerHigh: number;
221
- outliers: number[];
222
- } | null;
223
- /**
224
- * Bin a numeric dataset into a histogram. `bins` may be:
225
- * - undefined → Sturges' formula `ceil(log2(n)) + 1`
226
- * - a number → that many equal-width bins
227
- * - an array of edges (length k+1 → k bins)
228
- *
229
- * Non-finite input values are filtered. Returns bin edges and per-bin counts.
230
- */
231
- export declare const autoBin: (values: readonly number[], bins?: number | readonly number[]) => {
232
- edges: number[];
233
- counts: number[];
234
- };
235
- export type PlotArea = {
236
- x0: number;
237
- y0: number;
238
- x1: number;
239
- y1: number;
240
- };
241
- export declare const computePlotArea: (width: number, height: number, padding: Padding, hasXAxisLabel: boolean, hasYAxisLabel: boolean, headerHeight?: number, legendHeight?: number) => PlotArea;
242
- /**
243
- * Render an optional centered header (title + subtitle) at the top of an
244
- * SVG. Returns the SVG fragment plus the pixel height it consumed so the
245
- * caller can shift the plot area down accordingly.
246
- */
247
- export declare const renderHeader: (width: number, title: string | undefined, subtitle: string | undefined) => {
248
- svg: string;
249
- height: number;
250
- };
251
- /**
252
- * Render a single-row centered legend at the bottom of the SVG. Returns the
253
- * SVG fragment plus the height it consumed so callers can shift the plot
254
- * area up accordingly. Empty input yields height 0.
255
- */
256
- export declare const renderLegend: (items: ReadonlyArray<{
257
- label: string;
258
- seriesIndex: number;
259
- }>, width: number, yTop: number) => {
260
- svg: string;
261
- height: number;
262
- };
263
- /** Measure the total height a legend with `items` will consume in `width`,
264
- * without actually rendering. Used by chart functions to reserve vertical
265
- * space before computing the plot area. */
266
- export declare const measureLegendHeight: (items: ReadonlyArray<{
267
- label: string;
268
- seriesIndex: number;
269
- }>, width: number) => number;
270
- /** Wrap chart body in a root `<svg>` with embedded default styles. */
271
- export declare const svgRoot: (opts: {
272
- width: number;
273
- height: number;
274
- className?: string;
275
- }, body: string) => string;
276
- /** Format an SVG path `d` attribute for a polyline through `points`. */
277
- export declare const linePathD: (points: ReadonlyArray<{
278
- x: number;
279
- y: number;
280
- }>) => string;
281
- /**
282
- * Format an SVG path `d` for a smooth curve through `points` using cubic
283
- * Bezier segments with Catmull-Rom-derived vertical control points.
284
- *
285
- * Vertical control points use neighboring `points[i-1]` and `points[i+2]`
286
- * (reflecting the end points at boundaries) with the standard Catmull-Rom
287
- * tension factor of 1/6. Horizontal control points stay at the segment's
288
- * thirds, so x progresses linearly and never doubles back when point spacing
289
- * is uneven.
290
- */
291
- export declare const smoothPathD: (points: ReadonlyArray<{
292
- x: number;
293
- y: number;
294
- }>) => string;
295
- /**
296
- * Build an SVG path `d` attribute for a pie slice (or donut sector).
297
- *
298
- * Angles are in radians, measured from the +X axis. Slices grow clockwise,
299
- * which in SVG's y-down coordinate space means `a1 > a0` produces a clockwise
300
- * arc when drawn with the large-arc and sweep flags set appropriately.
301
- *
302
- * Full-circle (a1 - a0 ≈ 2π) is split into two 180° arcs because a single
303
- * `A` command can't draw a complete circle unambiguously.
304
- */
305
- export declare const arcPathD: (cx: number, cy: number, r: number, a0: number, a1: number, innerR?: number) => string;
306
- /**
307
- * SVG path `d` for a marker shape centered at `(cx, cy)` with circumradius `r`.
308
- *
309
- * The shapes are sized so a typical visual radius matches `r`:
310
- * - circle: full radius
311
- * - square: side = sqrt(2)·r so the diagonal equals 2·r (visually balanced
312
- * next to a circle of the same r)
313
- * - triangle: equilateral pointing up, circumradius r
314
- * - diamond: square rotated 45°, half-diagonal = r
315
- * - plus: cross-shape at thickness r·0.5
316
- * - cross: X-shape at thickness r·0.4
317
- */
318
- export declare const markerPath: (shape: MarkerShape, cx: number, cy: number, r: number) => string;
319
- /**
320
- * SVG path `d` for a step (stair) line. `mode` controls where the vertical
321
- * step happens relative to the data points:
322
- * - `before` — vertical step at the new x BEFORE the value updates (state
323
- * machine "Mealy" style: change at input)
324
- * - `after` — value updates at the data point's x and persists until next x
325
- * - `middle` — vertical step at the midpoint between consecutive x-values
326
- */
327
- export declare const stepPathD: (points: ReadonlyArray<{
328
- x: number;
329
- y: number;
330
- }>, mode: "before" | "after" | "middle") => string;
331
- /** Format a number for SVG attributes — short, no scientific notation. */
332
- export declare const fmt: (n: number) => string;
333
- export declare const clamp: (value: number, min: number, max: number) => number;
334
- export type RgbColor = {
335
- r: number;
336
- g: number;
337
- b: number;
338
- };
339
- export type AxisScale = {
340
- domain: [number, number];
341
- ticks: number[];
342
- minorTicks: number[];
343
- scale: "linear" | "log";
344
- };
345
- export type SeriesChartOptions = ChartOptions & {
346
- series: Series[];
347
- xAxis?: AxisOptions;
348
- yAxis?: AxisOptions;
349
- /** Reference lines (thresholds, targets, averages) drawn on the plot. */
350
- references?: ReferenceLine[];
351
- /** Render a single-row legend at the bottom of the chart, listing each
352
- * series's label with its color swatch. Series without a `label` are
353
- * shown as `Series N` (1-indexed). Default false. */
354
- legend?: boolean;
355
- };
356
- export type ScatterOptions = SeriesChartOptions & {
357
- /** Pixel-radius range for the optional `size` dimension on points.
358
- * Default `[3, 12]`. Only applied when at least one point has a finite
359
- * `size`; otherwise all points use the default radius (3px). */
360
- sizeRange?: [number, number];
361
- /** When true, automatically vary marker shape per series (cycling through
362
- * `circle, square, triangle, diamond, plus, cross`) so series remain
363
- * distinguishable in B/W or color-blind contexts. Default false. */
364
- autoVariant?: boolean;
365
- /** Overlay a least-squares linear regression line across all data points.
366
- * Default false. */
367
- trendline?: boolean;
368
- };
369
- export type LineOptions = SeriesChartOptions & {
370
- /** Render smooth Catmull-Rom curves. Default `true`. Pass `false` for
371
- * straight segments between points. */
372
- smooth?: boolean;
373
- /** Fill the area below each line with the series color (translucent).
374
- * Renders as a separate path so the line stroke remains crisp. Default false. */
375
- area?: boolean;
376
- /** Render a step (stair) line instead of a smooth/straight one. Implies
377
- * `smooth: false`. */
378
- step?: "before" | "after" | "middle";
379
- /** When true, automatically vary line dash pattern per series (cycling
380
- * through `solid, dashed, dotted, dashdot`). Default false. */
381
- autoVariant?: boolean;
382
- /** Render a translucent confidence band between each point's `errYLow` and
383
- * `errYHigh`. Points without explicit error fields are skipped. Default false. */
384
- errorBand?: boolean;
385
- };
386
- /**
387
- * Render a scatter plot. Each series produces a group of circles, one per
388
- * data point, classed `stdlib-chart-series-N` so series colors stay
389
- * consistent across charts.
390
- *
391
- * Non-finite x or y values are filtered out. An empty `series` (or one with
392
- * no finite points) renders an empty-state SVG with a "no data" label.
393
- *
394
- * @example
395
- * charts.scatter({ series: [{ data: [{x:1,y:2},{x:2,y:5},{x:3,y:3}] }] });
396
- *
397
- * @example
398
- * charts.scatter({
399
- * series: [
400
- * { label: "Group A", data: [...] },
401
- * { label: "Group B", data: [...] },
402
- * ],
403
- * xAxis: { label: "Time (s)" },
404
- * yAxis: { label: "Value", format: v => `${v}k` },
405
- * });
406
- */
407
- export declare const scatter: (opts: ScatterOptions) => string;
1
+ import type { BarChartOptions, LineOptions, PieChartOptions, SparklineOptions, StateTimelineOptions, StatOptions } from "./svg-common";
2
+ export { barGauge } from "./svg-barGauge";
3
+ export { boxplot } from "./svg-boxplot";
4
+ export * from "./svg-common";
5
+ export { gauge } from "./svg-gauge";
6
+ export { heatmap } from "./svg-heatmap";
7
+ export { histogram } from "./svg-histogram";
8
+ export { scatter } from "./svg-scatter";
408
9
  /**
409
10
  * Render a line chart. Each series becomes a `<path class="stdlib-chart-line">`
410
11
  * connecting its points (sorted by `x`). Multi-series charts get distinct
@@ -427,23 +28,6 @@ export declare const scatter: (opts: ScatterOptions) => string;
427
28
  * });
428
29
  */
429
30
  export declare const line: (opts: LineOptions) => string;
430
- export type BarChartOptions = ChartOptions & {
431
- data: BarItem[];
432
- yAxis?: AxisOptions;
433
- /** When true, each bar gets its own series color (`series-0` ... `series-7`,
434
- * cyclic). When false (default), all bars share `series-0`. */
435
- colorByBar?: boolean;
436
- /** Reference lines on the y-axis (e.g. target threshold). x-axis references
437
- * are ignored on bar charts since the x-axis is categorical. */
438
- references?: ReferenceLine[];
439
- /** Render the formatted value above (positive) or below (negative) each bar.
440
- * Uses `yAxis.format` if provided, otherwise `String(value)`. Default false. */
441
- showValues?: boolean;
442
- /** Render a legend mapping each bar's label to its color. Only meaningful
443
- * when `colorByBar` is true; ignored otherwise (the default single-color
444
- * bar chart needs no legend). Default false. */
445
- legend?: boolean;
446
- };
447
31
  /**
448
32
  * Render a categorical bar chart. The y-domain always includes zero so bars
449
33
  * rest on a visible baseline. Negative values produce bars below the zero
@@ -464,20 +48,6 @@ export type BarChartOptions = ChartOptions & {
464
48
  * });
465
49
  */
466
50
  export declare const bar: (opts: BarChartOptions) => string;
467
- export type PieChartOptions = ChartOptions & {
468
- data: SliceItem[];
469
- /** Render slice labels with percentages outside the chart area. Default false.
470
- * Note: for many small slices or one dominant slice, prefer `legend: true`
471
- * to avoid overlapping labels. */
472
- showLabels?: boolean;
473
- /** Render a wrapping legend below the chart with `Label (XX%)` entries.
474
- * Recommended when slices are many or when one slice dominates — outside
475
- * labels collide in those cases. Default false. */
476
- legend?: boolean;
477
- /** Inner radius as a fraction of outer radius (0..1). 0 = pie, 0.6 = donut.
478
- * Values outside `[0, 0.95]` are clamped. */
479
- innerRadius?: number;
480
- };
481
51
  /**
482
52
  * Render a pie chart. Slices are drawn clockwise starting at 12 o'clock,
483
53
  * proportional to each item's `value`. Pass `showLabels: true` to render
@@ -515,187 +85,13 @@ export declare const pie: (opts: PieChartOptions) => string;
515
85
  * charts.donut({ data: [...], legend: true }); // wrapping legend below the ring
516
86
  */
517
87
  export declare const donut: (opts: PieChartOptions) => string;
518
- export type HistogramOptions = ChartOptions & {
519
- /** Raw observations. Non-finite entries are filtered. */
520
- data: number[];
521
- /** Bin specification:
522
- * - undefined → Sturges' formula `ceil(log2(n)) + 1`
523
- * - number → that many equal-width bins
524
- * - array of bin edges (length k+1 → k bins) */
525
- bins?: number | number[];
526
- yAxis?: AxisOptions;
527
- xAxis?: AxisOptions;
528
- references?: ReferenceLine[];
529
- };
530
- /**
531
- * Render a histogram (frequency distribution) of the given observations.
532
- * Uses Sturges' formula by default for bin count, or accepts an explicit
533
- * count or list of bin edges.
534
- *
535
- * Bars are adjacent (no inter-bar gap) since a histogram represents a
536
- * continuous distribution. The x-axis is numeric (bin edges as ticks).
537
- *
538
- * @example
539
- * charts.histogram({ data: observations, title: "Reaction times (ms)" });
540
- *
541
- * @example
542
- * charts.histogram({ data: scores, bins: 20, yAxis: { label: "Count" } });
543
- */
544
- export declare const histogram: (opts: HistogramOptions) => string;
545
- export type BoxPlotItem = {
546
- label: string;
547
- values: number[];
548
- };
549
- export type BoxPlotOptions = ChartOptions & {
550
- /** Groups of observations, one box per group. */
551
- groups: BoxPlotItem[];
552
- yAxis?: AxisOptions;
553
- /** When true (default), render outliers as individual dots beyond the
554
- * whiskers (1.5×IQR fences). */
555
- showOutliers?: boolean;
556
- references?: ReferenceLine[];
557
- /** When true, each box gets its own series color. Default false (all use
558
- * series-0). */
559
- colorByBox?: boolean;
560
- };
561
- /**
562
- * Render a box plot (Tukey style): box for the IQR (Q1-Q3), median line,
563
- * whiskers extending to 1.5×IQR fences, and individual outlier dots.
564
- *
565
- * Useful for comparing distributions across categorical groups (e.g. test
566
- * scores per class, reaction times per condition).
567
- *
568
- * @example
569
- * charts.boxplot({
570
- * groups: [
571
- * { label: "Class A", values: scoresA },
572
- * { label: "Class B", values: scoresB },
573
- * ],
574
- * yAxis: { label: "Score" },
575
- * });
576
- */
577
- export declare const boxplot: (opts: BoxPlotOptions) => string;
578
- export type Threshold = {
579
- /** Inclusive upper bound for this threshold segment. */
580
- value: number;
581
- /** Optional label for legends or future consumers. */
582
- label?: string;
583
- /** Optional SVG color. When omitted, the series CSS variables are used. */
584
- color?: string;
585
- };
586
- export type GaugeOptions = ChartOptions & {
587
- value: number;
588
- min?: number;
589
- max?: number;
590
- label?: string;
591
- unit?: string;
592
- format?: (value: number) => string;
593
- thresholds?: Threshold[];
594
- showNeedle?: boolean;
595
- };
596
- export type BarGaugeItem = {
597
- label: string;
598
- value: number;
599
- min?: number;
600
- max?: number;
601
- unit?: string;
602
- };
603
- export type BarGaugeOptions = ChartOptions & {
604
- data: BarGaugeItem[];
605
- min?: number;
606
- max?: number;
607
- unit?: string;
608
- format?: (value: number) => string;
609
- thresholds?: Threshold[];
610
- };
611
- export type StatOptions = ChartOptions & {
612
- label: string;
613
- value: number | string;
614
- unit?: string;
615
- delta?: number | string;
616
- deltaFormat?: (value: number) => string;
617
- trend?: "up" | "down" | "neutral";
618
- sparkline?: number[] | Point[];
619
- format?: (value: number) => string;
620
- };
621
- export type HeatmapDatum = {
622
- x: string;
623
- y: string;
624
- value: number;
625
- };
626
- export type HeatmapOptions = ChartOptions & {
627
- data: HeatmapDatum[];
628
- xLabels?: string[];
629
- yLabels?: string[];
630
- min?: number;
631
- max?: number;
632
- format?: (value: number) => string;
633
- showValues?: boolean;
634
- };
635
- export type StateInterval = {
636
- from: number;
637
- to: number;
638
- state: string;
639
- label?: string;
640
- };
641
- export type StateTimelineRow = {
642
- label: string;
643
- intervals: StateInterval[];
644
- };
645
- export type StateStyle = {
646
- state: string;
647
- label?: string;
648
- color?: string;
649
- };
650
- export type StateTimelineOptions = ChartOptions & {
651
- rows: StateTimelineRow[];
652
- states?: StateStyle[];
653
- xAxis?: Pick<AxisOptions, "format" | "label">;
654
- legend?: boolean;
655
- };
656
- /**
657
- * Render a radial single-value gauge for KPI, quota, saturation, or SLO style
658
- * dashboard panels.
659
- */
660
- export declare const gauge: (opts: GaugeOptions) => string;
661
- /** Render compact horizontal bar gauges for multiple reduced metrics. */
662
- export declare const barGauge: (opts: BarGaugeOptions) => string;
663
88
  /** Render a large value panel with optional delta and inline sparkline. */
664
89
  export declare const stat: (opts: StatOptions) => string;
665
- /**
666
- * Render a categorical two-dimensional heatmap. Cell opacity represents value
667
- * intensity; labels are derived from first occurrence order unless provided.
668
- */
669
- export declare const heatmap: (opts: HeatmapOptions) => string;
670
90
  /**
671
91
  * Render state regions over a numeric timeline for services, jobs, deploys, or
672
92
  * health checks.
673
93
  */
674
94
  export declare const stateTimeline: (opts: StateTimelineOptions) => string;
675
- export type SparklineOptions = {
676
- inspect?: boolean;
677
- /** Series of values. Bare numbers auto-x to their array index. */
678
- data: number[] | Point[];
679
- /** Default 80. */
680
- width?: number;
681
- /** Default 20. */
682
- height?: number;
683
- /** Render with smooth Catmull-Rom curves. Default `true`. */
684
- smooth?: boolean;
685
- /** Render a small dot at the last data point. Default false. */
686
- showLast?: boolean;
687
- /** Render dots at the highest and lowest data points. Skipped when all
688
- * values are equal. Default false. */
689
- showMinMax?: boolean;
690
- /** Render a soft gradient fill below the stroke line, fading from a
691
- * translucent `currentColor` at the top to fully transparent at the
692
- * bottom — the classic dashboard-tile look. The stroke line stays
693
- * visible on top, and dots from `showLast`/`showMinMax` compose over
694
- * the fill. Default false. */
695
- area?: boolean;
696
- /** Appended to the root `<svg>`'s class attribute. */
697
- className?: string;
698
- };
699
95
  /**
700
96
  * Render a minimalist sparkline — a tiny inline chart with no axes, no
701
97
  * labels, and minimal padding. Designed to fit alongside text or in dense
@@ -0,0 +1,23 @@
1
+ import { type ScatterOptions } from "./svg-common";
2
+ /**
3
+ * Render a scatter plot. Each series produces a group of circles, one per
4
+ * data point, classed `stdlib-chart-series-N` so series colors stay
5
+ * consistent across charts.
6
+ *
7
+ * Non-finite x or y values are filtered out. An empty `series` (or one with
8
+ * no finite points) renders an empty-state SVG with a "no data" label.
9
+ *
10
+ * @example
11
+ * charts.scatter({ series: [{ data: [{x:1,y:2},{x:2,y:5},{x:3,y:3}] }] });
12
+ *
13
+ * @example
14
+ * charts.scatter({
15
+ * series: [
16
+ * { label: "Group A", data: [...] },
17
+ * { label: "Group B", data: [...] },
18
+ * ],
19
+ * xAxis: { label: "Time (s)" },
20
+ * yAxis: { label: "Value", format: v => `${v}k` },
21
+ * });
22
+ */
23
+ export declare const scatter: (opts: ScatterOptions) => string;