@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
@@ -0,0 +1,612 @@
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 declare const itemColorIndex: (item: {
83
+ colorIndex?: number;
84
+ }, fallback: number) => number;
85
+ export type AxisOptions = {
86
+ /** Exact inclusive bounds for comparisons. Must contain all finite plotted
87
+ * values (including error bounds/baselines); invalid bounds throw RangeError. */
88
+ domain?: [number, number];
89
+ /** Opt in to space beside exact endpoint labels. Numeric X labels align
90
+ * inward; adjacent nice ticks within one interval are omitted. Default false. */
91
+ insetEndpointLabels?: boolean;
92
+ /** Suggested tick count. Actual count may differ to keep ticks "nice". */
93
+ ticks?: number;
94
+ /** Format a tick value into a label string. Default: `String(v)`. */
95
+ format?: (value: number) => string;
96
+ /** Optional axis title rendered alongside the axis. */
97
+ label?: string;
98
+ /** Axis scale. `"linear"` (default) or `"log"`. Log axis requires all
99
+ * data on this axis to be strictly positive; non-positive values are
100
+ * filtered out before domain computation. */
101
+ scale?: "linear" | "log";
102
+ /** Render small subdivision ticks between major ticks. Default false. */
103
+ minorTicks?: boolean;
104
+ };
105
+ export type Padding = {
106
+ top: number;
107
+ right: number;
108
+ bottom: number;
109
+ left: number;
110
+ };
111
+ /** One selectable datum in an inspected SVG. Indices refer to the source arrays.
112
+ * `anchor` uses the containing SVG coordinate system, including nested map SVGs.
113
+ * Values are raw data; `formatted` contains the renderer's axis/value formatting.
114
+ */
115
+ /** Wrap renderer-owned geometry with escaped, inert inspection metadata. */
116
+ export declare const chartDatumSvg: (svg: string, datum: ChartDatum, inspect?: boolean, titleText?: string) => string;
117
+ export declare const inspectionPoint: (datum: ChartDatum, inspect?: boolean) => string;
118
+ export declare const pointValues: (p: Point, xAxis?: AxisOptions, yAxis?: AxisOptions) => ChartDatum["values"];
119
+ export type ChartOptions = {
120
+ /** Emit inert datum metadata and SVG titles for progressive inspection. */
121
+ inspect?: boolean;
122
+ /** Default 400. */
123
+ width?: number;
124
+ /** Default 240. */
125
+ height?: number;
126
+ /** Default `{ top: 16, right: 16, bottom: 32, left: 40 }`. A single number
127
+ * is applied to all four sides. */
128
+ padding?: number | Partial<Padding>;
129
+ /** Appended to the root `<svg>`'s class attribute (after `stdlib-chart`). */
130
+ className?: string;
131
+ /** Optional centered title rendered above the plot area. */
132
+ title?: string;
133
+ /** Optional centered subtitle rendered below the title. */
134
+ subtitle?: string;
135
+ };
136
+ /**
137
+ * A horizontal or vertical reference line drawn on a cartesian chart, e.g.
138
+ * for thresholds, targets, or averages.
139
+ */
140
+ export type ReferenceLine = {
141
+ /** Data value at which to draw the line. */
142
+ value: number;
143
+ /** Axis the line is anchored to. `"y"` (default) draws a horizontal line
144
+ * at the given y-value; `"x"` draws a vertical line at the x-value. */
145
+ axis?: "x" | "y";
146
+ /** Optional inline label rendered at the end of the line. */
147
+ label?: string;
148
+ /** Omit to retain the existing dashed line. */
149
+ style?: "solid" | "dashed" | "dotted";
150
+ /** Semantic color shared by the line and its label, with standalone SVG fallbacks. */
151
+ tone?: IntentTone;
152
+ };
153
+ /** Internal shared attributes for raw cartesian charts and UI bar layouts. */
154
+ export declare const referenceLineAttributes: (ref: ReferenceLine, label?: boolean) => string;
155
+ export declare const DEFAULT_WIDTH = 400;
156
+ export declare const DEFAULT_HEIGHT = 240;
157
+ export declare const DEFAULT_MARKERS: readonly MarkerShape[];
158
+ export declare const DEFAULT_LINE_STYLES: readonly LineStyle[];
159
+ /** SVG `stroke-dasharray` values per line style. Empty string = no dasharray. */
160
+ export declare const LINE_DASH_PATTERNS: Record<LineStyle, string>;
161
+ /** XML-escape a string for safe inclusion in attribute values or text content. */
162
+ export declare const escapeXml: (s: string) => string;
163
+ /** Normalize a `Padding` input (number or partial object) to a full `Padding`. */
164
+ export declare const normalizePadding: (p: number | Partial<Padding> | undefined) => Padding;
165
+ /**
166
+ * Compute `[min, max]` from a list of numeric values, ignoring non-finite
167
+ * entries. Returns `[0, 1]` for an empty/all-non-finite list and pads ±1
168
+ * around a single finite value.
169
+ */
170
+ export declare const computeDomain: (values: readonly number[]) => [number, number];
171
+ /**
172
+ * Pick a "nice" axis step (1, 2, 5, 10, 20, 50, ...) that splits `range`
173
+ * into roughly `target` intervals. Avoids ugly tick labels like 0.473.
174
+ */
175
+ export declare const niceStep: (range: number, target: number) => number;
176
+ /** The most ticks one linear axis counts, the same budget as a time axis; more never fit a readable axis. */
177
+ export declare const MAX_AXIS_TICKS = 1000;
178
+ /**
179
+ * Round `min` down and `max` up to the nearest multiples of `step`, so the
180
+ * domain edges fall on tick boundaries. Returns the extended domain plus the
181
+ * tick values within it (inclusive of both ends).
182
+ */
183
+ export declare const extendDomainToNice: (min: number, max: number, step: number) => {
184
+ domain: [number, number];
185
+ ticks: number[];
186
+ };
187
+ /** Linear map of `value` from input domain `[d0, d1]` to output range `[r0, r1]`. */
188
+ export declare const mapRange: (value: number, [d0, d1]: readonly [number, number], [r0, r1]: readonly [number, number]) => number;
189
+ /**
190
+ * Logarithmic (base-10) map of `value` from input domain `[d0, d1]` to
191
+ * output range `[r0, r1]`. Both domain endpoints must be strictly positive.
192
+ * Non-positive values are clamped to a small epsilon to avoid `-Infinity`.
193
+ */
194
+ export declare const mapLog: (value: number, [d0, d1]: readonly [number, number], [r0, r1]: readonly [number, number]) => number;
195
+ /**
196
+ * Compute logarithmic ticks (powers of 10) within `[min, max]`. The
197
+ * returned array always includes both decade boundaries enclosing the
198
+ * domain so the axis line spans the data.
199
+ */
200
+ export declare const niceLogTicks: (min: number, max: number) => {
201
+ domain: [number, number];
202
+ ticks: number[];
203
+ };
204
+ /**
205
+ * Least-squares linear regression. Returns slope, intercept, and r² for the
206
+ * regression line `y = slope * x + intercept`. Returns null for fewer than
207
+ * two finite points or all-x-equal input.
208
+ */
209
+ export declare const linearRegression: (points: ReadonlyArray<{
210
+ x: number;
211
+ y: number;
212
+ }>) => {
213
+ slope: number;
214
+ intercept: number;
215
+ r2: number;
216
+ } | null;
217
+ /**
218
+ * Compute box-plot statistics for a set of observations:
219
+ * min/max, quartiles (q1/q2/q3 via R-7 linear interpolation), Tukey whiskers
220
+ * (1.5×IQR rule clamped to data extents), and outliers beyond the whiskers.
221
+ *
222
+ * Returns null for an empty/all-non-finite input.
223
+ */
224
+ export declare const computeBoxStats: (values: readonly number[]) => {
225
+ min: number;
226
+ max: number;
227
+ q1: number;
228
+ q2: number;
229
+ q3: number;
230
+ whiskerLow: number;
231
+ whiskerHigh: number;
232
+ outliers: number[];
233
+ } | null;
234
+ /**
235
+ * Bin a numeric dataset into a histogram. `bins` may be:
236
+ * - undefined → Sturges' formula `ceil(log2(n)) + 1`
237
+ * - a number → that many equal-width bins
238
+ * - an array of edges (length k+1 → k bins)
239
+ *
240
+ * Non-finite input values are filtered. Returns bin edges and per-bin counts.
241
+ */
242
+ export declare const autoBin: (values: readonly number[], bins?: number | readonly number[]) => {
243
+ edges: number[];
244
+ counts: number[];
245
+ };
246
+ export type PlotArea = {
247
+ x0: number;
248
+ y0: number;
249
+ x1: number;
250
+ y1: number;
251
+ };
252
+ export declare const computePlotArea: (width: number, height: number, padding: Padding, hasXAxisLabel: boolean, hasYAxisLabel: boolean, headerHeight?: number, legendHeight?: number) => PlotArea;
253
+ /**
254
+ * Render an optional centered header (title + subtitle) at the top of an
255
+ * SVG. Returns the SVG fragment plus the pixel height it consumed so the
256
+ * caller can shift the plot area down accordingly.
257
+ */
258
+ export declare const renderHeader: (width: number, title: string | undefined, subtitle: string | undefined) => {
259
+ svg: string;
260
+ height: number;
261
+ };
262
+ /**
263
+ * Render reference lines (horizontal or vertical thresholds) within the plot
264
+ * area. Out-of-domain values are silently skipped. Honors per-axis scale
265
+ * (linear or log).
266
+ */
267
+ export declare const renderReferenceLines: (refs: ReadonlyArray<ReferenceLine>, xAxis: {
268
+ domain: [number, number];
269
+ scale: "linear" | "log";
270
+ }, yAxis: {
271
+ domain: [number, number];
272
+ scale: "linear" | "log";
273
+ }, area: PlotArea) => string;
274
+ /**
275
+ * Resolve a point's effective error extents into `[low, high]` magnitudes
276
+ * (relative deltas, both ≥ 0). Asymmetric `errYHigh`/`errYLow` take precedence
277
+ * over symmetric `errY`. Returns null when no error info is set.
278
+ */
279
+ export declare const resolveErrorY: (p: Point) => [number, number] | null;
280
+ /** Build the SVG fragment for the per-point error bars across all series. */
281
+ export declare const renderErrorBars: (series: ReadonlyArray<Series>, xAxis: AxisScale, yAxis: AxisScale, area: PlotArea) => string;
282
+ /** Collect all values relevant for axis-domain computation, including error
283
+ * extents so error bars don't get clipped. */
284
+ export declare const collectAxisValues: (series: ReadonlyArray<Series>, axis: "x" | "y") => number[];
285
+ /**
286
+ * Render a single-row centered legend at the bottom of the SVG. Returns the
287
+ * SVG fragment plus the height it consumed so callers can shift the plot
288
+ * area up accordingly. Empty input yields height 0.
289
+ */
290
+ export declare const renderLegend: (items: ReadonlyArray<{
291
+ label: string;
292
+ seriesIndex: number;
293
+ }>, width: number, yTop: number) => {
294
+ svg: string;
295
+ height: number;
296
+ };
297
+ /** Measure the total height a legend with `items` will consume in `width`,
298
+ * without actually rendering. Used by chart functions to reserve vertical
299
+ * space before computing the plot area. */
300
+ export declare const measureLegendHeight: (items: ReadonlyArray<{
301
+ label: string;
302
+ seriesIndex: number;
303
+ }>, width: number) => number;
304
+ /** Wrap chart body in a root `<svg>` with embedded default styles. */
305
+ export declare const svgRoot: (opts: {
306
+ width: number;
307
+ height: number;
308
+ className?: string;
309
+ }, body: string) => string;
310
+ /** Format an SVG path `d` attribute for a polyline through `points`. */
311
+ export declare const linePathD: (points: ReadonlyArray<{
312
+ x: number;
313
+ y: number;
314
+ }>) => string;
315
+ /**
316
+ * Format an SVG path `d` for a smooth curve through `points` using cubic
317
+ * Bezier segments with Catmull-Rom-derived vertical control points.
318
+ *
319
+ * Vertical control points use neighboring `points[i-1]` and `points[i+2]`
320
+ * (reflecting the end points at boundaries) with the standard Catmull-Rom
321
+ * tension factor of 1/6. Horizontal control points stay at the segment's
322
+ * thirds, so x progresses linearly and never doubles back when point spacing
323
+ * is uneven.
324
+ */
325
+ export declare const smoothPathD: (points: ReadonlyArray<{
326
+ x: number;
327
+ y: number;
328
+ }>) => string;
329
+ /**
330
+ * Build an SVG path `d` attribute for a pie slice (or donut sector).
331
+ *
332
+ * Angles are in radians, measured from the +X axis. Slices grow clockwise,
333
+ * which in SVG's y-down coordinate space means `a1 > a0` produces a clockwise
334
+ * arc when drawn with the large-arc and sweep flags set appropriately.
335
+ *
336
+ * Full-circle (a1 - a0 ≈ 2π) is split into two 180° arcs because a single
337
+ * `A` command can't draw a complete circle unambiguously.
338
+ */
339
+ export declare const arcPathD: (cx: number, cy: number, r: number, a0: number, a1: number, innerR?: number) => string;
340
+ /**
341
+ * SVG path `d` for a marker shape centered at `(cx, cy)` with circumradius `r`.
342
+ *
343
+ * The shapes are sized so a typical visual radius matches `r`:
344
+ * - circle: full radius
345
+ * - square: side = sqrt(2)·r so the diagonal equals 2·r (visually balanced
346
+ * next to a circle of the same r)
347
+ * - triangle: equilateral pointing up, circumradius r
348
+ * - diamond: square rotated 45°, half-diagonal = r
349
+ * - plus: cross-shape at thickness r·0.5
350
+ * - cross: X-shape at thickness r·0.4
351
+ */
352
+ export declare const markerPath: (shape: MarkerShape, cx: number, cy: number, r: number) => string;
353
+ /**
354
+ * SVG path `d` for a step (stair) line. `mode` controls where the vertical
355
+ * step happens relative to the data points:
356
+ * - `before` — vertical step at the new x BEFORE the value updates (state
357
+ * machine "Mealy" style: change at input)
358
+ * - `after` — value updates at the data point's x and persists until next x
359
+ * - `middle` — vertical step at the midpoint between consecutive x-values
360
+ */
361
+ export declare const stepPathD: (points: ReadonlyArray<{
362
+ x: number;
363
+ y: number;
364
+ }>, mode: "before" | "after" | "middle") => string;
365
+ /** Format a number for SVG attributes — short, no scientific notation. */
366
+ export declare const fmt: (n: number) => string;
367
+ export declare const clamp: (value: number, min: number, max: number) => number;
368
+ export declare const normalizeMinMax: (min: number | undefined, max: number | undefined) => [number, number];
369
+ export declare const formatNumberValue: (value: number, format: ((value: number) => string) | undefined, unit?: string) => string;
370
+ export declare const thresholdFillAttr: (color: string | undefined) => string;
371
+ export declare const thresholdStrokeAttr: (color: string | undefined) => string;
372
+ export type RgbColor = {
373
+ r: number;
374
+ g: number;
375
+ b: number;
376
+ };
377
+ export type AxisScale = {
378
+ domain: [number, number];
379
+ ticks: number[];
380
+ minorTicks: number[];
381
+ scale: "linear" | "log";
382
+ };
383
+ export declare const pickMapper: (scale: "linear" | "log") => typeof mapRange;
384
+ /**
385
+ * Whether a value is renderable on the given axis. Log axes reject zero and
386
+ * negative values (since `log(<=0)` is undefined). Used to filter data
387
+ * points before rendering so we don't emit huge off-plot SVG coordinates.
388
+ */
389
+ export declare const isOnAxis: (axis: {
390
+ scale: "linear" | "log";
391
+ }, v: number) => boolean;
392
+ /**
393
+ * Compute the domain, major ticks, and (optional) minor ticks for an axis,
394
+ * choosing linear or log scale per `axisOpts`. Filters non-positive values
395
+ * out under log scale and falls back to `[1, 10]` if none remain.
396
+ */
397
+ export declare const computeAxisScale: (values: readonly number[], axisOpts: AxisOptions | undefined, fallbackTicks?: number) => AxisScale;
398
+ export declare const renderYAxis: (axis: AxisScale, area: PlotArea, opts: AxisOptions | undefined) => string;
399
+ export declare const renderXAxisNumeric: (axis: AxisScale, area: PlotArea, height: number, opts: AxisOptions | undefined) => string;
400
+ export declare const renderXAxisCategorical: (labels: readonly string[], area: PlotArea, height: number, axisLabel?: string) => string;
401
+ export declare const emptyChart: (width: number, height: number, className: string | undefined, message?: string) => string;
402
+ export type SeriesChartOptions = ChartOptions & {
403
+ series: Series[];
404
+ xAxis?: AxisOptions;
405
+ yAxis?: AxisOptions;
406
+ /** Reference lines (thresholds, targets, averages) drawn on the plot. */
407
+ references?: ReferenceLine[];
408
+ /** Render a single-row legend at the bottom of the chart, listing each
409
+ * series's label with its color swatch. Series without a `label` are
410
+ * shown as `Series N` (1-indexed). Default false. */
411
+ legend?: boolean;
412
+ };
413
+ export type ScatterOptions = SeriesChartOptions & {
414
+ /** Pixel-radius range for the optional `size` dimension on points.
415
+ * Default `[3, 12]`. Only applied when at least one point has a finite
416
+ * `size`; otherwise all points use the default radius (3px). */
417
+ sizeRange?: [number, number];
418
+ /** When true, automatically vary marker shape per series (cycling through
419
+ * `circle, square, triangle, diamond, plus, cross`) so series remain
420
+ * distinguishable in B/W or color-blind contexts. Default false. */
421
+ autoVariant?: boolean;
422
+ /** Overlay a least-squares linear regression line across all data points.
423
+ * Default false. */
424
+ trendline?: boolean;
425
+ };
426
+ export type LineOptions = SeriesChartOptions & {
427
+ /** Render smooth Catmull-Rom curves. Default `true`. Pass `false` for
428
+ * straight segments between points. */
429
+ smooth?: boolean;
430
+ /** Fill the area below each line with the series color (translucent).
431
+ * Renders as a separate path so the line stroke remains crisp. Default false. */
432
+ area?: boolean;
433
+ /** Render a step (stair) line instead of a smooth/straight one. Implies
434
+ * `smooth: false`. */
435
+ step?: "before" | "after" | "middle";
436
+ /** When true, automatically vary line dash pattern per series (cycling
437
+ * through `solid, dashed, dotted, dashdot`). Default false. */
438
+ autoVariant?: boolean;
439
+ /** Render a translucent confidence band between each point's `errYLow` and
440
+ * `errYHigh`. Points without explicit error fields are skipped. Default false. */
441
+ errorBand?: boolean;
442
+ };
443
+ export declare const collectSeriesLegend: (opts: {
444
+ series: Series[];
445
+ legend?: boolean;
446
+ }) => Array<{
447
+ label: string;
448
+ seriesIndex: number;
449
+ }>;
450
+ export type BarChartOptions = ChartOptions & {
451
+ data: BarItem[];
452
+ yAxis?: AxisOptions;
453
+ /** When true, each bar gets its own series color (`series-0` ... `series-7`,
454
+ * cyclic). When false (default), all bars share `series-0`. */
455
+ colorByBar?: boolean;
456
+ /** Reference lines on the y-axis (e.g. target threshold). x-axis references
457
+ * are ignored on bar charts since the x-axis is categorical. */
458
+ references?: ReferenceLine[];
459
+ /** Render the formatted value above (positive) or below (negative) each bar.
460
+ * Uses `yAxis.format` if provided, otherwise `String(value)`. Default false. */
461
+ showValues?: boolean;
462
+ /** Render a legend mapping each bar's label to its color. Only meaningful
463
+ * when `colorByBar` is true; ignored otherwise (the default single-color
464
+ * bar chart needs no legend). Default false. */
465
+ legend?: boolean;
466
+ };
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
+ export type HistogramOptions = ChartOptions & {
482
+ /** Raw observations. Non-finite entries are filtered. */
483
+ data: number[];
484
+ /** Bin specification:
485
+ * - undefined → Sturges' formula `ceil(log2(n)) + 1`
486
+ * - number → that many equal-width bins
487
+ * - array of bin edges (length k+1 → k bins) */
488
+ bins?: number | number[];
489
+ yAxis?: AxisOptions;
490
+ xAxis?: AxisOptions;
491
+ references?: ReferenceLine[];
492
+ };
493
+ export type BoxPlotItem = {
494
+ label: string;
495
+ values: number[];
496
+ };
497
+ export type BoxPlotOptions = ChartOptions & {
498
+ /** Groups of observations, one box per group. */
499
+ groups: BoxPlotItem[];
500
+ yAxis?: AxisOptions;
501
+ /** When true (default), render outliers as individual dots beyond the
502
+ * whiskers (1.5×IQR fences). */
503
+ showOutliers?: boolean;
504
+ references?: ReferenceLine[];
505
+ /** When true, each box gets its own series color. Default false (all use
506
+ * series-0). */
507
+ colorByBox?: boolean;
508
+ };
509
+ export type Threshold = {
510
+ /** Inclusive upper bound for this threshold segment. */
511
+ value: number;
512
+ /** Optional label for legends or future consumers. */
513
+ label?: string;
514
+ /** Optional SVG color. When omitted, the series CSS variables are used. */
515
+ color?: string;
516
+ };
517
+ export type GaugeOptions = ChartOptions & {
518
+ value: number;
519
+ min?: number;
520
+ max?: number;
521
+ label?: string;
522
+ unit?: string;
523
+ format?: (value: number) => string;
524
+ thresholds?: Threshold[];
525
+ showNeedle?: boolean;
526
+ };
527
+ export type BarGaugeItem = {
528
+ label: string;
529
+ value: number;
530
+ min?: number;
531
+ max?: number;
532
+ unit?: string;
533
+ };
534
+ export type BarGaugeOptions = ChartOptions & {
535
+ data: BarGaugeItem[];
536
+ min?: number;
537
+ max?: number;
538
+ unit?: string;
539
+ format?: (value: number) => string;
540
+ thresholds?: Threshold[];
541
+ };
542
+ export type StatOptions = ChartOptions & {
543
+ label: string;
544
+ value: number | string;
545
+ unit?: string;
546
+ delta?: number | string;
547
+ deltaFormat?: (value: number) => string;
548
+ trend?: "up" | "down" | "neutral";
549
+ sparkline?: number[] | Point[];
550
+ format?: (value: number) => string;
551
+ };
552
+ export type HeatmapDatum = {
553
+ x: string;
554
+ y: string;
555
+ value: number;
556
+ };
557
+ export type HeatmapOptions = ChartOptions & {
558
+ data: HeatmapDatum[];
559
+ xLabels?: string[];
560
+ yLabels?: string[];
561
+ min?: number;
562
+ max?: number;
563
+ format?: (value: number) => string;
564
+ showValues?: boolean;
565
+ };
566
+ export type StateInterval = {
567
+ from: number;
568
+ to: number;
569
+ state: string;
570
+ label?: string;
571
+ };
572
+ export type StateTimelineRow = {
573
+ label: string;
574
+ intervals: StateInterval[];
575
+ };
576
+ export type StateStyle = {
577
+ state: string;
578
+ label?: string;
579
+ color?: string;
580
+ };
581
+ export type StateTimelineOptions = ChartOptions & {
582
+ rows: StateTimelineRow[];
583
+ states?: StateStyle[];
584
+ xAxis?: Pick<AxisOptions, "format" | "label">;
585
+ legend?: boolean;
586
+ };
587
+ export declare const thresholdIndexForValue: (value: number, thresholds: readonly Threshold[] | undefined, min: number, max: number) => number;
588
+ export declare const thresholdForIndex: (thresholds: readonly Threshold[] | undefined, index: number) => Threshold | undefined;
589
+ export type SparklineOptions = {
590
+ inspect?: boolean;
591
+ /** Series of values. Bare numbers auto-x to their array index. */
592
+ data: number[] | Point[];
593
+ /** Default 80. */
594
+ width?: number;
595
+ /** Default 20. */
596
+ height?: number;
597
+ /** Render with smooth Catmull-Rom curves. Default `true`. */
598
+ smooth?: boolean;
599
+ /** Render a small dot at the last data point. Default false. */
600
+ showLast?: boolean;
601
+ /** Render dots at the highest and lowest data points. Skipped when all
602
+ * values are equal. Default false. */
603
+ showMinMax?: boolean;
604
+ /** Render a soft gradient fill below the stroke line, fading from a
605
+ * translucent `currentColor` at the top to fully transparent at the
606
+ * bottom — the classic dashboard-tile look. The stroke line stays
607
+ * visible on top, and dots from `showLast`/`showMinMax` compose over
608
+ * the fill. Default false. */
609
+ area?: boolean;
610
+ /** Appended to the root `<svg>`'s class attribute. */
611
+ className?: string;
612
+ };
@@ -0,0 +1,6 @@
1
+ import { type GaugeOptions } from "./svg-common";
2
+ /**
3
+ * Render a radial single-value gauge for KPI, quota, saturation, or SLO style
4
+ * dashboard panels.
5
+ */
6
+ export declare const gauge: (opts: GaugeOptions) => string;
@@ -0,0 +1,6 @@
1
+ import { type HeatmapOptions } from "./svg-common";
2
+ /**
3
+ * Render a categorical two-dimensional heatmap. Cell opacity represents value
4
+ * intensity; labels are derived from first occurrence order unless provided.
5
+ */
6
+ export declare const heatmap: (opts: HeatmapOptions) => string;
@@ -0,0 +1,16 @@
1
+ import { type HistogramOptions } from "./svg-common";
2
+ /**
3
+ * Render a histogram (frequency distribution) of the given observations.
4
+ * Uses Sturges' formula by default for bin count, or accepts an explicit
5
+ * count or list of bin edges.
6
+ *
7
+ * Bars are adjacent (no inter-bar gap) since a histogram represents a
8
+ * continuous distribution. The x-axis is numeric (bin edges as ticks).
9
+ *
10
+ * @example
11
+ * charts.histogram({ data: observations, title: "Reaction times (ms)" });
12
+ *
13
+ * @example
14
+ * charts.histogram({ data: scores, bins: 20, yAxis: { label: "Count" } });
15
+ */
16
+ export declare const histogram: (opts: HistogramOptions) => string;