@pixerate/editor 0.47.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.cjs +246 -29
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +18 -6
- package/dist/agent/index.d.ts +18 -6
- package/dist/agent/index.js +226 -9
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-xs7rK6ys.d.cts → builtins-1kqwLUnb.d.cts} +1 -1
- package/dist/{builtins-D2nMtw2W.d.ts → builtins-BKYlHH1s.d.ts} +1 -1
- package/dist/chart/index.cjs +214 -3541
- package/dist/chart/index.cjs.map +1 -1
- package/dist/chart/index.d.cts +4 -494
- package/dist/chart/index.d.ts +4 -494
- package/dist/chart/index.js +135 -3462
- package/dist/chart/index.js.map +1 -1
- package/dist/{chunk-5VXI5GED.js → chunk-2CJ3LPYQ.js} +3 -3
- package/dist/{chunk-ZFBBVGCI.js → chunk-EKYHKQPG.js} +243 -243
- package/dist/{chunk-ZFBBVGCI.js.map → chunk-EKYHKQPG.js.map} +1 -1
- package/dist/chunk-HXUL3LS7.js +113 -0
- package/dist/chunk-HXUL3LS7.js.map +1 -0
- package/dist/{chunk-REAGGLXS.js → chunk-JQ3BB3E6.js} +2 -2
- package/dist/chunk-LTUM52X6.js +4074 -0
- package/dist/chunk-LTUM52X6.js.map +1 -0
- package/dist/{chunk-J3R2OWOE.cjs → chunk-MUCYWI6W.cjs} +608 -15
- package/dist/chunk-MUCYWI6W.cjs.map +1 -0
- package/dist/chunk-PIMCHMZE.cjs +521 -0
- package/dist/chunk-PIMCHMZE.cjs.map +1 -0
- package/dist/{chunk-TK2XZK6Z.js → chunk-PKBWLEL7.js} +594 -1
- package/dist/chunk-PKBWLEL7.js.map +1 -0
- package/dist/chunk-PRSJJZBS.cjs +4074 -0
- package/dist/chunk-PRSJJZBS.cjs.map +1 -0
- package/dist/chunk-U6IZKC7B.cjs +113 -0
- package/dist/chunk-U6IZKC7B.cjs.map +1 -0
- package/dist/{chunk-SQC26VQV.cjs → chunk-UN33YOXW.cjs} +191 -191
- package/dist/{chunk-SQC26VQV.cjs.map → chunk-UN33YOXW.cjs.map} +1 -1
- package/dist/{chunk-PQFAHT5O.js → chunk-VKPEPWKZ.js} +27 -94
- package/dist/chunk-VKPEPWKZ.js.map +1 -0
- package/dist/{chunk-H4PICYNL.cjs → chunk-WXEHCVJQ.cjs} +113 -180
- package/dist/chunk-WXEHCVJQ.cjs.map +1 -0
- package/dist/{chunk-LYGEEDNR.cjs → chunk-XP5IUZUO.cjs} +242 -242
- package/dist/chunk-XP5IUZUO.cjs.map +1 -0
- package/dist/{chunk-C3NWJE3K.js → chunk-XUUD43OV.js} +11 -672
- package/dist/chunk-XUUD43OV.js.map +1 -0
- package/dist/{chunk-BBRK6MOI.cjs → chunk-YU4WQE5M.cjs} +100 -100
- package/dist/{chunk-BBRK6MOI.cjs.map → chunk-YU4WQE5M.cjs.map} +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/controller-ChjCCMLl.d.cts +822 -0
- package/dist/controller-DtbEo3om.d.ts +822 -0
- package/dist/extensions/index.cjs +32 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +4 -2
- package/dist/extensions/index.d.ts +4 -2
- package/dist/extensions/index.js +31 -3
- package/dist/{index-QrqMmZ75.d.cts → index-DoHqT1mq.d.cts} +203 -7
- package/dist/{index-CSUCQYAH.d.ts → index-YLZ0fKqE.d.ts} +203 -7
- package/dist/index.cjs +37 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/spreadsheet/index.cjs +4 -4
- package/dist/spreadsheet/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-C3NWJE3K.js.map +0 -1
- package/dist/chunk-H4PICYNL.cjs.map +0 -1
- package/dist/chunk-J3R2OWOE.cjs.map +0 -1
- package/dist/chunk-LYGEEDNR.cjs.map +0 -1
- package/dist/chunk-NEOO6QJD.cjs +0 -1182
- package/dist/chunk-NEOO6QJD.cjs.map +0 -1
- package/dist/chunk-PQFAHT5O.js.map +0 -1
- package/dist/chunk-TK2XZK6Z.js.map +0 -1
- package/dist/types-BVqWm3d1.d.cts +0 -320
- package/dist/types-BVqWm3d1.d.ts +0 -320
- /package/dist/{chunk-5VXI5GED.js.map → chunk-2CJ3LPYQ.js.map} +0 -0
- /package/dist/{chunk-REAGGLXS.js.map → chunk-JQ3BB3E6.js.map} +0 -0
package/dist/chart/index.d.cts
CHANGED
|
@@ -1,113 +1,11 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { x as
|
|
3
|
-
import { H as HistoryManager } from '../HistoryManager-DeQQMBCj.cjs';
|
|
1
|
+
import { C as ChartNumberFormat, a as ChartValue, b as ChartRect, c as ChartScene, d as ChartSpec, e as ChartLayoutOptions, f as ChartWarning, g as ChartAxis, h as ChartLegend, i as ChartType, j as ChartStacking, k as ChartSeries, l as ChartIssue, m as ChartController, n as ChartValueScale, o as ChartSelection, p as ChartSpecPatch } from '../controller-ChjCCMLl.cjs';
|
|
2
|
+
export { q as CHART_AXIS_KINDS, r as CHART_CURVES, s as CHART_LABEL_POSITIONS, t as CHART_LEGEND_POSITIONS, u as CHART_MARKERS, v as CHART_NUMBER_STYLES, w as CHART_ORIENTATIONS, x as CHART_SERIES_TYPES, y as CHART_STACKINGS, z as CHART_TRENDLINE_TYPES, A as CHART_TYPES, B as CHART_TYPE_LABELS, D as CSS_VARIABLE_CHART_THEME, E as ChartActionResult, F as ChartCircleMark, G as ChartControllerOptions, H as ChartCurve, I as ChartDomSpec, J as ChartEditOptions, K as ChartFamily, L as ChartLabelPosition, M as ChartLegendPosition, N as ChartLineMark, O as ChartMark, P as ChartMarkRole, Q as ChartMarker, R as ChartOrientation, S as ChartPathMark, T as ChartRectMark, U as ChartSeriesInput, V as ChartSeriesPatch, W as ChartSeriesType, X as ChartSparklineKind, Y as ChartSparklineOptions, Z as ChartState, _ as ChartSvgOptions, $ as ChartTableData, a0 as ChartTableOptions, a1 as ChartTextMark, a2 as ChartTextMeasure, a3 as ChartTheme, a4 as ChartTrendFit, a5 as ChartTrendline, a6 as ChartTrendlineType, a7 as DEFAULT_CHART_PALETTE, a8 as DEFAULT_CHART_THEME, a9 as chartColorInputValue, aa as chartColorsByCategory, ab as chartDataFromTable, ac as chartDataToTable, ad as chartFamily, ae as chartMovingAverage, af as chartPointColor, ag as chartSceneToDomSpec, ah as chartSceneToSvg, ai as chartSeriesColor, aj as chartSeriesType, ak as chartSliceColor, al as chartSupportsTrendlines, am as chartTextBaseline, an as chartTextTransform, ao as chartToSvg, ap as chartTrendlineName, aq as cloneChartSeries, ar as cloneChartSpec, as as contrastingTextColor, at as createChartController, au as createChartSpec, av as defaultChartAxis, aw as estimateChartTextWidth, ax as fitChartTrendline, ay as isCartesianChart, az as isXyChart, aA as layoutSparkline, aB as normalizeChartAxis, aC as normalizeChartSpec, aD as normalizeChartTrendline, aE as normalizeChartValues, aF as parseChartValue, aG as sameChartSelection, aH as sparklineToSvg, aI as trendNumberText, aJ as uniqueChartSeriesId } from '../controller-ChjCCMLl.cjs';
|
|
4
3
|
import { C as CommandSpec } from '../registry-CaR7LC6W.cjs';
|
|
5
4
|
import { A as AgentToolProvider } from '../registry-B4l-lYts.cjs';
|
|
5
|
+
import '../HistoryManager-DeQQMBCj.cjs';
|
|
6
6
|
import '../types-DsiXGmjo.cjs';
|
|
7
7
|
import '../schema-Di0CS6Pe.cjs';
|
|
8
8
|
|
|
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']>[];
|
|
14
|
-
declare const CHART_SERIES_TYPES: readonly ChartSeriesType[];
|
|
15
|
-
declare const CHART_STACKINGS: readonly ChartStacking[];
|
|
16
|
-
declare const CHART_CURVES: readonly ChartCurve[];
|
|
17
|
-
declare const CHART_ORIENTATIONS: readonly ChartOrientation[];
|
|
18
|
-
declare const CHART_LEGEND_POSITIONS: readonly ChartLegendPosition[];
|
|
19
|
-
declare const CHART_NUMBER_STYLES: readonly NonNullable<ChartNumberFormat['style']>[];
|
|
20
|
-
/** Labels for pickers, shared by the React and Svelte components. */
|
|
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';
|
|
24
|
-
/** A colour-blind-friendly categorical palette (Okabe–Ito order, tuned for light and dark backgrounds). */
|
|
25
|
-
declare const DEFAULT_CHART_PALETTE: readonly string[];
|
|
26
|
-
declare const DEFAULT_CHART_THEME: ChartTheme;
|
|
27
|
-
/**
|
|
28
|
-
* A theme that reads the page's `--background`, `--foreground`, `--muted-foreground`,
|
|
29
|
-
* `--border` and `--primary` colour variables (full colours, as the other components'
|
|
30
|
-
* inline styles use them), with light fallbacks. The React and Svelte canvases use it.
|
|
31
|
-
*/
|
|
32
|
-
declare const CSS_VARIABLE_CHART_THEME: ChartTheme;
|
|
33
|
-
/** Bar, line, area and scatter: categories (or numeric x) against values, series may mix. */
|
|
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;
|
|
41
|
-
declare function defaultChartAxis(value: boolean): ChartAxis;
|
|
42
|
-
/** A complete spec with every default filled in. */
|
|
43
|
-
declare function createChartSpec(partial?: Partial<ChartSpec>): ChartSpec;
|
|
44
|
-
/** The colour a series is drawn with. */
|
|
45
|
-
declare function chartSeriesColor(spec: Pick<ChartSpec, 'palette' | 'series'>, seriesIndex: number): string;
|
|
46
|
-
/** The colour a pie slice is drawn with (by category). */
|
|
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;
|
|
50
|
-
/** How a series is drawn in a cartesian chart. */
|
|
51
|
-
declare function chartSeriesType(spec: Pick<ChartSpec, 'type'>, series: ChartSeries): ChartSeriesType;
|
|
52
|
-
/** An id not used by any series (`series-1`, `series-2`, …). */
|
|
53
|
-
declare function uniqueChartSeriesId(series: readonly Pick<ChartSeries, 'id'>[], base?: string): string;
|
|
54
|
-
/**
|
|
55
|
-
* Reads a number the way people type it in a data grid: `1,234.5`, `12%` (→ 0.12),
|
|
56
|
-
* `$40`, `(3)` (→ -3). Blank → `null`. Returns `undefined` when it is not a number.
|
|
57
|
-
*/
|
|
58
|
-
declare function parseChartValue(input: unknown): ChartValue | undefined;
|
|
59
|
-
declare function normalizeChartAxis(value: unknown, fallback: ChartAxis, path: string, issues?: ChartIssue[]): ChartAxis;
|
|
60
|
-
/** Values as numbers or nulls; bad entries become null and are reported. */
|
|
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;
|
|
64
|
-
/**
|
|
65
|
-
* Turns any input (a partial spec, saved JSON, an agent's arguments) into a complete,
|
|
66
|
-
* valid `ChartSpec`. Every value is checked; problems are reported as sentences in
|
|
67
|
-
* `issues` and replaced by defaults, so the result is always drawable. Series values are
|
|
68
|
-
* padded or trimmed to the number of categories.
|
|
69
|
-
*/
|
|
70
|
-
declare function normalizeChartSpec(input: unknown): {
|
|
71
|
-
spec: ChartSpec;
|
|
72
|
-
issues: ChartIssue[];
|
|
73
|
-
};
|
|
74
|
-
/** A deep copy (specs are plain JSON). */
|
|
75
|
-
declare function cloneChartSpec(spec: ChartSpec): ChartSpec;
|
|
76
|
-
declare function cloneChartSeries(series: ChartSeries): ChartSeries;
|
|
77
|
-
interface ChartTableOptions {
|
|
78
|
-
/**
|
|
79
|
-
* `columns` (default): the first column holds categories and each other column is a
|
|
80
|
-
* series. `rows`: the first row holds categories and each other row is a series.
|
|
81
|
-
*/
|
|
82
|
-
seriesIn?: 'columns' | 'rows';
|
|
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;
|
|
93
|
-
}
|
|
94
|
-
interface ChartTableData {
|
|
95
|
-
categories: string[];
|
|
96
|
-
series: ChartSeries[];
|
|
97
|
-
issues: ChartIssue[];
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Reads a grid of cells (from CSV, a spreadsheet range or the clipboard) as categories and
|
|
101
|
-
* series. Cells that are not numbers become gaps and are reported.
|
|
102
|
-
*/
|
|
103
|
-
declare function chartDataFromTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options?: ChartTableOptions): ChartTableData;
|
|
104
|
-
/** The chart's data as a grid: a header row of series names, then one row per category. */
|
|
105
|
-
declare function chartDataToTable(spec: Pick<ChartSpec, 'categories' | 'series'>, options?: {
|
|
106
|
-
categoryHeader?: string;
|
|
107
|
-
}): (string | number | null)[][];
|
|
108
|
-
/** A colour input value (`#rrggbb`) for a CSS colour: `#abc` expands, non-hex colours show as black. */
|
|
109
|
-
declare function chartColorInputValue(color: string): string;
|
|
110
|
-
|
|
111
9
|
/** A "nice" step (1, 2, 2.5 or 5 × 10ⁿ) for about `count` intervals over `span`. */
|
|
112
10
|
declare function niceStep(span: number, count: number): number;
|
|
113
11
|
interface NiceScale {
|
|
@@ -357,87 +255,6 @@ declare function summarizeChartSeries(series: {
|
|
|
357
255
|
values: readonly ChartValue[];
|
|
358
256
|
}, categories: readonly string[]): ChartSeriesSummary;
|
|
359
257
|
|
|
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
|
-
|
|
396
|
-
type ChartTextMeasure = (text: string, size: number, weight?: number) => number;
|
|
397
|
-
interface ChartLayoutOptions {
|
|
398
|
-
width: number;
|
|
399
|
-
height: number;
|
|
400
|
-
theme?: Partial<ChartTheme>;
|
|
401
|
-
/** Highlighted in the scene (selection outlines, `selected` flags). */
|
|
402
|
-
selection?: ChartSelection | null;
|
|
403
|
-
/** Text width in pixels (default: an estimate from the character count). */
|
|
404
|
-
measureText?: ChartTextMeasure;
|
|
405
|
-
/** Shown when there is nothing to draw (default "No data"). */
|
|
406
|
-
emptyMessage?: string;
|
|
407
|
-
/**
|
|
408
|
-
* Fixes the value axis to this range (over `yAxis.min` / `yAxis.max`). Canvases pass
|
|
409
|
-
* `ChartPointDrag.valueDomain` during a drag so the axis does not rescale under the pointer.
|
|
410
|
-
*/
|
|
411
|
-
valueDomain?: {
|
|
412
|
-
min: number;
|
|
413
|
-
max: number;
|
|
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;
|
|
430
|
-
}
|
|
431
|
-
/** A DOM-free text width estimate (average glyph ≈ 0.56 em, bold ≈ 0.6 em). */
|
|
432
|
-
declare const estimateChartTextWidth: ChartTextMeasure;
|
|
433
|
-
/** Whether two selections point at the same thing. */
|
|
434
|
-
declare function sameChartSelection(a: ChartSelection | null | undefined, b: ChartSelection | null | undefined): boolean;
|
|
435
|
-
/**
|
|
436
|
-
* Black or white text for a label drawn on `fill` (#rgb, #rrggbb or rgb()), by perceived
|
|
437
|
-
* luminance (0.299 R + 0.587 G + 0.114 B). Unparseable colours (CSS variables) get white.
|
|
438
|
-
*/
|
|
439
|
-
declare function contrastingTextColor(fill: string): string;
|
|
440
|
-
|
|
441
258
|
/**
|
|
442
259
|
* Lays a chart out as drawing primitives (rects, paths, circles, lines and text) in a
|
|
443
260
|
* `width × height` box. Pure and DOM-free: the React and Svelte canvases render the marks
|
|
@@ -470,23 +287,6 @@ declare const MAX_CHART_LINE_POINTS = 2000;
|
|
|
470
287
|
/** Markers beyond this many are thinned to one per 2px cell. */
|
|
471
288
|
declare const MAX_CHART_MARKERS = 1000;
|
|
472
289
|
|
|
473
|
-
/** SVG `dominant-baseline` for a text mark's baseline (shared by every renderer). */
|
|
474
|
-
declare function chartTextBaseline(baseline: ChartTextMark['baseline']): 'hanging' | 'central' | 'text-after-edge';
|
|
475
|
-
/** SVG `transform` for a rotated text mark, if any. */
|
|
476
|
-
declare function chartTextTransform(mark: ChartTextMark): string | undefined;
|
|
477
|
-
interface ChartSvgOptions {
|
|
478
|
-
/** Leave out selection outlines (default `true`: exports show the chart only). */
|
|
479
|
-
hideSelection?: boolean;
|
|
480
|
-
/** Accessible title (default: the chart title). */
|
|
481
|
-
ariaLabel?: string;
|
|
482
|
-
/** A longer description written as `<desc>` (`chartToSvg` defaults to `describeChart`). */
|
|
483
|
-
description?: string;
|
|
484
|
-
}
|
|
485
|
-
/** Writes a laid-out scene as a standalone SVG document string. */
|
|
486
|
-
declare function chartSceneToSvg(scene: ChartScene, options?: ChartSvgOptions): string;
|
|
487
|
-
/** Lays out and writes a chart as SVG, e.g. for export or server rendering. */
|
|
488
|
-
declare function chartToSvg(spec: ChartSpec, options: Omit<ChartLayoutOptions, 'selection'> & ChartSvgOptions): string;
|
|
489
|
-
|
|
490
290
|
interface ChartSummary {
|
|
491
291
|
type: ChartSpec['type'];
|
|
492
292
|
title: string;
|
|
@@ -524,34 +324,6 @@ declare function summarizeChart(spec: ChartSpec, size?: Pick<ChartLayoutOptions,
|
|
|
524
324
|
/** A plain-language description of a chart: type, what it compares, ranges and notable extremes. */
|
|
525
325
|
declare function describeChart(spec: ChartSpec, series?: ChartSeriesSummary[]): string;
|
|
526
326
|
|
|
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
327
|
/** A partial change several fields at once (what `ChartController.update` takes). */
|
|
556
328
|
type ChartPresetPatch = Partial<Omit<ChartSpec, 'version' | 'xAxis' | 'yAxis' | 'yAxis2' | 'legend' | 'series' | 'categories'>> & {
|
|
557
329
|
xAxis?: Partial<ChartAxis>;
|
|
@@ -643,268 +415,6 @@ declare function chartFromTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, opt
|
|
|
643
415
|
type?: ChartType | 'auto';
|
|
644
416
|
}): ChartFromTable;
|
|
645
417
|
|
|
646
|
-
interface ChartControllerOptions {
|
|
647
|
-
/** Starting chart (any partial or saved spec; problems are reported in `state.issues`). */
|
|
648
|
-
spec?: Partial<ChartSpec> | unknown;
|
|
649
|
-
/** History to record into, e.g. one shared with the rest of the app (default: a new one). */
|
|
650
|
-
history?: HistoryManager;
|
|
651
|
-
/** Called after the spec changes (edit, undo, redo, load). */
|
|
652
|
-
onChange?: (spec: Readonly<ChartSpec>) => void;
|
|
653
|
-
}
|
|
654
|
-
/** A snapshot of the controller. The same object is returned until something changes. */
|
|
655
|
-
interface ChartState {
|
|
656
|
-
spec: Readonly<ChartSpec>;
|
|
657
|
-
selection: ChartSelection | null;
|
|
658
|
-
/** The series the selection belongs to (a series, one of its points or one of its trendlines). */
|
|
659
|
-
selectedSeries: ChartSeries | null;
|
|
660
|
-
/** The category the selection belongs to (a category or a point). */
|
|
661
|
-
selectedIndex: number | null;
|
|
662
|
-
/** Problems from the last load or rejected edit, as sentences. */
|
|
663
|
-
issues: readonly ChartIssue[];
|
|
664
|
-
/** The gesture in progress (e.g. a bar drag), if any. */
|
|
665
|
-
gesture: string | null;
|
|
666
|
-
canUndo: boolean;
|
|
667
|
-
canRedo: boolean;
|
|
668
|
-
undoLabel: string;
|
|
669
|
-
redoLabel: string;
|
|
670
|
-
/** Bumped on every change. */
|
|
671
|
-
revision: number;
|
|
672
|
-
}
|
|
673
|
-
type ChartActionResult = {
|
|
674
|
-
ok: true;
|
|
675
|
-
} | {
|
|
676
|
-
ok: false;
|
|
677
|
-
message: string;
|
|
678
|
-
issues?: ChartIssue[];
|
|
679
|
-
};
|
|
680
|
-
/** Top-level fields with partial axes and legend. */
|
|
681
|
-
type ChartSpecPatch = Partial<Omit<ChartSpec, 'version' | 'xAxis' | 'yAxis' | 'yAxis2' | 'legend'>> & {
|
|
682
|
-
xAxis?: Partial<ChartAxis>;
|
|
683
|
-
yAxis?: Partial<ChartAxis>;
|
|
684
|
-
yAxis2?: Partial<ChartAxis>;
|
|
685
|
-
legend?: Partial<ChartLegend>;
|
|
686
|
-
};
|
|
687
|
-
interface ChartSeriesInput {
|
|
688
|
-
id?: string;
|
|
689
|
-
name?: string;
|
|
690
|
-
values?: readonly unknown[];
|
|
691
|
-
color?: string;
|
|
692
|
-
type?: ChartSeriesType;
|
|
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[];
|
|
703
|
-
}
|
|
704
|
-
/** Changes to one series; `null` resets a field to the chart's default. */
|
|
705
|
-
interface ChartSeriesPatch {
|
|
706
|
-
name?: string;
|
|
707
|
-
/** `null` goes back to the palette colour. */
|
|
708
|
-
color?: string | null;
|
|
709
|
-
/** `null` follows the chart type. */
|
|
710
|
-
type?: ChartSeriesType | null;
|
|
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;
|
|
720
|
-
}
|
|
721
|
-
interface ChartEditOptions {
|
|
722
|
-
/** Undo step label. */
|
|
723
|
-
label?: string;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Headless state for a chart editor: a validated `ChartSpec`, a selection, and undoable
|
|
727
|
-
* edits to data (values, series, categories, pasted grids, CSV) and presentation (type,
|
|
728
|
-
* titles, axes, legend, stacking, …). Drags merge into one undo step (`beginGesture`).
|
|
729
|
-
* `getState()` returns the same object until something changes, so it works with
|
|
730
|
-
* `useSyncExternalStore` and Svelte runes alike.
|
|
731
|
-
*/
|
|
732
|
-
declare class ChartController {
|
|
733
|
-
readonly history: HistoryManager;
|
|
734
|
-
private spec;
|
|
735
|
-
private selection;
|
|
736
|
-
private issues;
|
|
737
|
-
private gestureKey;
|
|
738
|
-
private gestureCount;
|
|
739
|
-
private gestureStart;
|
|
740
|
-
private revision;
|
|
741
|
-
private applying;
|
|
742
|
-
private readonly onChange?;
|
|
743
|
-
private readonly listeners;
|
|
744
|
-
private unsubscribeHistory?;
|
|
745
|
-
private state;
|
|
746
|
-
constructor(options?: ChartControllerOptions);
|
|
747
|
-
private connect;
|
|
748
|
-
/** The current snapshot (stable until the next change). */
|
|
749
|
-
getState: () => ChartState;
|
|
750
|
-
/** Calls `listener` after every change. Returns an unsubscribe function. */
|
|
751
|
-
subscribe: (listener: (state: ChartState) => void) => (() => void);
|
|
752
|
-
/** The current spec (do not mutate; edit through the controller). */
|
|
753
|
-
getSpec(): Readonly<ChartSpec>;
|
|
754
|
-
getSeries(id: string): ChartSeries | undefined;
|
|
755
|
-
private computeState;
|
|
756
|
-
private notify;
|
|
757
|
-
/** Drops a selection that no longer points at anything. */
|
|
758
|
-
private validSelection;
|
|
759
|
-
private applySpec;
|
|
760
|
-
private commit;
|
|
761
|
-
private reject;
|
|
762
|
-
/** A copy of the spec with `edit` applied (series and categories copied as needed). */
|
|
763
|
-
private edited;
|
|
764
|
-
private unknownSeries;
|
|
765
|
-
private badIndex;
|
|
766
|
-
/**
|
|
767
|
-
* Changes any presentation or data fields as one undo step. All-or-nothing: if anything
|
|
768
|
-
* is invalid, nothing changes and every problem is returned (and shown in `state.issues`).
|
|
769
|
-
*/
|
|
770
|
-
update(patch: ChartSpecPatch, options?: ChartEditOptions): ChartActionResult;
|
|
771
|
-
setType(type: ChartType): ChartActionResult;
|
|
772
|
-
setTitle(title: string): ChartActionResult;
|
|
773
|
-
setSubtitle(subtitle: string): 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;
|
|
784
|
-
setLegend(patch: Partial<ChartLegend>): ChartActionResult;
|
|
785
|
-
/**
|
|
786
|
-
* Replaces categories and / or series as one undo step. Values are validated and padded
|
|
787
|
-
* to the categories; all-or-nothing like `update`.
|
|
788
|
-
*/
|
|
789
|
-
setData(data: {
|
|
790
|
-
categories?: readonly unknown[];
|
|
791
|
-
series?: readonly ChartSeriesInput[];
|
|
792
|
-
}, options?: ChartEditOptions): ChartActionResult;
|
|
793
|
-
/**
|
|
794
|
-
* Sets one value (numbers, numeric text such as `1,200` or `12%`, or blank for a gap).
|
|
795
|
-
* One undo step, or part of the current gesture.
|
|
796
|
-
*/
|
|
797
|
-
setValue(seriesId: string, index: number, value: unknown, options?: ChartEditOptions): ChartActionResult;
|
|
798
|
-
/** Several values as one undo step (all-or-nothing). */
|
|
799
|
-
setValues(cells: readonly {
|
|
800
|
-
seriesId: string;
|
|
801
|
-
index: number;
|
|
802
|
-
value: unknown;
|
|
803
|
-
}[], options?: ChartEditOptions): ChartActionResult;
|
|
804
|
-
/** Adds a series (values padded to the categories) and selects it. Returns its id. */
|
|
805
|
-
addSeries(input?: ChartSeriesInput, options?: {
|
|
806
|
-
at?: number;
|
|
807
|
-
}): {
|
|
808
|
-
ok: true;
|
|
809
|
-
id: string;
|
|
810
|
-
} | {
|
|
811
|
-
ok: false;
|
|
812
|
-
message: string;
|
|
813
|
-
issues?: ChartIssue[];
|
|
814
|
-
};
|
|
815
|
-
removeSeries(id: string): ChartActionResult;
|
|
816
|
-
updateSeries(id: string, patch: ChartSeriesPatch): ChartActionResult;
|
|
817
|
-
toggleSeries(id: string): ChartActionResult;
|
|
818
|
-
/** Moves a series to position `to` (drawing and legend order). */
|
|
819
|
-
moveSeries(id: string, to: number): ChartActionResult;
|
|
820
|
-
/** Inserts a category (with gaps in every series) at `at` (default: the end). Returns its index. */
|
|
821
|
-
addCategory(label?: string, options?: {
|
|
822
|
-
at?: number;
|
|
823
|
-
}): {
|
|
824
|
-
ok: true;
|
|
825
|
-
index: number;
|
|
826
|
-
};
|
|
827
|
-
removeCategory(index: number): ChartActionResult;
|
|
828
|
-
renameCategory(index: number, label: string): ChartActionResult;
|
|
829
|
-
moveCategory(from: number, to: number): ChartActionResult;
|
|
830
|
-
/**
|
|
831
|
-
* Pastes a block of cells (TSV / CSV text or rows) into the data grid with its top-left at
|
|
832
|
-
* `row` (category index) and `column` (series index; `-1` is the category column). The
|
|
833
|
-
* grid grows to fit. Non-numeric value cells become gaps and are reported in `issues`.
|
|
834
|
-
*/
|
|
835
|
-
pasteCells(row: number, column: number, cells: string | ReadonlyArray<ReadonlyArray<unknown>>): ChartActionResult & {
|
|
836
|
-
issues?: ChartIssue[];
|
|
837
|
-
};
|
|
838
|
-
/**
|
|
839
|
-
* Replaces the data with a grid of cells (see `chartDataFromTable`): one undo step. Series
|
|
840
|
-
* colours and types are kept by name.
|
|
841
|
-
*/
|
|
842
|
-
importTable(rows: ReadonlyArray<ReadonlyArray<unknown>>, options?: ChartTableOptions): ChartActionResult & {
|
|
843
|
-
issues?: ChartIssue[];
|
|
844
|
-
};
|
|
845
|
-
/** Imports CSV (or TSV, detected by tabs) text; see `importTable`. */
|
|
846
|
-
importCsv(text: string, options?: ChartTableOptions & {
|
|
847
|
-
delimiter?: string;
|
|
848
|
-
}): ChartActionResult & {
|
|
849
|
-
issues?: ChartIssue[];
|
|
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;
|
|
875
|
-
/** Selects a chart element (view state; not an undo step). */
|
|
876
|
-
select(selection: ChartSelection | null): void;
|
|
877
|
-
/**
|
|
878
|
-
* Deletes what is selected: a series or category is removed, a point becomes a gap, a
|
|
879
|
-
* title is cleared, the legend or an axis is hidden.
|
|
880
|
-
*/
|
|
881
|
-
deleteSelection(): ChartActionResult;
|
|
882
|
-
/** Adds `delta` to a value (a gap counts as 0). */
|
|
883
|
-
nudgeValue(seriesId: string, index: number, delta: number): ChartActionResult;
|
|
884
|
-
/** Starts a continuous edit (a drag): every change until `endGesture()` is one undo step. */
|
|
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;
|
|
891
|
-
endGesture(): void;
|
|
892
|
-
/** The spec, for saving (a copy). */
|
|
893
|
-
toJSON(): ChartSpec;
|
|
894
|
-
/**
|
|
895
|
-
* Replaces the chart without an undo step (e.g. when opening a document). Problems are
|
|
896
|
-
* fixed with defaults and reported in `state.issues` (and returned).
|
|
897
|
-
*/
|
|
898
|
-
load(input: unknown, options?: {
|
|
899
|
-
clearHistory?: boolean;
|
|
900
|
-
}): ChartIssue[];
|
|
901
|
-
undo(): boolean;
|
|
902
|
-
redo(): boolean;
|
|
903
|
-
/** Stops listening to the history (reconnected by the next `subscribe`). */
|
|
904
|
-
destroy(): void;
|
|
905
|
-
}
|
|
906
|
-
declare function createChartController(options?: ChartControllerOptions): ChartController;
|
|
907
|
-
|
|
908
418
|
interface ChartCommandOptions {
|
|
909
419
|
/** Id prefix (default `chart.`); use one per chart when several are registered. */
|
|
910
420
|
prefix?: string;
|
|
@@ -1367,4 +877,4 @@ declare function blendChartScenes(from: ChartScene | null, to: ChartScene, t: nu
|
|
|
1367
877
|
/** Ease-out cubic, for tweens. */
|
|
1368
878
|
declare const easeChartTween: (t: number) => number;
|
|
1369
879
|
|
|
1370
|
-
export {
|
|
880
|
+
export { CHART_COLOR_SCHEMES, CHART_DATE_STEPS, CHART_LAYOUT_PRESETS, CHART_MERMAID_META_PREFIX, CHART_OOXML_CONTENT_TYPE, CHART_OOXML_NS, CHART_OOXML_RELATIONSHIP, CHART_PALETTE_SHADES, CHART_PRESENCE_COLORS, type ChartAgentCommand, ChartAxis, type ChartBoxStats, type ChartClock, type ChartColorCheck, type ChartColorCheckOptions, type ChartColorPair, type ChartColorScheme, type ChartCommandOptions, ChartController, type ChartDateLabels, type ChartDateStep, ChartDirector, type ChartDirectorActor, type ChartDirectorOptions, type ChartDragMoveOptions, type ChartFormatCode, type ChartFromTable, type ChartHistogramBin, ChartIssue, type ChartKeyInput, ChartLayoutOptions, type ChartLayoutPreset, ChartLegend, type ChartMermaidFamily, type ChartMermaidOptions, type ChartMermaidParseOptions, type ChartMermaidResult, ChartNumberFormat, type ChartOoxmlReadOptions, type ChartOoxmlReadResult, type ChartOoxmlWriteResult, type ChartPerformanceResult, type ChartPerformanceStep, type ChartPointDrag, ChartPresence, type ChartPresenceActor, type ChartPresenceState, type ChartPresetPatch, type ChartRecommendation, ChartRect, type ChartRgb, ChartScene, ChartSelection, ChartSeries, type ChartSeriesSummary, type ChartSnapOptions, ChartSpec, ChartSpecPatch, ChartStacking, ChartStream, type ChartStreamFormat, type ChartStreamResult, type ChartSummary, type ChartTableShape, type ChartToolProviderOptions, ChartType, ChartValue, ChartValueScale, type ChartVision, ChartWarning, type FoundChartMermaid, MAX_CHART_DATA_LABELS, MAX_CHART_LINE_POINTS, MAX_CHART_MARKERS, type NiceScale, analyzeChartTable, blendChartScenes, canDragChartPoint, chartBoxStats, chartClientToScene, chartColorDistance, chartContrastRatio, chartDateLabels, chartDateToSerial, chartFormatToCode, chartFromMermaid, chartFromOoxml, chartFromTable, chartHistogram, chartHitTest, chartLuminance, chartMermaidFamily, chartPointAnchor, chartPresetPatch, chartQuantile, chartRgbToHex, chartRgbToOklab, chartSerialToDate, chartSquarify, chartTextOn, chartToMermaid, chartToOoxml, chartValueAtPoint, chartXAtPoint, checkChartColors, compileChartFormatCode, createChartCommands, createChartToolProvider, createInstantChartClock, cyclePaletteColor, decimateChartPoints, describeChart, describeChartSelection, easeChartTween, findMermaidCharts, formatChartDate, formatChartNumber, formatChartValueWithCode, handleChartKey, layoutChart, linearMap, monochromeChartPalette, niceScale, niceStep, parseChartColor, parseChartDate, parsePartialChartJson, planChartCommand, realChartClock, recommendChartTypes, recommendForShape, shadeChartColor, simulateChartVision, snapChartDragValue, snapChartValue, startChartPointDrag, stepDecimals, summarizeChart, summarizeChartSeries };
|