@pixerate/editor 0.46.1 → 0.47.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 (84) hide show
  1. package/THIRD_PARTY_NOTICES.md +20 -0
  2. package/dist/agent/index.cjs +20 -19
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +2 -2
  5. package/dist/agent/index.d.ts +2 -2
  6. package/dist/agent/index.js +4 -3
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/{builtins-DghNQbT-.d.ts → builtins-D2nMtw2W.d.ts} +1 -1
  9. package/dist/{builtins-CZW-aYKS.d.cts → builtins-xs7rK6ys.d.cts} +1 -1
  10. package/dist/chart/index.cjs +3887 -813
  11. package/dist/chart/index.cjs.map +1 -1
  12. package/dist/chart/index.d.cts +941 -239
  13. package/dist/chart/index.d.ts +941 -239
  14. package/dist/chart/index.js +3866 -792
  15. package/dist/chart/index.js.map +1 -1
  16. package/dist/{chunk-PQM5W7ZN.js → chunk-4FX5ACVG.js} +29 -2
  17. package/dist/{chunk-PQM5W7ZN.js.map → chunk-4FX5ACVG.js.map} +1 -1
  18. package/dist/{chunk-3RPOW4CS.js → chunk-5VXI5GED.js} +12 -10
  19. package/dist/{chunk-3RPOW4CS.js.map → chunk-5VXI5GED.js.map} +1 -1
  20. package/dist/{chunk-HHQ4XJWT.js → chunk-AMWXSYCI.js} +2 -2
  21. package/dist/{chunk-U7VGDSNY.cjs → chunk-BBRK6MOI.cjs} +101 -99
  22. package/dist/chunk-BBRK6MOI.cjs.map +1 -0
  23. package/dist/chunk-C3NWJE3K.js +1182 -0
  24. package/dist/chunk-C3NWJE3K.js.map +1 -0
  25. package/dist/{chunk-N4MLNJPO.cjs → chunk-H4PICYNL.cjs} +59 -12
  26. package/dist/chunk-H4PICYNL.cjs.map +1 -0
  27. package/dist/chunk-LYGEEDNR.cjs +1895 -0
  28. package/dist/chunk-LYGEEDNR.cjs.map +1 -0
  29. package/dist/chunk-NEOO6QJD.cjs +1182 -0
  30. package/dist/chunk-NEOO6QJD.cjs.map +1 -0
  31. package/dist/{chunk-Q25ZS4F7.js → chunk-PQFAHT5O.js} +53 -6
  32. package/dist/chunk-PQFAHT5O.js.map +1 -0
  33. package/dist/{chunk-ZRNHGAQT.js → chunk-REAGGLXS.js} +43 -1891
  34. package/dist/chunk-REAGGLXS.js.map +1 -0
  35. package/dist/{chunk-EFDCLENW.cjs → chunk-RIWPYSKU.cjs} +29 -2
  36. package/dist/chunk-RIWPYSKU.cjs.map +1 -0
  37. package/dist/{chunk-EWCOFSCQ.cjs → chunk-SQC26VQV.cjs} +252 -2100
  38. package/dist/chunk-SQC26VQV.cjs.map +1 -0
  39. package/dist/{chunk-K2LVZ4FA.cjs → chunk-XFYUFVAX.cjs} +3 -3
  40. package/dist/{chunk-K2LVZ4FA.cjs.map → chunk-XFYUFVAX.cjs.map} +1 -1
  41. package/dist/chunk-ZFBBVGCI.js +1895 -0
  42. package/dist/chunk-ZFBBVGCI.js.map +1 -0
  43. package/dist/commands/index.cjs +93 -11
  44. package/dist/commands/index.cjs.map +1 -1
  45. package/dist/commands/index.d.cts +9 -7
  46. package/dist/commands/index.d.ts +9 -7
  47. package/dist/commands/index.js +92 -10
  48. package/dist/commands/index.js.map +1 -1
  49. package/dist/extensions/index.cjs +3 -2
  50. package/dist/extensions/index.cjs.map +1 -1
  51. package/dist/extensions/index.d.cts +3 -2
  52. package/dist/extensions/index.d.ts +3 -2
  53. package/dist/extensions/index.js +2 -1
  54. package/dist/generation/index.cjs +2 -2
  55. package/dist/generation/index.js +1 -1
  56. package/dist/{index-jwJ_onWf.d.ts → index-CSUCQYAH.d.ts} +23 -2
  57. package/dist/{index-CfOQf70b.d.cts → index-QrqMmZ75.d.cts} +23 -2
  58. package/dist/index.cjs +12 -9
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +9 -3
  61. package/dist/index.d.ts +9 -3
  62. package/dist/index.js +26 -23
  63. package/dist/index.js.map +1 -1
  64. package/dist/parameters/index.d.cts +1 -1
  65. package/dist/parameters/index.d.ts +1 -1
  66. package/dist/{registry-vz6HOiiy.d.cts → registry-CaR7LC6W.d.cts} +2 -0
  67. package/dist/{registry-BfVD-vVg.d.ts → registry-rVtFJjRM.d.ts} +2 -0
  68. package/dist/spreadsheet/index.cjs +5 -3
  69. package/dist/spreadsheet/index.cjs.map +1 -1
  70. package/dist/spreadsheet/index.js +24 -22
  71. package/dist/tools/index.cjs +3 -3
  72. package/dist/tools/index.js +2 -2
  73. package/dist/types-BVqWm3d1.d.cts +320 -0
  74. package/dist/types-BVqWm3d1.d.ts +320 -0
  75. package/dist/vector/index.d.cts +1 -1
  76. package/dist/vector/index.d.ts +1 -1
  77. package/package.json +2 -1
  78. package/dist/chunk-EFDCLENW.cjs.map +0 -1
  79. package/dist/chunk-EWCOFSCQ.cjs.map +0 -1
  80. package/dist/chunk-N4MLNJPO.cjs.map +0 -1
  81. package/dist/chunk-Q25ZS4F7.js.map +0 -1
  82. package/dist/chunk-U7VGDSNY.cjs.map +0 -1
  83. package/dist/chunk-ZRNHGAQT.js.map +0 -1
  84. /package/dist/{chunk-HHQ4XJWT.js.map → chunk-AMWXSYCI.js.map} +0 -0
@@ -1,225 +1,16 @@
1
+ import { C as ChartAxis, a as ChartCurve, b as ChartLabelPosition, c as ChartLegendPosition, d as ChartMarker, e as ChartNumberFormat, f as ChartOrientation, g as ChartSeriesType, h as ChartStacking, i as ChartTrendlineType, j as ChartType, k as ChartTheme, l as ChartSeries, m as ChartIssue, n as ChartSpec, o as ChartTrendline, p as ChartValue, q as ChartRect, r as ChartSelection, s as ChartScene, t as ChartTextMark, u as ChartWarning, v as ChartLegend, w as ChartValueScale } from '../types-BVqWm3d1.js';
2
+ export { x as ChartCircleMark, y as ChartLineMark, z as ChartMark, A as ChartMarkRole, B as ChartPathMark, D as ChartRectMark } from '../types-BVqWm3d1.js';
1
3
  import { H as HistoryManager } from '../HistoryManager-DWSLd6Tf.js';
2
- import { C as CommandSpec } from '../registry-BfVD-vVg.js';
4
+ import { C as CommandSpec } from '../registry-rVtFJjRM.js';
5
+ import { A as AgentToolProvider } from '../registry-CSlH4iUn.js';
3
6
  import '../types-DsiXGmjo.js';
4
7
  import '../schema-Di0CS6Pe.js';
5
8
 
6
- /** Chart kinds. `bar`, `line`, `area` and `scatter` are cartesian; series may mix them (a combo chart). */
7
- type ChartType = 'bar' | 'line' | 'area' | 'scatter' | 'pie' | 'donut';
8
- /** How a series is drawn in a cartesian chart. */
9
- type ChartSeriesType = 'bar' | 'line' | 'area' | 'scatter';
10
- /** One data value; `null` is a gap (missing value). */
11
- type ChartValue = number | null;
12
- interface ChartSeries {
13
- /** Stable id (unique within the chart). */
14
- id: string;
15
- name: string;
16
- /** One value per category. */
17
- values: ChartValue[];
18
- /** CSS colour (default: the palette colour for the series' position). */
19
- color?: string;
20
- /** Overrides the chart type for this series (cartesian charts only). */
21
- type?: ChartSeriesType;
22
- /** Hidden series keep their data but are not drawn or scaled. */
23
- hidden?: boolean;
24
- }
25
- interface ChartNumberFormat {
26
- /** `number` (default), `percent` (0.25 → 25%), `currency` or `compact` (1.2K). */
27
- style?: 'number' | 'percent' | 'currency' | 'compact';
28
- /** Fixed decimals (default: as many as the ticks need, up to 2). */
29
- decimals?: number;
30
- /** ISO currency code for `currency` (default `USD`). */
31
- currency?: string;
32
- prefix?: string;
33
- suffix?: string;
34
- }
35
- interface ChartAxis {
36
- /** Draw the axis line, ticks and labels (default `true`). */
37
- show: boolean;
38
- title: string;
39
- /** Fixed lower bound (default: from the data, including 0 for bars and areas). */
40
- min: number | null;
41
- /** Fixed upper bound (default: from the data). */
42
- max: number | null;
43
- /** Grid lines at each tick (default: on for the value axis). */
44
- gridlines: boolean;
45
- /** How tick and data labels are written (value axis only). */
46
- format: ChartNumberFormat;
47
- }
48
- type ChartLegendPosition = 'top' | 'bottom' | 'left' | 'right';
49
- interface ChartLegend {
50
- show: boolean;
51
- position: ChartLegendPosition;
52
- }
53
- type ChartStacking = 'none' | 'stacked' | 'percent';
54
- type ChartOrientation = 'vertical' | 'horizontal';
55
- type ChartCurve = 'linear' | 'smooth' | 'step';
56
- /** A whole chart: data plus presentation. Plain JSON, safe to persist. */
57
- interface ChartSpec {
58
- version: 1;
59
- type: ChartType;
60
- title: string;
61
- subtitle: string;
62
- /** Category labels (the x axis, or pie slices). */
63
- categories: string[];
64
- series: ChartSeries[];
65
- /** The category axis. */
66
- xAxis: ChartAxis;
67
- /** The value axis. */
68
- yAxis: ChartAxis;
69
- legend: ChartLegend;
70
- /** Stack bars and areas (`percent` scales each category to 100%). */
71
- stacking: ChartStacking;
72
- /** `horizontal` draws bars sideways (bar charts only). */
73
- orientation: ChartOrientation;
74
- /** Line and area interpolation. */
75
- curve: ChartCurve;
76
- /** Dots on line and area series. */
77
- points: boolean;
78
- /** Value labels on bars, points and slices. */
79
- dataLabels: boolean;
80
- /** Series colours in order (cycled). */
81
- palette: string[];
82
- /** Donut hole as a fraction of the radius (0–0.9). */
83
- innerRadius: number;
84
- }
85
- /** What a click selects. */
86
- type ChartSelection = {
87
- kind: 'chart';
88
- } | {
89
- kind: 'title';
90
- } | {
91
- kind: 'subtitle';
92
- } | {
93
- kind: 'legend';
94
- } | {
95
- kind: 'axis';
96
- axis: 'x' | 'y';
97
- } | {
98
- kind: 'series';
99
- seriesId: string;
100
- } | {
101
- kind: 'point';
102
- seriesId: string;
103
- index: number;
104
- } | {
105
- kind: 'category';
106
- index: number;
107
- };
108
- /** Colours and type used to lay out a chart. Any CSS colour strings work. */
109
- interface ChartTheme {
110
- /** Fill behind the chart (`transparent` lets the page show through). */
111
- background: string;
112
- /** The page colour: slice separators and hollow points (set it when `background` is transparent). */
113
- surface: string;
114
- text: string;
115
- mutedText: string;
116
- grid: string;
117
- axis: string;
118
- /** Outline drawn around the selected mark. */
119
- selection: string;
120
- fontFamily: string;
121
- fontSize: number;
122
- titleSize: number;
123
- }
124
- interface ChartRect {
125
- x: number;
126
- y: number;
127
- width: number;
128
- height: number;
129
- }
130
- /** What a mark is, for styling and tests. */
131
- type ChartMarkRole = 'background' | 'title' | 'subtitle' | 'grid' | 'axis' | 'tick' | 'tick-label' | 'axis-title' | 'bar' | 'line' | 'area' | 'point' | 'slice' | 'data-label' | 'legend-swatch' | 'legend-label' | 'selection' | 'empty';
132
- interface ChartMarkBase {
133
- /** Unique within the scene (a stable key for frameworks). */
134
- key: string;
135
- role: ChartMarkRole;
136
- /** What clicking this mark selects (none: not clickable). */
137
- target?: ChartSelection;
138
- /** Mark belongs to the current selection. */
139
- selected?: boolean;
140
- opacity?: number;
141
- }
142
- interface ChartRectMark extends ChartMarkBase {
143
- kind: 'rect';
144
- x: number;
145
- y: number;
146
- width: number;
147
- height: number;
148
- fill: string;
149
- stroke?: string;
150
- strokeWidth?: number;
151
- radius?: number;
152
- }
153
- interface ChartPathMark extends ChartMarkBase {
154
- kind: 'path';
155
- d: string;
156
- fill?: string;
157
- stroke?: string;
158
- strokeWidth?: number;
159
- dash?: string;
160
- }
161
- interface ChartCircleMark extends ChartMarkBase {
162
- kind: 'circle';
163
- cx: number;
164
- cy: number;
165
- r: number;
166
- fill: string;
167
- stroke?: string;
168
- strokeWidth?: number;
169
- }
170
- interface ChartLineMark extends ChartMarkBase {
171
- kind: 'line';
172
- x1: number;
173
- y1: number;
174
- x2: number;
175
- y2: number;
176
- stroke: string;
177
- strokeWidth?: number;
178
- dash?: string;
179
- }
180
- interface ChartTextMark extends ChartMarkBase {
181
- kind: 'text';
182
- x: number;
183
- y: number;
184
- text: string;
185
- anchor: 'start' | 'middle' | 'end';
186
- /** Vertical alignment of the text box to `y`. */
187
- baseline: 'top' | 'middle' | 'bottom';
188
- size: number;
189
- weight?: number;
190
- fill: string;
191
- /** Degrees, around (x, y). */
192
- rotate?: number;
193
- }
194
- type ChartMark = ChartRectMark | ChartPathMark | ChartCircleMark | ChartLineMark | ChartTextMark;
195
- /** Maps between data values and scene pixels along one axis of the plot. */
196
- interface ChartValueScale {
197
- /** `y` for vertical charts, `x` for horizontal bars. */
198
- axis: 'x' | 'y';
199
- domain: [number, number];
200
- range: [number, number];
201
- ticks: number[];
202
- }
203
- /** A laid-out chart: drawing primitives in scene pixels, ready for SVG, canvas or anything else. */
204
- interface ChartScene {
205
- width: number;
206
- height: number;
207
- /** The plot area (inside the axes). Empty for pies. */
208
- plot: ChartRect;
209
- /** Draw in order. */
210
- marks: ChartMark[];
211
- /** The value scale of a cartesian chart (absent for pies and empty charts). */
212
- valueScale?: ChartValueScale;
213
- /** Percent-stacked: values are shown as shares, so dragging is disabled. */
214
- percent: boolean;
215
- theme: ChartTheme;
216
- }
217
- interface ChartIssue {
218
- path: string;
219
- message: string;
220
- }
221
-
222
9
  declare const CHART_TYPES: readonly ChartType[];
10
+ declare const CHART_MARKERS: readonly ChartMarker[];
11
+ declare const CHART_TRENDLINE_TYPES: readonly ChartTrendlineType[];
12
+ declare const CHART_LABEL_POSITIONS: readonly ChartLabelPosition[];
13
+ declare const CHART_AXIS_KINDS: readonly NonNullable<ChartAxis['kind']>[];
223
14
  declare const CHART_SERIES_TYPES: readonly ChartSeriesType[];
224
15
  declare const CHART_STACKINGS: readonly ChartStacking[];
225
16
  declare const CHART_CURVES: readonly ChartCurve[];
@@ -228,6 +19,8 @@ declare const CHART_LEGEND_POSITIONS: readonly ChartLegendPosition[];
228
19
  declare const CHART_NUMBER_STYLES: readonly NonNullable<ChartNumberFormat['style']>[];
229
20
  /** Labels for pickers, shared by the React and Svelte components. */
230
21
  declare const CHART_TYPE_LABELS: Readonly<Record<ChartType, string>>;
22
+ /** How a chart type is laid out. */
23
+ type ChartFamily = 'cartesian' | 'xy' | 'pie' | 'radar' | 'waterfall' | 'histogram' | 'box' | 'funnel' | 'treemap';
231
24
  /** A colour-blind-friendly categorical palette (Okabe–Ito order, tuned for light and dark backgrounds). */
232
25
  declare const DEFAULT_CHART_PALETTE: readonly string[];
233
26
  declare const DEFAULT_CHART_THEME: ChartTheme;
@@ -237,7 +30,14 @@ declare const DEFAULT_CHART_THEME: ChartTheme;
237
30
  * inline styles use them), with light fallbacks. The React and Svelte canvases use it.
238
31
  */
239
32
  declare const CSS_VARIABLE_CHART_THEME: ChartTheme;
33
+ /** Bar, line, area and scatter: categories (or numeric x) against values, series may mix. */
240
34
  declare function isCartesianChart(type: ChartType): boolean;
35
+ /** Whether the chart plots series against a numeric x axis (bubble charts, and scatter charts with x values). */
36
+ declare function isXyChart(spec: Pick<ChartSpec, 'type' | 'series'>): boolean;
37
+ /** How a chart is laid out (see `ChartType`). */
38
+ declare function chartFamily(spec: Pick<ChartSpec, 'type' | 'series'>): ChartFamily;
39
+ /** Chart types whose legend lists categories (one colour per category) rather than series. */
40
+ declare function chartColorsByCategory(type: ChartType): boolean;
241
41
  declare function defaultChartAxis(value: boolean): ChartAxis;
242
42
  /** A complete spec with every default filled in. */
243
43
  declare function createChartSpec(partial?: Partial<ChartSpec>): ChartSpec;
@@ -245,6 +45,8 @@ declare function createChartSpec(partial?: Partial<ChartSpec>): ChartSpec;
245
45
  declare function chartSeriesColor(spec: Pick<ChartSpec, 'palette' | 'series'>, seriesIndex: number): string;
246
46
  /** The colour a pie slice is drawn with (by category). */
247
47
  declare function chartSliceColor(spec: Pick<ChartSpec, 'palette'>, index: number): string;
48
+ /** The colour of one bar or point: its override, else the series colour. */
49
+ declare function chartPointColor(spec: Pick<ChartSpec, 'palette' | 'series'>, seriesIndex: number, index: number): string;
248
50
  /** How a series is drawn in a cartesian chart. */
249
51
  declare function chartSeriesType(spec: Pick<ChartSpec, 'type'>, series: ChartSeries): ChartSeriesType;
250
52
  /** An id not used by any series (`series-1`, `series-2`, …). */
@@ -257,6 +59,8 @@ declare function parseChartValue(input: unknown): ChartValue | undefined;
257
59
  declare function normalizeChartAxis(value: unknown, fallback: ChartAxis, path: string, issues?: ChartIssue[]): ChartAxis;
258
60
  /** Values as numbers or nulls; bad entries become null and are reported. */
259
61
  declare function normalizeChartValues(value: unknown, length: number | undefined, path: string, issues?: ChartIssue[]): ChartValue[];
62
+ /** Checks one trendline; `null` (reported) when it is unusable. */
63
+ declare function normalizeChartTrendline(value: unknown, path: string, issues?: ChartIssue[]): ChartTrendline | null;
260
64
  /**
261
65
  * Turns any input (a partial spec, saved JSON, an agent's arguments) into a complete,
262
66
  * valid `ChartSpec`. Every value is checked; problems are reported as sentences in
@@ -276,8 +80,16 @@ interface ChartTableOptions {
276
80
  * series. `rows`: the first row holds categories and each other row is a series.
277
81
  */
278
82
  seriesIn?: 'columns' | 'rows';
279
- /** The first row (or column for `rows`) holds series names (default `true`). */
280
- header?: boolean;
83
+ /**
84
+ * The first row (or column for `rows`) holds series names (default `true`). `auto`: only
85
+ * when one of its value cells is not a number.
86
+ */
87
+ header?: boolean | 'auto';
88
+ /**
89
+ * Read the first column as numeric x values (scatter and bubble charts): every series gets
90
+ * them as `x`, and the categories are their labels.
91
+ */
92
+ xFromFirstColumn?: boolean;
281
93
  }
282
94
  interface ChartTableData {
283
95
  categories: string[];
@@ -321,6 +133,266 @@ declare function formatChartNumber(value: number | null | undefined, format?: Ch
321
133
  /** Linear map from `domain` to `range`. */
322
134
  declare function linearMap(value: number, domain: readonly [number, number], range: readonly [number, number]): number;
323
135
 
136
+ /**
137
+ * A compiled spreadsheet number format code for chart labels, e.g. `#,##0.00`, `0.0%`,
138
+ * `#,##0,,"M"`, `$#,##0;[Red]($#,##0);"–"` or `yyyy-mm-dd`. Backed by the spreadsheet's
139
+ * format engine (`NumberFormat`), so charts and sheets write numbers the same way; colours
140
+ * such as `[Red]` are ignored on charts.
141
+ */
142
+ interface ChartFormatCode {
143
+ format(value: number): string;
144
+ /** The code is a date or time format (values are serial day numbers from 1899-12-30). */
145
+ isDate: boolean;
146
+ /** The code shows a percentage (values are multiplied by 100). */
147
+ isPercent: boolean;
148
+ }
149
+ /** Compiles a spreadsheet format code (cached). */
150
+ declare function compileChartFormatCode(code: string): ChartFormatCode;
151
+ /** Formats `value` with a spreadsheet format code. */
152
+ declare function formatChartValueWithCode(value: number, code: string): string;
153
+ /** A spreadsheet serial day number (1 = 1900-01-01, with the 1900 leap-year quirk) as a UTC date. */
154
+ declare function chartSerialToDate(serial: number): Date;
155
+ /** A UTC date as a spreadsheet serial day number. */
156
+ declare function chartDateToSerial(date: Date): number;
157
+
158
+ /** An sRGB colour with channels from 0 to 1. */
159
+ type ChartRgb = [number, number, number];
160
+ /**
161
+ * Reads `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` and a few colour names. Returns
162
+ * `null` for anything else (CSS variables, `hsl()`, …), so callers can leave such colours alone.
163
+ */
164
+ declare function parseChartColor(color: string): ChartRgb | null;
165
+ declare function chartRgbToHex(rgb: ChartRgb): string;
166
+ /**
167
+ * A lighter (`amount` > 0, towards white) or darker (`amount` < 0, towards black) shade of
168
+ * `color`. Colours it cannot read (CSS variables) come back unchanged.
169
+ */
170
+ declare function shadeChartColor(color: string, amount: number): string;
171
+ /** Shades used once a palette is used up: the same hues, lighter then darker (GridCraft's cycle). */
172
+ declare const CHART_PALETTE_SHADES: readonly number[];
173
+ /** The palette colour for the `index`-th item: the palette in order, then lighter and darker rounds of it. */
174
+ declare function cyclePaletteColor(palette: readonly string[], index: number): string;
175
+ /** WCAG relative luminance (0 black – 1 white). */
176
+ declare function chartLuminance(rgb: ChartRgb): number;
177
+ /** WCAG contrast ratio (1–21) between two colours, or `null` when either cannot be read. */
178
+ declare function chartContrastRatio(a: string, b: string): number | null;
179
+ /**
180
+ * Dark or white text, whichever reads better on `fill`; `fallback` when the fill cannot be
181
+ * read (a CSS variable).
182
+ */
183
+ declare function chartTextOn(fill: string, fallback: string, dark?: string, light?: string): string;
184
+ /** OKLab (Ottosson) from sRGB. */
185
+ declare function chartRgbToOklab(rgb: ChartRgb): [number, number, number];
186
+ /** Perceptual distance between two colours (Euclidean in OKLab; ≈0.02 is just noticeable). */
187
+ declare function chartColorDistance(a: ChartRgb, b: ChartRgb): number;
188
+ type ChartVision = 'normal' | 'protanopia' | 'deuteranopia' | 'tritanopia';
189
+ /** How a colour looks with a colour-vision deficiency (Machado et al. 2009, full severity). */
190
+ declare function simulateChartVision(rgb: ChartRgb, vision: ChartVision): ChartRgb;
191
+ interface ChartColorPair {
192
+ a: number;
193
+ b: number;
194
+ colors: [string, string];
195
+ distance: number;
196
+ }
197
+ interface ChartColorCheck {
198
+ /** No problems found. */
199
+ ok: boolean;
200
+ /** Per vision: the closest pair of colours and their OKLab distance. */
201
+ closest: Partial<Record<ChartVision, ChartColorPair>>;
202
+ /** Contrast ratio of each colour against the surface (null when unreadable). */
203
+ contrast: (number | null)[];
204
+ /** Problems, as sentences. */
205
+ issues: string[];
206
+ /** Colours that could not be read (CSS variables, `hsl()`); they are skipped. */
207
+ skipped: string[];
208
+ }
209
+ interface ChartColorCheckOptions {
210
+ /** The page colour behind the marks (default white). */
211
+ surface?: string;
212
+ /** Smallest OKLab distance two series may have (default 0.08). */
213
+ minDistance?: number;
214
+ /** Smallest contrast ratio against the surface (default 1.5; WCAG asks 3 for graphics). */
215
+ minContrast?: number;
216
+ /** Visions to check (default all four). */
217
+ visions?: readonly ChartVision[];
218
+ }
219
+ /**
220
+ * Checks that series colours can be told apart, with normal vision and the three
221
+ * colour-vision deficiencies, and stand out from the surface. Returns the closest pair per
222
+ * vision and problems as sentences.
223
+ */
224
+ declare function checkChartColors(colors: readonly string[], options?: ChartColorCheckOptions): ChartColorCheck;
225
+
226
+ /**
227
+ * Reads a category label as a UTC date: `2024`, `2024-03`, `2024-03-05`, ISO date-times,
228
+ * `2024/03/05`, `Mar 2024` and `5 Mar 2024`. Returns milliseconds since the epoch, or `null`.
229
+ */
230
+ declare function parseChartDate(label: string): number | null;
231
+ /** Calendar steps from fine to coarse. */
232
+ declare const CHART_DATE_STEPS: readonly [{
233
+ readonly unit: "day";
234
+ readonly count: 1;
235
+ }, {
236
+ readonly unit: "day";
237
+ readonly count: 2;
238
+ }, {
239
+ readonly unit: "week";
240
+ readonly count: 1;
241
+ }, {
242
+ readonly unit: "week";
243
+ readonly count: 2;
244
+ }, {
245
+ readonly unit: "month";
246
+ readonly count: 1;
247
+ }, {
248
+ readonly unit: "month";
249
+ readonly count: 3;
250
+ }, {
251
+ readonly unit: "month";
252
+ readonly count: 6;
253
+ }, {
254
+ readonly unit: "year";
255
+ readonly count: 1;
256
+ }, {
257
+ readonly unit: "year";
258
+ readonly count: 2;
259
+ }, {
260
+ readonly unit: "year";
261
+ readonly count: 5;
262
+ }, {
263
+ readonly unit: "year";
264
+ readonly count: 10;
265
+ }, {
266
+ readonly unit: "year";
267
+ readonly count: 25;
268
+ }, {
269
+ readonly unit: "year";
270
+ readonly count: 50;
271
+ }, {
272
+ readonly unit: "year";
273
+ readonly count: 100;
274
+ }];
275
+ type ChartDateStep = (typeof CHART_DATE_STEPS)[number];
276
+ /** A label for a date at `step`: years as `2024`, months as `Mar 2024` (`Mar` within a year), days as `5 Mar`. */
277
+ declare function formatChartDate(t: number, step: ChartDateStep, previous?: number | null): string;
278
+ interface ChartDateLabels {
279
+ /** The calendar step chosen. */
280
+ step: ChartDateStep;
281
+ /** Category indexes that get a label (the first category in each bucket). */
282
+ indexes: number[];
283
+ /** Label text by category index. */
284
+ labels: Map<number, string>;
285
+ }
286
+ /**
287
+ * Picks the finest calendar step whose labels fit along a category axis. Categories are
288
+ * evenly spaced (`band` pixels each), so a label goes on the first category of each bucket,
289
+ * and the step is the first on the ladder whose neighbouring labels are at least their own
290
+ * width plus `gap` apart. Returns `null` when fewer than half the categories read as dates.
291
+ */
292
+ declare function chartDateLabels(categories: readonly string[], band: number, measure: (text: string) => number, gap?: number): ChartDateLabels | null;
293
+
294
+ interface ChartHistogramBin {
295
+ /** Lower edge (exclusive, except for the first bin). */
296
+ from: number;
297
+ /** Upper edge (inclusive). */
298
+ to: number;
299
+ count: number;
300
+ }
301
+ /**
302
+ * Bins values into `bins` equal-width bins (default √n, from 1 to 100). Bins are
303
+ * right-inclusive, the first closed on both sides, so a value on an edge belongs to the bin
304
+ * that ends there. Gaps and non-finite values are ignored.
305
+ */
306
+ declare function chartHistogram(values: readonly ChartValue[], bins?: number | null): ChartHistogramBin[];
307
+ /** The `q` quantile (0–1) of sorted values, interpolating linearly between ranks (`q·(n-1)`). */
308
+ declare function chartQuantile(sorted: readonly number[], q: number): number;
309
+ interface ChartBoxStats {
310
+ min: number;
311
+ max: number;
312
+ q1: number;
313
+ median: number;
314
+ q3: number;
315
+ mean: number;
316
+ /** Whisker ends: the furthest values within 1.5 × IQR of the box. */
317
+ lowerWhisker: number;
318
+ upperWhisker: number;
319
+ /** Values beyond the whiskers. */
320
+ outliers: number[];
321
+ count: number;
322
+ }
323
+ /** Box-and-whisker statistics (Tukey fences at 1.5 × IQR); `null` without values. */
324
+ declare function chartBoxStats(values: readonly ChartValue[]): ChartBoxStats | null;
325
+ /** Squarified treemap (Bruls et al.): positive `values` packed into `rect`, largest first. Returns one rect per input index (zero-size for values ≤ 0). */
326
+ declare function chartSquarify(values: readonly number[], rect: ChartRect): ChartRect[];
327
+ /**
328
+ * Thins a long polyline (sorted by x) to the first, lowest, highest and last point of each
329
+ * pixel column, which draws identically. Returns the input when it has `max` points or fewer.
330
+ */
331
+ declare function decimateChartPoints<T extends {
332
+ x: number;
333
+ y: number;
334
+ }>(points: readonly T[], max?: number): T[];
335
+ interface ChartSeriesSummary {
336
+ id: string;
337
+ name: string;
338
+ /** Values present (not gaps). */
339
+ count: number;
340
+ gaps: number;
341
+ min: number | null;
342
+ max: number | null;
343
+ mean: number | null;
344
+ sum: number | null;
345
+ /** Category label of the minimum and maximum. */
346
+ minAt: string | null;
347
+ maxAt: string | null;
348
+ /** Direction of a least-squares line through the values in order. */
349
+ trend: 'rising' | 'falling' | 'flat' | null;
350
+ /** Relative change from the first to the last value, e.g. 0.25 for +25%. */
351
+ change: number | null;
352
+ }
353
+ /** Numbers about one series, for agents that check a chart without looking at it. */
354
+ declare function summarizeChartSeries(series: {
355
+ id: string;
356
+ name: string;
357
+ values: readonly ChartValue[];
358
+ }, categories: readonly string[]): ChartSeriesSummary;
359
+
360
+ /**
361
+ * A fitted regression trendline. Exponential, logarithmic and power fits are linear fits of
362
+ * transformed data (`ln y ~ x`, `y ~ ln x`, `ln y ~ ln x`), as spreadsheets document them;
363
+ * points the transform cannot take (values ≤ 0) are skipped, and R² is for the transformed fit.
364
+ */
365
+ interface ChartTrendFit {
366
+ type: Exclude<ChartTrendlineType, 'moving-average'>;
367
+ /** Coefficients `c0…cd` of `Y = Σ cₖ·Xᵏ` in the transformed variables. */
368
+ coefficients: number[];
369
+ /** Coefficient of determination; `null` when undefined (all y equal). */
370
+ r2: number | null;
371
+ /** The equation as a label, e.g. `y = 0.5x² - 2x + 1` or `y = 3e^(0.2x)`. */
372
+ equation: string;
373
+ /** Number of points used. */
374
+ points: number;
375
+ /** The fitted y at `x`, or `null` outside the fit's domain (x ≤ 0 for log and power). */
376
+ evaluate(x: number): number | null;
377
+ }
378
+ /**
379
+ * Fits `trendline` to the points. Returns `null` for moving averages (see
380
+ * `chartMovingAverage`) and degenerate data: too few usable points, all x equal, or a
381
+ * singular system.
382
+ */
383
+ declare function fitChartTrendline(trendline: ChartTrendline, points: ReadonlyArray<readonly [number, number]>): ChartTrendFit | null;
384
+ /** A coefficient as trendline labels show it: up to four decimals, scientific when tiny or huge. */
385
+ declare function trendNumberText(v: number): string;
386
+ /**
387
+ * Moving average of `period` consecutive points in plotted order: point `i` (from
388
+ * `period - 1`) is `(xᵢ, mean(yᵢ₋ₚ₊₁ … yᵢ))`. Empty when there are fewer points than `period`.
389
+ */
390
+ declare function chartMovingAverage(points: ReadonlyArray<readonly [number, number]>, period: number): [number, number][];
391
+ /** The legend name spreadsheets give a trendline, e.g. `Linear (Sales)`. */
392
+ declare function chartTrendlineName(trendline: ChartTrendline, seriesName: string): string;
393
+ /** Whether trendlines can be drawn for this chart type and stacking (unstacked cartesian and xy charts). */
394
+ declare function chartSupportsTrendlines(type: string, stacking: string): boolean;
395
+
324
396
  type ChartTextMeasure = (text: string, size: number, weight?: number) => number;
325
397
  interface ChartLayoutOptions {
326
398
  width: number;
@@ -340,6 +412,21 @@ interface ChartLayoutOptions {
340
412
  min: number;
341
413
  max: number;
342
414
  } | null;
415
+ /** Fixes the secondary value axis the same way (`ChartPointDrag.valueDomain2`). */
416
+ valueDomain2?: {
417
+ min: number;
418
+ max: number;
419
+ } | null;
420
+ /** Fixes the numeric x axis of a scatter or bubble chart (`ChartPointDrag.xDomain`). */
421
+ xDomain?: {
422
+ min: number;
423
+ max: number;
424
+ } | null;
425
+ /** Shows the value of this point next to it (a `drag-readout` text mark, kept inside the plot). */
426
+ readout?: {
427
+ seriesId: string;
428
+ index: number;
429
+ } | null;
343
430
  }
344
431
  /** A DOM-free text width estimate (average glyph ≈ 0.56 em, bold ≈ 0.6 em). */
345
432
  declare const estimateChartTextWidth: ChartTextMeasure;
@@ -350,23 +437,38 @@ declare function sameChartSelection(a: ChartSelection | null | undefined, b: Cha
350
437
  * luminance (0.299 R + 0.587 G + 0.114 B). Unparseable colours (CSS variables) get white.
351
438
  */
352
439
  declare function contrastingTextColor(fill: string): string;
440
+
353
441
  /**
354
442
  * Lays a chart out as drawing primitives (rects, paths, circles, lines and text) in a
355
443
  * `width × height` box. Pure and DOM-free: the React and Svelte canvases render the marks
356
444
  * as SVG, `chartSceneToSvg` writes them as a string, and anything else (canvas, PDF) can
357
- * draw them too. Clickable marks carry the `target` they select.
445
+ * draw them too. Clickable marks carry the `target` they select; what had to be left out
446
+ * (hidden labels, thinned lines) is listed in `warnings`.
358
447
  */
359
448
  declare function layoutChart(spec: ChartSpec, options: ChartLayoutOptions): ChartScene;
360
449
  /**
361
450
  * The data value at a scene point along the value axis (for dragging a bar or point), or
362
- * `undefined` when the scene has no value scale or is percent-stacked.
451
+ * `undefined` when the scene has no value scale or is percent-stacked. `secondary` reads the
452
+ * secondary axis.
363
453
  */
364
454
  declare function chartValueAtPoint(scene: ChartScene, point: {
365
455
  x: number;
366
456
  y: number;
457
+ }, secondary?: boolean): number | undefined;
458
+ /** The x value at a scene point on a scatter or bubble chart, or `undefined` without a numeric x axis. */
459
+ declare function chartXAtPoint(scene: ChartScene, point: {
460
+ x: number;
461
+ y: number;
367
462
  }): number | undefined;
368
463
  /** The value a drag should store: snapped to a tenth of the tick step (or `step`) and kept finite. */
369
- declare function snapChartValue(scene: ChartScene, value: number, step?: number): number;
464
+ declare function snapChartValue(scene: ChartScene, value: number, step?: number, ticks?: readonly number[]): number;
465
+
466
+ /** Data labels are skipped on series with more points than this. */
467
+ declare const MAX_CHART_DATA_LABELS = 200;
468
+ /** Lines with more points than this are thinned per pixel column. */
469
+ declare const MAX_CHART_LINE_POINTS = 2000;
470
+ /** Markers beyond this many are thinned to one per 2px cell. */
471
+ declare const MAX_CHART_MARKERS = 1000;
370
472
 
371
473
  /** SVG `dominant-baseline` for a text mark's baseline (shared by every renderer). */
372
474
  declare function chartTextBaseline(baseline: ChartTextMark['baseline']): 'hanging' | 'central' | 'text-after-edge';
@@ -377,12 +479,170 @@ interface ChartSvgOptions {
377
479
  hideSelection?: boolean;
378
480
  /** Accessible title (default: the chart title). */
379
481
  ariaLabel?: string;
482
+ /** A longer description written as `<desc>` (`chartToSvg` defaults to `describeChart`). */
483
+ description?: string;
380
484
  }
381
485
  /** Writes a laid-out scene as a standalone SVG document string. */
382
486
  declare function chartSceneToSvg(scene: ChartScene, options?: ChartSvgOptions): string;
383
487
  /** Lays out and writes a chart as SVG, e.g. for export or server rendering. */
384
488
  declare function chartToSvg(spec: ChartSpec, options: Omit<ChartLayoutOptions, 'selection'> & ChartSvgOptions): string;
385
489
 
490
+ interface ChartSummary {
491
+ type: ChartSpec['type'];
492
+ title: string;
493
+ categories: number;
494
+ series: ChartSeriesSummary[];
495
+ /** The value axis as drawn: range and ticks (absent for pies and treemaps). */
496
+ valueAxis?: {
497
+ min: number;
498
+ max: number;
499
+ ticks: number[];
500
+ };
501
+ secondaryAxis?: {
502
+ min: number;
503
+ max: number;
504
+ ticks: number[];
505
+ };
506
+ xAxis?: {
507
+ min: number;
508
+ max: number;
509
+ ticks: number[];
510
+ };
511
+ /** What the layout left out at this size (hidden labels, thinned lines, …). */
512
+ warnings: ChartWarning[];
513
+ /** Whether the series colours can be told apart (also with colour-blindness). */
514
+ colors: Pick<ChartColorCheck, 'ok' | 'issues'>;
515
+ /** A plain-language description (the SVG `<desc>`). */
516
+ description: string;
517
+ }
518
+ /**
519
+ * Numbers about a chart for agents and screen readers: per-series min / max / mean / trend,
520
+ * the axes as drawn, layout warnings at `size`, a colour check and a one-paragraph
521
+ * description. Lets an agent verify a chart without rendering it.
522
+ */
523
+ declare function summarizeChart(spec: ChartSpec, size?: Pick<ChartLayoutOptions, 'width' | 'height' | 'measureText'>, scene?: ChartScene): ChartSummary;
524
+ /** A plain-language description of a chart: type, what it compares, ranges and notable extremes. */
525
+ declare function describeChart(spec: ChartSpec, series?: ChartSeriesSummary[]): string;
526
+
527
+ type ChartSparklineKind = 'line' | 'column' | 'win-loss';
528
+ interface ChartSparklineOptions {
529
+ kind?: ChartSparklineKind;
530
+ width: number;
531
+ height: number;
532
+ /** Line, positive column and win colour (default the first palette colour). */
533
+ color?: string;
534
+ /** Negative column and loss colour (default red). */
535
+ negativeColor?: string;
536
+ /** Dots on every line point (thinned past 500). */
537
+ markers?: boolean;
538
+ /** Highlight the highest and lowest point of a line (or column). */
539
+ highLow?: boolean;
540
+ /** Fixed value range (default: the data, including 0 for columns). */
541
+ min?: number;
542
+ max?: number;
543
+ }
544
+ /**
545
+ * Lays out a word-sized chart (a sparkline) as marks: a line broken at gaps, columns
546
+ * (negatives in `negativeColor`) or win/loss bars of equal height. Long lines are thinned past
547
+ * 4000 points. Returns a scene with no axes, legend or targets.
548
+ */
549
+ declare function layoutSparkline(values: readonly ChartValue[], options: ChartSparklineOptions): ChartScene;
550
+ /** A sparkline as a standalone SVG string (e.g. for an inline image in rich text). */
551
+ declare function sparklineToSvg(values: readonly ChartValue[], options: ChartSparklineOptions & {
552
+ ariaLabel?: string;
553
+ }): string;
554
+
555
+ /** A partial change several fields at once (what `ChartController.update` takes). */
556
+ type ChartPresetPatch = Partial<Omit<ChartSpec, 'version' | 'xAxis' | 'yAxis' | 'yAxis2' | 'legend' | 'series' | 'categories'>> & {
557
+ xAxis?: Partial<ChartAxis>;
558
+ yAxis?: Partial<ChartAxis>;
559
+ yAxis2?: Partial<ChartAxis>;
560
+ legend?: Partial<ChartLegend>;
561
+ };
562
+ interface ChartLayoutPreset {
563
+ id: string;
564
+ label: string;
565
+ description: string;
566
+ patch: ChartPresetPatch;
567
+ }
568
+ /** Quick layouts: legend, labels and grid lines set together. */
569
+ declare const CHART_LAYOUT_PRESETS: readonly ChartLayoutPreset[];
570
+ interface ChartColorScheme {
571
+ id: string;
572
+ label: string;
573
+ description: string;
574
+ palette: readonly string[];
575
+ }
576
+ /** Shades of one hue, dark to light (for monochrome schemes). */
577
+ declare function monochromeChartPalette(base: string, count?: number): string[];
578
+ /** Named palettes. `default` and `okabe-ito` are colour-blind friendly. */
579
+ declare const CHART_COLOR_SCHEMES: readonly ChartColorScheme[];
580
+ /** The change a named layout and / or colour scheme makes, or a sentence saying which names exist. */
581
+ declare function chartPresetPatch(options: {
582
+ layout?: string;
583
+ colors?: string;
584
+ }): {
585
+ ok: true;
586
+ patch: ChartPresetPatch;
587
+ } | {
588
+ ok: false;
589
+ message: string;
590
+ };
591
+
592
+ interface ChartTableShape {
593
+ /** The first row holds series names (some text, every value cell text or blank). */
594
+ headerRow: boolean;
595
+ /** The first column holds category labels (all text, or a blank top-left cell above a header row). */
596
+ labelColumn: boolean;
597
+ /** Series run along rows (the block is much wider than tall). */
598
+ byRows: boolean;
599
+ series: number;
600
+ /** Points per series. */
601
+ points: number;
602
+ anyNumber: boolean;
603
+ nonNegative: boolean;
604
+ mixedSigns: boolean;
605
+ /** The category labels read as dates. */
606
+ dates: boolean;
607
+ }
608
+ /**
609
+ * Reads the shape of a block of cells the way spreadsheets do: a header row when the first
610
+ * row is text, a label column when the first column is text (or the top-left cell is blank
611
+ * above a header row, the convention for years and x values), and series along the longer side.
612
+ */
613
+ declare function analyzeChartTable(rows: ReadonlyArray<ReadonlyArray<unknown>>): ChartTableShape;
614
+ interface ChartRecommendation {
615
+ type: ChartType;
616
+ stacking?: ChartStacking;
617
+ label: string;
618
+ /** Why it suits the data, as a sentence. */
619
+ reason: string;
620
+ }
621
+ /**
622
+ * Chart types that suit the shape of a block of cells, best first. A heuristic from the shape
623
+ * (series count, points per series, text or date categories, negative values), not a copy of
624
+ * any spreadsheet's ranking.
625
+ */
626
+ declare function recommendChartTypes(rows: ReadonlyArray<ReadonlyArray<unknown>>): ChartRecommendation[];
627
+ declare function recommendForShape(shape: Omit<ChartTableShape, 'headerRow' | 'byRows'> & Partial<ChartTableShape>): ChartRecommendation[];
628
+ interface ChartFromTable {
629
+ type: ChartType;
630
+ stacking: ChartStacking;
631
+ categories: string[];
632
+ series: ChartSeries[];
633
+ issues: ChartIssue[];
634
+ shape: ChartTableShape;
635
+ }
636
+ /**
637
+ * Builds chart data from a block of cells (CSV, a clipboard grid or a spreadsheet range) using
638
+ * the spreadsheet conventions of `analyzeChartTable`. `type: 'auto'` (the default) takes the
639
+ * first recommendation. A scatter chart of a block without labels takes the first column as
640
+ * the x values of the others.
641
+ */
642
+ declare function chartFromTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options?: {
643
+ type?: ChartType | 'auto';
644
+ }): ChartFromTable;
645
+
386
646
  interface ChartControllerOptions {
387
647
  /** Starting chart (any partial or saved spec; problems are reported in `state.issues`). */
388
648
  spec?: Partial<ChartSpec> | unknown;
@@ -395,7 +655,7 @@ interface ChartControllerOptions {
395
655
  interface ChartState {
396
656
  spec: Readonly<ChartSpec>;
397
657
  selection: ChartSelection | null;
398
- /** The series the selection belongs to (a series or one of its points). */
658
+ /** The series the selection belongs to (a series, one of its points or one of its trendlines). */
399
659
  selectedSeries: ChartSeries | null;
400
660
  /** The category the selection belongs to (a category or a point). */
401
661
  selectedIndex: number | null;
@@ -418,9 +678,10 @@ type ChartActionResult = {
418
678
  issues?: ChartIssue[];
419
679
  };
420
680
  /** Top-level fields with partial axes and legend. */
421
- type ChartSpecPatch = Partial<Omit<ChartSpec, 'version' | 'xAxis' | 'yAxis' | 'legend'>> & {
681
+ type ChartSpecPatch = Partial<Omit<ChartSpec, 'version' | 'xAxis' | 'yAxis' | 'yAxis2' | 'legend'>> & {
422
682
  xAxis?: Partial<ChartAxis>;
423
683
  yAxis?: Partial<ChartAxis>;
684
+ yAxis2?: Partial<ChartAxis>;
424
685
  legend?: Partial<ChartLegend>;
425
686
  };
426
687
  interface ChartSeriesInput {
@@ -430,7 +691,17 @@ interface ChartSeriesInput {
430
691
  color?: string;
431
692
  type?: ChartSeriesType;
432
693
  hidden?: boolean;
694
+ axis?: 'primary' | 'secondary';
695
+ x?: readonly unknown[];
696
+ sizes?: readonly unknown[];
697
+ pointColors?: readonly (string | null)[];
698
+ marker?: ChartMarker;
699
+ curve?: ChartCurve;
700
+ dataLabels?: boolean;
701
+ format?: ChartNumberFormat;
702
+ trendlines?: readonly ChartTrendline[];
433
703
  }
704
+ /** Changes to one series; `null` resets a field to the chart's default. */
434
705
  interface ChartSeriesPatch {
435
706
  name?: string;
436
707
  /** `null` goes back to the palette colour. */
@@ -438,6 +709,14 @@ interface ChartSeriesPatch {
438
709
  /** `null` follows the chart type. */
439
710
  type?: ChartSeriesType | null;
440
711
  hidden?: boolean;
712
+ axis?: 'primary' | 'secondary' | null;
713
+ x?: readonly unknown[] | null;
714
+ sizes?: readonly unknown[] | null;
715
+ pointColors?: readonly (string | null)[] | null;
716
+ marker?: ChartMarker | null;
717
+ curve?: ChartCurve | null;
718
+ dataLabels?: boolean | null;
719
+ format?: ChartNumberFormat | null;
441
720
  }
442
721
  interface ChartEditOptions {
443
722
  /** Undo step label. */
@@ -492,8 +771,16 @@ declare class ChartController {
492
771
  setType(type: ChartType): ChartActionResult;
493
772
  setTitle(title: string): ChartActionResult;
494
773
  setSubtitle(subtitle: string): ChartActionResult;
495
- /** Changes the category (`x`) or value (`y`) axis. */
496
- setAxis(axis: 'x' | 'y', patch: Partial<ChartAxis>): ChartActionResult;
774
+ /** Changes the category (`x`), value (`y`) or secondary value (`y2`) axis. */
775
+ setAxis(axis: 'x' | 'y' | 'y2', patch: Partial<ChartAxis>): ChartActionResult;
776
+ /**
777
+ * Applies a named quick layout and / or colour scheme (see `CHART_LAYOUT_PRESETS` and
778
+ * `CHART_COLOR_SCHEMES`) as one undo step.
779
+ */
780
+ applyPreset(options: {
781
+ layout?: string;
782
+ colors?: string;
783
+ }): ChartActionResult;
497
784
  setLegend(patch: Partial<ChartLegend>): ChartActionResult;
498
785
  /**
499
786
  * Replaces categories and / or series as one undo step. Values are validated and padded
@@ -561,6 +848,30 @@ declare class ChartController {
561
848
  }): ChartActionResult & {
562
849
  issues?: ChartIssue[];
563
850
  };
851
+ /** Adds a trendline to a series and selects it. Returns its index (and the fit, when it can be computed). */
852
+ addTrendline(seriesId: string, input: ChartTrendline): {
853
+ ok: true;
854
+ index: number;
855
+ fit: ChartTrendFit | null;
856
+ } | {
857
+ ok: false;
858
+ message: string;
859
+ issues?: ChartIssue[];
860
+ };
861
+ /** Changes a trendline (all-or-nothing). */
862
+ updateTrendline(seriesId: string, index: number, patch: Partial<ChartTrendline>): ChartActionResult;
863
+ removeTrendline(seriesId: string, index: number): ChartActionResult;
864
+ /** The points a series' trendlines are fitted to: (x, y) with x = 1, 2, 3 … on category charts. */
865
+ trendlinePoints(seriesId: string): [number, number][];
866
+ /** The fitted coefficients, R² and equation of a trendline (null for moving averages or unfittable data). */
867
+ trendlineFit(seriesId: string, index: number): ChartTrendFit | null;
868
+ /** The moving-average points of a trendline (empty for other kinds). */
869
+ trendlineMovingAverage(seriesId: string, index: number): [number, number][];
870
+ /**
871
+ * Switches rows and columns: series become categories and categories become series (one
872
+ * undo step). Series colours, types and other per-series settings are dropped.
873
+ */
874
+ transpose(): ChartActionResult;
564
875
  /** Selects a chart element (view state; not an undo step). */
565
876
  select(selection: ChartSelection | null): void;
566
877
  /**
@@ -572,6 +883,11 @@ declare class ChartController {
572
883
  nudgeValue(seriesId: string, index: number, delta: number): ChartActionResult;
573
884
  /** Starts a continuous edit (a drag): every change until `endGesture()` is one undo step. */
574
885
  beginGesture(key: string): void;
886
+ /**
887
+ * Cancels the gesture in progress (Escape during a drag): everything it changed is taken
888
+ * back and leaves no undo or redo step.
889
+ */
890
+ cancelGesture(): void;
575
891
  endGesture(): void;
576
892
  /** The spec, for saving (a copy). */
577
893
  toJSON(): ChartSpec;
@@ -599,9 +915,12 @@ interface ChartCommandOptions {
599
915
  }
600
916
  /**
601
917
  * Palette and agent commands for a chart: describe, update presentation, replace data, set
602
- * values, add / remove series and categories, import CSV and export SVG. Register them in a
603
- * `CommandRegistry` and agents get them through `createCommandToolProvider`. Failures throw
604
- * sentences, which the registry returns as `{ ok: false, code: 'failed', message }`.
918
+ * values, add / remove series, categories and trendlines, apply presets, switch rows and
919
+ * columns, import CSV or Mermaid, export SVG, Mermaid or Office XML, recommend types and
920
+ * check colours. Register them in a `CommandRegistry` and agents get them through
921
+ * `createCommandToolProvider`; `createChartToolProvider` offers the same operations as
922
+ * individual tools. Failures throw sentences, which the registry returns as
923
+ * `{ ok: false, code: 'failed', message }`.
605
924
  */
606
925
  declare function createChartCommands(controller: ChartController, options?: ChartCommandOptions): CommandSpec[];
607
926
 
@@ -615,10 +934,22 @@ declare function chartClientToScene(scene: Pick<ChartScene, 'width' | 'height'>,
615
934
  x: number;
616
935
  y: number;
617
936
  };
618
- /** Whether a point can be dragged to a new value in this scene (cartesian, not percent-stacked, not hidden). */
937
+ /**
938
+ * Whether a point can be dragged to a new value in this scene: bar, line, area and scatter
939
+ * charts (not percent-stacked), scatter and bubble charts with x values (x and y), and
940
+ * waterfall steps. Hidden series and gaps cannot be dragged.
941
+ */
619
942
  declare function canDragChartPoint(controller: ChartController, scene: ChartScene, target: ChartSelection | undefined): target is Extract<ChartSelection, {
620
943
  kind: 'point';
621
944
  }>;
945
+ interface ChartDragMoveOptions {
946
+ /** Move a tenth as far as the pointer (fine adjustment; Alt). */
947
+ fine?: boolean;
948
+ /** Only change the axis the pointer has moved along most (scatter charts; Shift). */
949
+ lockAxis?: boolean;
950
+ /** Skip snapping to nearby values and ticks (e.g. while Ctrl / Cmd is held). */
951
+ noSnap?: boolean;
952
+ }
622
953
  interface ChartPointDrag {
623
954
  /**
624
955
  * The value axis range when the drag started. Pass it to `layoutChart` (`valueDomain`)
@@ -628,25 +959,60 @@ interface ChartPointDrag {
628
959
  min: number;
629
960
  max: number;
630
961
  };
962
+ /** The secondary value axis range when the drag started (`layoutChart`'s `valueDomain2`). */
963
+ readonly valueDomain2?: {
964
+ min: number;
965
+ max: number;
966
+ };
967
+ /** The numeric x range of a scatter or bubble chart when the drag started (`xDomain`). */
968
+ readonly xDomain?: {
969
+ min: number;
970
+ max: number;
971
+ };
972
+ /** The point being dragged, for `layoutChart`'s `readout`. */
973
+ readonly target: {
974
+ seriesId: string;
975
+ index: number;
976
+ };
631
977
  /** Moves the value with the pointer (scene coordinates). */
632
978
  move(point: {
633
979
  x: number;
634
980
  y: number;
635
- }): void;
981
+ }, options?: ChartDragMoveOptions): void;
636
982
  /** Ends the drag (one undo step for the whole drag). */
637
983
  end(): void;
984
+ /** Cancels the drag: the value goes back and no undo step is left (Escape). */
985
+ cancel(): void;
638
986
  }
987
+ interface ChartSnapOptions {
988
+ /** Values to snap to when the pointer is within `tolerancePx` of them. */
989
+ candidates?: readonly number[];
990
+ /** Screen distance that snaps (default 6). */
991
+ tolerancePx?: number;
992
+ /** Fallback step when no candidate is close (default: a tenth of the tick step). */
993
+ step?: number;
994
+ /** The scale the value is on (default: the scene's value scale). */
995
+ scale?: ChartValueScale;
996
+ }
997
+ /**
998
+ * Snaps a dragged value: to the nearest candidate (other series at the same category, the
999
+ * neighbouring values, zero, the start value, ticks) within `tolerancePx` screen pixels, or
1000
+ * else to a tenth of the tick step.
1001
+ */
1002
+ declare function snapChartDragValue(scene: ChartScene, value: number, options?: ChartSnapOptions): number;
639
1003
  /**
640
- * Starts dragging a bar or point: the value follows the pointer along the value axis,
641
- * snapped to a tenth of the tick step (`step` overrides), and the whole drag is one undo
642
- * step. Works for stacked bars too (the drag changes the segment by the distance moved).
643
- * Returns `null` when the target cannot be dragged.
1004
+ * Starts dragging a bar or point: the value follows the pointer along its value axis (and
1005
+ * along x on scatter and bubble charts), snapped to nearby values and then to a tenth of the
1006
+ * tick step (`step` overrides), and the whole drag is one undo step. Works for stacked bars
1007
+ * too (the drag changes the segment by the distance moved). Returns `null` when the target
1008
+ * cannot be dragged.
644
1009
  */
645
1010
  declare function startChartPointDrag(controller: ChartController, scene: ChartScene, target: ChartSelection | undefined, start: {
646
1011
  x: number;
647
1012
  y: number;
648
1013
  }, options?: {
649
1014
  step?: number;
1015
+ tolerancePx?: number;
650
1016
  }): ChartPointDrag | null;
651
1017
  interface ChartKeyInput {
652
1018
  key: string;
@@ -657,12 +1023,348 @@ interface ChartKeyInput {
657
1023
  }
658
1024
  /**
659
1025
  * Keyboard editing on a focused chart: arrows move a point selection between categories
660
- * (← →) and change its value (↑ ↓, a tenth of the tick step; Shift: a whole step), Delete /
661
- * Backspace deletes the selection, Escape clears it. Returns `true` when the key was used
662
- * (call `preventDefault`).
1026
+ * (← →) and change its value (↑ ↓, a tenth of the tick step; Shift: a whole step; Alt: a
1027
+ * hundredth), Delete / Backspace deletes the selection, Escape cancels a drag or clears the
1028
+ * selection. Returns `true` when the key was used (call `preventDefault`).
663
1029
  */
664
1030
  declare function handleChartKey(controller: ChartController, scene: ChartScene | null, event: ChartKeyInput): boolean;
665
1031
  /** A short description of the selection for an inspector heading or a screen reader. */
666
1032
  declare function describeChartSelection(controller: ChartController, selection?: ChartSelection | null): string;
1033
+ /**
1034
+ * The mark under a scene point (topmost first), for hosts without DOM events and for agents
1035
+ * that drive the pointer: rects, circles, lines (within 4 px) and text boxes. Returns the
1036
+ * mark's `target`, or `{ kind: 'chart' }` over the background, or `null` outside.
1037
+ */
1038
+ declare function chartHitTest(scene: ChartScene, point: {
1039
+ x: number;
1040
+ y: number;
1041
+ }, measure?: (text: string, size: number, weight?: number) => number): ChartSelection | null;
1042
+
1043
+ /** The comment line that carries what Mermaid cannot express. Every Mermaid tool ignores `%%` comments. */
1044
+ declare const CHART_MERMAID_META_PREFIX = "%% @pixerate ";
1045
+ type ChartMermaidFamily = 'xychart' | 'pie' | 'radar';
1046
+ interface ChartMermaidOptions {
1047
+ /** Write the `%% @pixerate {…}` line so the chart round-trips exactly (default `true`). */
1048
+ meta?: boolean;
1049
+ /** Indentation of statements (default four spaces). */
1050
+ indent?: string;
1051
+ }
1052
+ /** The Mermaid family a chart is written as. */
1053
+ declare function chartMermaidFamily(spec: Pick<ChartSpec, 'type' | 'series'>): ChartMermaidFamily;
1054
+ /**
1055
+ * Writes a chart as Mermaid: `xychart-beta` for bar, line, area and scatter charts (areas and
1056
+ * scatters drawn as lines), `pie` for pies, donuts, funnels and treemaps, `radar-beta` for
1057
+ * radars. Anything Mermaid cannot hold (stacking, colours, formats, gaps, trendlines, other
1058
+ * chart types) goes into one `%% @pixerate {…}` comment so `chartFromMermaid` gets the chart
1059
+ * back exactly, while any Mermaid renderer still draws the basic chart.
1060
+ */
1061
+ declare function chartToMermaid(spec: ChartSpec, options?: ChartMermaidOptions): string;
1062
+ interface ChartMermaidParseOptions {
1063
+ /** Accept a statement that is still being written (an unclosed `[` list): for streaming views. */
1064
+ partial?: boolean;
1065
+ /** Ignore the `%% @pixerate` line (what the Mermaid text alone says). */
1066
+ ignoreMeta?: boolean;
1067
+ }
1068
+ interface ChartMermaidResult {
1069
+ spec: ChartSpec;
1070
+ /** Problems, with 1-based `line` numbers. Lines that could not be read are listed and skipped. */
1071
+ issues: ChartIssue[];
1072
+ family: ChartMermaidFamily | null;
1073
+ /** The `%% @pixerate` line was found and applied. */
1074
+ hasMeta: boolean;
1075
+ }
1076
+ /**
1077
+ * Reads Mermaid `xychart-beta`, `pie` or `radar-beta` text as a chart. Never throws: lines it
1078
+ * cannot read are reported with their line numbers and skipped, and the result always draws.
1079
+ * A `%% @pixerate {…}` line written by `chartToMermaid` restores everything Mermaid cannot hold.
1080
+ */
1081
+ declare function chartFromMermaid(text: string, options?: ChartMermaidParseOptions): ChartMermaidResult;
1082
+ interface FoundChartMermaid {
1083
+ source: string;
1084
+ family: ChartMermaidFamily;
1085
+ /** 1-based line where the block starts in the input. */
1086
+ line: number;
1087
+ }
1088
+ /**
1089
+ * Finds Mermaid charts in Markdown or chat text: fenced ```mermaid blocks (and unlabelled
1090
+ * fences) whose header is xychart-beta, pie or radar-beta, else the whole text when it is one.
1091
+ */
1092
+ declare function findMermaidCharts(text: string): FoundChartMermaid[];
1093
+
1094
+ declare const CHART_OOXML_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
1095
+ declare const CHART_OOXML_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
1096
+ declare const CHART_OOXML_RELATIONSHIP = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
1097
+ type ParserCtor$1 = {
1098
+ new (): DOMParser;
1099
+ };
1100
+ interface ChartOoxmlReadOptions {
1101
+ /** `DOMParser` constructor (default: the global one; pass jsdom's or xmldom's in Node). */
1102
+ DOMParser?: ParserCtor$1;
1103
+ }
1104
+ interface ChartOoxmlReadResult {
1105
+ spec: ChartSpec;
1106
+ /** Problems and simplifications, as sentences. */
1107
+ issues: ChartIssue[];
1108
+ /** Features the file uses that the spec cannot hold (3-D, stock, surface, gradients, …). */
1109
+ unsupported: string[];
1110
+ /**
1111
+ * Nothing was dropped: writing `spec` back gives an equivalent chart. When false, keep the
1112
+ * original part (or show the chart read-only) if the file must stay as it was.
1113
+ */
1114
+ lossless: boolean;
1115
+ }
1116
+ /**
1117
+ * Reads a DrawingML chart part (`c:chartSpace`, e.g. `word/charts/chart1.xml`) or an Office
1118
+ * 2016 chartex part (`cx:chartSpace`: waterfall, funnel, treemap, histogram, box & whisker)
1119
+ * as a chart spec. Data comes from the cached values. Never throws for a malformed chart: it
1120
+ * returns an empty chart and says why.
1121
+ */
1122
+ declare function chartFromOoxml(xml: string, options?: ChartOoxmlReadOptions): ChartOoxmlReadResult;
1123
+ /** A spreadsheet format code equivalent to a chart number format (`General` when there is none). */
1124
+ declare function chartFormatToCode(format: ChartNumberFormat): string;
1125
+ interface ChartOoxmlWriteResult {
1126
+ /** The `c:chartSpace` part. */
1127
+ xml: string;
1128
+ /** What could not be written as DrawingML, as sentences (empty when nothing was lost). */
1129
+ issues: string[];
1130
+ }
1131
+ /**
1132
+ * Writes a chart as a DrawingML chart part (`c:chartSpace`) with the data as literals (no
1133
+ * embedded workbook), for `word/charts/chartN.xml` or `ppt/charts/chartN.xml`. Waterfall,
1134
+ * histogram, box, funnel and treemap charts need Office 2016 chartex parts; they are written
1135
+ * as the closest classic chart and reported in `issues`.
1136
+ */
1137
+ declare function chartToOoxml(spec: ChartSpec): ChartOoxmlWriteResult;
1138
+
1139
+ interface ChartPresenceActor {
1140
+ id: string;
1141
+ name: string;
1142
+ color: string;
1143
+ /** Cursor position in scene coordinates. */
1144
+ x: number;
1145
+ y: number;
1146
+ /** The button is down (dragging). */
1147
+ pressed: boolean;
1148
+ /** A short note shown next to the cursor (what the agent is doing). */
1149
+ message?: string;
1150
+ }
1151
+ interface ChartPresenceState {
1152
+ actors: readonly ChartPresenceActor[];
1153
+ }
1154
+ /** Cursor positions and notes of agents acting on a chart, for an overlay. */
1155
+ declare class ChartPresence {
1156
+ private state;
1157
+ private readonly listeners;
1158
+ getState: () => ChartPresenceState;
1159
+ subscribe: (listener: (state: ChartPresenceState) => void) => (() => void);
1160
+ /** Adds or changes an actor. */
1161
+ set(actor: Pick<ChartPresenceActor, 'id'> & Partial<ChartPresenceActor>): void;
1162
+ remove(id: string): void;
1163
+ }
1164
+ declare const CHART_PRESENCE_COLORS: readonly string[];
1165
+ /** Time for performances: real timers, or an instant clock for tests and recordings. */
1166
+ interface ChartClock {
1167
+ now(): number;
1168
+ wait(ms: number): Promise<void>;
1169
+ }
1170
+ declare const realChartClock: ChartClock;
1171
+ /** A clock whose waits finish at once while its time still advances (repeatable performances). */
1172
+ declare function createInstantChartClock(start?: number): ChartClock & {
1173
+ elapsed(): number;
1174
+ };
1175
+ /** What an agent asks for. Each command commits as one undo step. */
1176
+ type ChartAgentCommand = {
1177
+ kind: 'setValue';
1178
+ seriesId: string;
1179
+ index: number;
1180
+ value: number;
1181
+ note?: string;
1182
+ } | {
1183
+ kind: 'select';
1184
+ selection: ChartSelection | null;
1185
+ note?: string;
1186
+ } | {
1187
+ kind: 'update';
1188
+ patch: ChartSpecPatch;
1189
+ label?: string;
1190
+ note?: string;
1191
+ } | {
1192
+ kind: 'say';
1193
+ text: string;
1194
+ };
1195
+ type ChartPerformanceStep = {
1196
+ type: 'move';
1197
+ to: {
1198
+ x: number;
1199
+ y: number;
1200
+ };
1201
+ ms: number;
1202
+ } | {
1203
+ type: 'say';
1204
+ text: string;
1205
+ ms: number;
1206
+ } | {
1207
+ type: 'press';
1208
+ } | {
1209
+ type: 'drag';
1210
+ to: {
1211
+ x: number;
1212
+ y: number;
1213
+ };
1214
+ ms: number;
1215
+ from: number;
1216
+ value: number;
1217
+ } | {
1218
+ type: 'release';
1219
+ } | {
1220
+ type: 'commit';
1221
+ };
1222
+ /** Where a point or bar sits in the scene (its top for bars), or null when it is not drawn. */
1223
+ declare function chartPointAnchor(scene: ChartScene, seriesId: string, index: number): {
1224
+ x: number;
1225
+ y: number;
1226
+ } | null;
1227
+ /**
1228
+ * Plans how an agent acts out a command on the chart: cursor moves, a drag along the value
1229
+ * axis for a value change (its end at the new value), a note, then a commit. Pure: the same
1230
+ * scene and command give the same steps.
1231
+ */
1232
+ declare function planChartCommand(spec: ChartSpec, scene: ChartScene, command: ChartAgentCommand, speed?: number): ChartPerformanceStep[];
1233
+ interface ChartDirectorOptions {
1234
+ /** The scene as currently drawn (for cursor targets), e.g. the canvas' last layout. */
1235
+ scene: () => ChartScene;
1236
+ clock?: ChartClock;
1237
+ /** 1 = natural speed; 2 = twice as fast. */
1238
+ speed?: number;
1239
+ /** Hide each actor's cursor this long after its last command (ms, default 1500; 0 keeps it). */
1240
+ linger?: number;
1241
+ }
1242
+ interface ChartDirectorActor {
1243
+ id: string;
1244
+ name?: string;
1245
+ color?: string;
1246
+ }
1247
+ type ChartPerformanceResult = {
1248
+ ok: true;
1249
+ command: ChartAgentCommand;
1250
+ } | {
1251
+ ok: false;
1252
+ command: ChartAgentCommand;
1253
+ message: string;
1254
+ };
1255
+ /**
1256
+ * Acts out agent commands on a chart: each actor's cursor moves to the target, drags values
1257
+ * into place (the chart updates live) and the command commits as one undo step, while the
1258
+ * user keeps editing. Commands queue per actor; a command whose target was deleted meanwhile
1259
+ * fails with a sentence instead of editing something else.
1260
+ */
1261
+ declare class ChartDirector {
1262
+ private readonly controller;
1263
+ readonly presence: ChartPresence;
1264
+ private readonly options;
1265
+ private readonly queues;
1266
+ private readonly clock;
1267
+ private calls;
1268
+ constructor(controller: ChartController, presence: ChartPresence, options: ChartDirectorOptions);
1269
+ /** Acts out `commands` in order for `actor`. Resolves with one result per command. */
1270
+ perform(actor: ChartDirectorActor, commands: readonly ChartAgentCommand[]): Promise<ChartPerformanceResult[]>;
1271
+ private stale;
1272
+ private move;
1273
+ private performOne;
1274
+ }
1275
+
1276
+ type ParserCtor = {
1277
+ new (): DOMParser;
1278
+ };
1279
+ interface ChartToolProviderOptions {
1280
+ /** Provider id (unique per registry). Default `chart`. */
1281
+ id?: string;
1282
+ /** Always prefix tool names with `<namespace>__`. */
1283
+ namespace?: string;
1284
+ /**
1285
+ * The chart cannot be edited: write tools are hidden and `get_chart` says why. A string
1286
+ * is the reason ("The report is locked").
1287
+ */
1288
+ readOnly?: boolean | string | (() => boolean | string);
1289
+ /** Size used for summaries, previews and pointer gestures (default 640 × 400). */
1290
+ size?: {
1291
+ width: number;
1292
+ height: number;
1293
+ };
1294
+ /** Enables `import_chart_ooxml` (reading Office chart XML needs a DOMParser). Default: the global one, if any. */
1295
+ DOMParser?: ParserCtor;
1296
+ /**
1297
+ * Acts out `set_chart_values` and `select_chart_element` with a visible cursor (see
1298
+ * `ChartDirector`); each call is still one undo step. Without it, edits apply at once.
1299
+ */
1300
+ director?: ChartDirector;
1301
+ /** Who the cursor belongs to (default `{ id: 'agent', name: 'Agent' }`). */
1302
+ actor?: ChartDirectorActor;
1303
+ /** Turns SVG into an image so `render_chart` can return PNG (e.g. through a canvas). */
1304
+ rasterize?: (svg: string, size: {
1305
+ width: number;
1306
+ height: number;
1307
+ }) => Promise<{
1308
+ data: string;
1309
+ mimeType: string;
1310
+ }> | {
1311
+ data: string;
1312
+ mimeType: string;
1313
+ };
1314
+ }
1315
+ /**
1316
+ * Agent tools for a chart editor, for a `ToolRegistry`: one tool per operation with strict
1317
+ * schemas. Reads (`get_chart`, `render_chart`, `check_chart_colors`, `recommend_chart`,
1318
+ * `get_chart_trendline`, `list_chart_presets`, `export_chart_mermaid`, `export_chart_ooxml`)
1319
+ * are always there; writes (data, series, categories, presentation, trendlines, presets,
1320
+ * imports, selection, pointer and key input, undo / redo) are hidden while the chart is
1321
+ * read-only. Every write is one undo step and returns what it changed.
1322
+ */
1323
+ declare function createChartToolProvider(controller: ChartController, options?: ChartToolProviderOptions): AgentToolProvider;
1324
+
1325
+ /**
1326
+ * Reads JSON that is still arriving: closes open strings, arrays and objects and drops a
1327
+ * dangling key or comma, so `{"type":"bar","series":[{"name":"A","values":[1,2` reads as far
1328
+ * as it goes. Returns `undefined` when nothing usable has arrived yet.
1329
+ */
1330
+ declare function parsePartialChartJson(text: string): unknown;
1331
+ type ChartStreamFormat = 'auto' | 'mermaid' | 'json';
1332
+ interface ChartStreamResult {
1333
+ /** The chart as far as it has arrived, or `null` before anything can be drawn. */
1334
+ spec: ChartSpec | null;
1335
+ issues: ChartIssue[];
1336
+ /**
1337
+ * The value range to lay out with while incomplete: it only grows, so the axis does not
1338
+ * jump as values arrive. `null` once complete (the chart's own scale takes over).
1339
+ */
1340
+ valueDomain: {
1341
+ min: number;
1342
+ max: number;
1343
+ } | null;
1344
+ }
1345
+ /**
1346
+ * Turns a chart source that is still being written (Mermaid or a JSON spec, e.g. streamed
1347
+ * from a model) into drawable specs. Series appear once their values start, axis bounds only
1348
+ * grow until `complete`, and parse problems are reported only once the source is complete.
1349
+ */
1350
+ declare class ChartStream {
1351
+ private readonly format;
1352
+ private lo;
1353
+ private hi;
1354
+ private last;
1355
+ constructor(format?: ChartStreamFormat);
1356
+ /** Reads the source so far. `complete` when nothing more will arrive. */
1357
+ update(source: string, complete?: boolean): ChartStreamResult;
1358
+ /** Forgets the axis bounds (a new source). */
1359
+ reset(): void;
1360
+ }
1361
+ /**
1362
+ * A scene between two scenes, for animating changes (streamed data arriving, an agent's
1363
+ * edit): marks are matched by `key`; numbers and same-shaped paths move from `from` to `to`;
1364
+ * new marks fade in and marks that are gone are dropped. `t` runs from 0 to 1.
1365
+ */
1366
+ declare function blendChartScenes(from: ChartScene | null, to: ChartScene, t: number): ChartScene;
1367
+ /** Ease-out cubic, for tweens. */
1368
+ declare const easeChartTween: (t: number) => number;
667
1369
 
668
- export { CHART_CURVES, CHART_LEGEND_POSITIONS, CHART_NUMBER_STYLES, CHART_ORIENTATIONS, CHART_SERIES_TYPES, CHART_STACKINGS, CHART_TYPES, CHART_TYPE_LABELS, CSS_VARIABLE_CHART_THEME, type ChartActionResult, type ChartAxis, type ChartCircleMark, type ChartCommandOptions, ChartController, type ChartControllerOptions, type ChartCurve, type ChartEditOptions, type ChartIssue, type ChartKeyInput, type ChartLayoutOptions, type ChartLegend, type ChartLegendPosition, type ChartLineMark, type ChartMark, type ChartMarkRole, type ChartNumberFormat, type ChartOrientation, type ChartPathMark, type ChartPointDrag, type ChartRect, type ChartRectMark, type ChartScene, type ChartSelection, type ChartSeries, type ChartSeriesInput, type ChartSeriesPatch, type ChartSeriesType, type ChartSpec, type ChartSpecPatch, type ChartStacking, type ChartState, type ChartSvgOptions, type ChartTableData, type ChartTableOptions, type ChartTextMark, type ChartTextMeasure, type ChartTheme, type ChartType, type ChartValue, type ChartValueScale, DEFAULT_CHART_PALETTE, DEFAULT_CHART_THEME, type NiceScale, canDragChartPoint, chartClientToScene, chartColorInputValue, chartDataFromTable, chartDataToTable, chartSceneToSvg, chartSeriesColor, chartSeriesType, chartSliceColor, chartTextBaseline, chartTextTransform, chartToSvg, chartValueAtPoint, cloneChartSeries, cloneChartSpec, contrastingTextColor, createChartCommands, createChartController, createChartSpec, defaultChartAxis, describeChartSelection, estimateChartTextWidth, formatChartNumber, handleChartKey, isCartesianChart, layoutChart, linearMap, niceScale, niceStep, normalizeChartAxis, normalizeChartSpec, normalizeChartValues, parseChartValue, sameChartSelection, snapChartValue, startChartPointDrag, stepDecimals, uniqueChartSeriesId };
1370
+ export { CHART_AXIS_KINDS, CHART_COLOR_SCHEMES, CHART_CURVES, CHART_DATE_STEPS, CHART_LABEL_POSITIONS, CHART_LAYOUT_PRESETS, CHART_LEGEND_POSITIONS, CHART_MARKERS, CHART_MERMAID_META_PREFIX, CHART_NUMBER_STYLES, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_ORIENTATIONS, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, CHART_SERIES_TYPES, CHART_STACKINGS, CHART_TRENDLINE_TYPES, CHART_TYPES, CHART_TYPE_LABELS, CSS_VARIABLE_CHART_THEME, type ChartActionResult, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartControllerOptions, ChartCurve, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartEditOptions, type ChartFamily, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLabelPosition, type ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, ChartLegendPosition, ChartMarker, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, ChartOrientation, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesInput, type ChartSeriesPatch, type ChartSeriesSummary, ChartSeriesType, type ChartSnapOptions, type ChartSparklineKind, type ChartSparklineOptions, ChartSpec, type ChartSpecPatch, ChartStacking, type ChartState, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartSvgOptions, type ChartTableData, type ChartTableOptions, type ChartTableShape, ChartTextMark, type ChartTextMeasure, ChartTheme, type ChartToolProviderOptions, type ChartTrendFit, ChartTrendline, ChartTrendlineType, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, DEFAULT_CHART_PALETTE, DEFAULT_CHART_THEME, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartColorInputValue, chartColorsByCategory, chartContrastRatio, chartDataFromTable, chartDataToTable, chartDateLabels, chartDateToSerial, chartFamily, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartMovingAverage, chartPointAnchor, chartPointColor, chartPresetPatch, chartQuantile, chartRgbToHex, chartRgbToOklab, chartSceneToSvg, chartSerialToDate, chartSeriesColor, chartSeriesType, chartSliceColor, chartSquarify, chartSupportsTrendlines, chartTextBaseline, chartTextOn, chartTextTransform, chartToMermaid, chartToOoxml, chartToSvg, chartTrendlineName, chartValueAtPoint, chartXAtPoint, checkChartColors, cloneChartSeries, cloneChartSpec, compileChartFormatCode, contrastingTextColor, createChartCommands, createChartController, createChartSpec, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, defaultChartAxis, describeChart, describeChartSelection, easeChartTween, estimateChartTextWidth, findMermaidCharts, fitChartTrendline, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, isCartesianChart, isXyChart, layoutChart, layoutSparkline, linearMap, monochromeChartPalette, niceScale, niceStep, normalizeChartAxis, normalizeChartSpec, normalizeChartTrendline, normalizeChartValues, parseChartColor, parseChartDate, parseChartValue, parsePartialChartJson, planChartCommand, realChartClock, recommendChartTypes, recommendForShape, sameChartSelection, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, sparklineToSvg, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries, trendNumberText, uniqueChartSeriesId };