@opendata-ai/openchart-core 8.0.0-rc.9 → 8.0.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/index.d.ts +363 -43
- package/dist/index.js +39 -18
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -2
- package/schema/chart.schema.json +373 -67
- package/schema/table.schema.json +35 -1
- package/schema/vizspec.schema.json +950 -152
- package/src/accessibility/__tests__/alt-text.test.ts +0 -110
- package/src/accessibility/__tests__/aria.test.ts +0 -125
- package/src/accessibility/alt-text.ts +0 -155
- package/src/accessibility/aria.ts +0 -75
- package/src/accessibility/index.ts +0 -6
- package/src/colors/__tests__/colorblind.test.ts +0 -75
- package/src/colors/__tests__/contrast.test.ts +0 -119
- package/src/colors/__tests__/palettes.test.ts +0 -74
- package/src/colors/colorblind.ts +0 -131
- package/src/colors/contrast.ts +0 -143
- package/src/colors/index.ts +0 -36
- package/src/colors/palettes.ts +0 -206
- package/src/helpers/__tests__/deep-merge.test.ts +0 -54
- package/src/helpers/__tests__/spec-builders.test.ts +0 -338
- package/src/helpers/deep-merge.ts +0 -29
- package/src/helpers/spec-builders.ts +0 -479
- package/src/index.ts +0 -215
- package/src/labels/__tests__/collision.test.ts +0 -310
- package/src/labels/collision.ts +0 -249
- package/src/labels/index.ts +0 -13
- package/src/layout/__tests__/chrome.test.ts +0 -208
- package/src/layout/__tests__/text-measure.test.ts +0 -57
- package/src/layout/chrome.ts +0 -470
- package/src/layout/index.ts +0 -18
- package/src/layout/text-measure.ts +0 -404
- package/src/layout/text-wrap.ts +0 -93
- package/src/locale/__tests__/format.test.ts +0 -606
- package/src/locale/format.ts +0 -459
- package/src/locale/index.ts +0 -21
- package/src/responsive/__tests__/breakpoints.test.ts +0 -146
- package/src/responsive/__tests__/metrics.test.ts +0 -52
- package/src/responsive/breakpoints.ts +0 -177
- package/src/responsive/index.ts +0 -53
- package/src/responsive/metrics.ts +0 -299
- package/src/schema/__tests__/generated-artifacts.test.ts +0 -42
- package/src/schema/__tests__/schema.test.ts +0 -179
- package/src/styles/__tests__/reduced-motion-selectors.test.ts +0 -28
- package/src/styles/animation.css +0 -213
- package/src/styles/base.css +0 -102
- package/src/styles/chrome.css +0 -174
- package/src/styles/dark.css +0 -44
- package/src/styles/graph.css +0 -135
- package/src/styles/index.css +0 -28
- package/src/styles/keyframes.css +0 -151
- package/src/styles/legend.css +0 -18
- package/src/styles/reduced-motion.css +0 -67
- package/src/styles/series-search.css +0 -153
- package/src/styles/sparkline.css +0 -16
- package/src/styles/table-animation.css +0 -93
- package/src/styles/table.css +0 -398
- package/src/styles/token-definitions.ts +0 -199
- package/src/styles/tokens.css +0 -156
- package/src/styles/tooltip.css +0 -126
- package/src/styles/you-draw-it.css +0 -126
- package/src/theme/__tests__/dark-mode.test.ts +0 -232
- package/src/theme/__tests__/defaults.test.ts +0 -73
- package/src/theme/__tests__/resolve.test.ts +0 -277
- package/src/theme/dark-mode.ts +0 -258
- package/src/theme/defaults.ts +0 -110
- package/src/theme/index.ts +0 -8
- package/src/theme/presets.ts +0 -64
- package/src/theme/resolve.ts +0 -312
- package/src/types/__tests__/encoding.test.ts +0 -368
- package/src/types/__tests__/gradient.test.ts +0 -95
- package/src/types/__tests__/spec.test.ts +0 -499
- package/src/types/encoding.ts +0 -280
- package/src/types/events.ts +0 -236
- package/src/types/index.ts +0 -290
- package/src/types/layout.ts +0 -2024
- package/src/types/schema-roots.ts +0 -32
- package/src/types/spec.ts +0 -2925
- package/src/types/table.ts +0 -108
- package/src/types/theme.ts +0 -209
package/dist/index.d.ts
CHANGED
|
@@ -67,7 +67,12 @@ interface LayoutStrategy {
|
|
|
67
67
|
*
|
|
68
68
|
* Compact: minimal chrome, no inline labels, legend on top, reduced axes.
|
|
69
69
|
* Medium: moderate labels, legend on top, reduced axes.
|
|
70
|
-
* Full: all labels, legend on
|
|
70
|
+
* Full: all labels, legend on top, full axes.
|
|
71
|
+
*
|
|
72
|
+
* Legend position is 'top' at every breakpoint: a top legend reads as a key to
|
|
73
|
+
* the chart before the eye reaches the plot, and it keeps the plotting area
|
|
74
|
+
* full-width instead of surrendering a right-hand column. `legend.position`
|
|
75
|
+
* still overrides it per spec.
|
|
71
76
|
*
|
|
72
77
|
* Height constraints further reduce chrome and legend when container is short.
|
|
73
78
|
*/
|
|
@@ -432,6 +437,29 @@ declare function isGradientDef(value: unknown): value is GradientDef;
|
|
|
432
437
|
* overlays that need a flat color.
|
|
433
438
|
*/
|
|
434
439
|
declare function getRepresentativeColor(fill: string | GradientDef): string;
|
|
440
|
+
/**
|
|
441
|
+
* Configuration for the scatter regression trend line. Passed as the object
|
|
442
|
+
* form of `MarkDef.trendline`.
|
|
443
|
+
*/
|
|
444
|
+
interface TrendlineConfig {
|
|
445
|
+
/**
|
|
446
|
+
* Stacking order relative to the point marks. `'below'` (default) draws the
|
|
447
|
+
* line behind the dots; `'above'` draws it on top so it stays visible over a
|
|
448
|
+
* dense cloud.
|
|
449
|
+
*/
|
|
450
|
+
layer?: 'above' | 'below';
|
|
451
|
+
/**
|
|
452
|
+
* Stroke color. Defaults to the theme's high-contrast text color so the line
|
|
453
|
+
* reads on both light and dark grounds. Set an explicit CSS color to override.
|
|
454
|
+
*/
|
|
455
|
+
stroke?: string;
|
|
456
|
+
/**
|
|
457
|
+
* Stroke width in pixels. Defaults to 1.5. Over a dense cloud with `layer:
|
|
458
|
+
* 'above'`, a heavier line (e.g. 2.5) stays legible where the thin default
|
|
459
|
+
* disappears into the dots.
|
|
460
|
+
*/
|
|
461
|
+
strokeWidth?: number;
|
|
462
|
+
}
|
|
435
463
|
/**
|
|
436
464
|
* Mark definition object with visual properties.
|
|
437
465
|
*
|
|
@@ -479,7 +507,15 @@ interface MarkDef {
|
|
|
479
507
|
endAngle?: number;
|
|
480
508
|
/** Corner radius for rect/bar marks. 'pill' sets rx to half the bar thickness. */
|
|
481
509
|
cornerRadius?: number | 'pill';
|
|
482
|
-
/**
|
|
510
|
+
/**
|
|
511
|
+
* Bar/column marks: fixed bar thickness in pixels. When set, bars are this
|
|
512
|
+
* height (horizontal) or width (vertical), centered within the band.
|
|
513
|
+
*
|
|
514
|
+
* Point marks: the dot RADIUS in pixels (default 5, typical 2-12). This is
|
|
515
|
+
* NOT Vega-Lite's point `size`, which is an area in px^2 -- a VL size of
|
|
516
|
+
* 110 corresponds to `size: 6` here (r = sqrt(area / pi)). Validation
|
|
517
|
+
* rejects values above 50 with the conversion.
|
|
518
|
+
*/
|
|
483
519
|
size?: number;
|
|
484
520
|
/** Whether the mark is filled (vs stroked only). */
|
|
485
521
|
filled?: boolean;
|
|
@@ -501,8 +537,13 @@ interface MarkDef {
|
|
|
501
537
|
* suppress it when the chart already carries its own reference line (e.g. a
|
|
502
538
|
* manual x=y diagonal in a separate layer), which would otherwise produce
|
|
503
539
|
* two competing diagonals.
|
|
540
|
+
*
|
|
541
|
+
* Pass an object to control stacking order: the line renders `below` the
|
|
542
|
+
* points by default, but a dense scatter (thousands of overlapping dots)
|
|
543
|
+
* fully occludes a line drawn underneath, so `{ layer: 'above' }` lifts the
|
|
544
|
+
* reference line over the cloud.
|
|
504
545
|
*/
|
|
505
|
-
trendline?: boolean;
|
|
546
|
+
trendline?: boolean | TrendlineConfig;
|
|
506
547
|
/**
|
|
507
548
|
* Horizontal pixel offset from the data anchor. Only meaningful when `type`
|
|
508
549
|
* is `'text'`. Use it to lift a label clear of the mark it annotates instead
|
|
@@ -902,9 +943,13 @@ interface Encoding<TData extends DataRow = DataRow> {
|
|
|
902
943
|
*/
|
|
903
944
|
color?: EncodingChannel<TData> | ConditionalValueDef<TData> | ValueDef;
|
|
904
945
|
/**
|
|
905
|
-
* Size channel. Used by point/bubble charts to scale
|
|
906
|
-
*
|
|
907
|
-
*
|
|
946
|
+
* Size channel. Used by point/bubble charts to scale dots by a quantitative
|
|
947
|
+
* field, area-proportionally (sqrt curve). The units are dot RADII in px:
|
|
948
|
+
* `scale.range` defaults to [3, 30] for scatter, and a bare `{ value }`
|
|
949
|
+
* constant expands to `mark.size`, also a radius. This differs from
|
|
950
|
+
* Vega-Lite, where point size is an area in px^2 -- VL-scale values
|
|
951
|
+
* (60-900) are rejected by validation with the conversion.
|
|
952
|
+
* Accepts a conditional definition to vary size based on data predicates.
|
|
908
953
|
*/
|
|
909
954
|
size?: EncodingChannel<TData> | ConditionalValueDef<TData> | ValueDef;
|
|
910
955
|
/**
|
|
@@ -968,6 +1013,20 @@ interface Encoding<TData extends DataRow = DataRow> {
|
|
|
968
1013
|
* per-panel axes.
|
|
969
1014
|
*/
|
|
970
1015
|
facet?: FacetChannel<TData>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Row facet channel: partitions data into vertically-stacked panels.
|
|
1018
|
+
* Each unique value of the row field produces one panel, arranged in a
|
|
1019
|
+
* single column. Shares the x-axis scale by default; y-axis is independent.
|
|
1020
|
+
* Mutually exclusive with `facet` and `column`.
|
|
1021
|
+
*/
|
|
1022
|
+
row?: FacetChannel<TData>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Column facet channel: partitions data into side-by-side panels.
|
|
1025
|
+
* Each unique value of the column field produces one panel, arranged in a
|
|
1026
|
+
* single row. Shares the y-axis scale by default; x-axis is independent.
|
|
1027
|
+
* Mutually exclusive with `facet` and `row`.
|
|
1028
|
+
*/
|
|
1029
|
+
column?: FacetChannel<TData>;
|
|
971
1030
|
}
|
|
972
1031
|
/** Encoding channel for graph nodes and edges. */
|
|
973
1032
|
interface GraphEncodingChannel {
|
|
@@ -977,13 +1036,40 @@ interface GraphEncodingChannel {
|
|
|
977
1036
|
type?: FieldType;
|
|
978
1037
|
/** Scale configuration. Auto-derived from data if omitted. */
|
|
979
1038
|
scale?: ScaleConfig;
|
|
1039
|
+
/**
|
|
1040
|
+
* Category ordering for the color domain and legend. Graph channels default
|
|
1041
|
+
* `'ascending'` (VL-aligned, deterministic); `string[]` pins an explicit
|
|
1042
|
+
* order; `null` keeps data order.
|
|
1043
|
+
*
|
|
1044
|
+
* NOTE: chart encoding channels keep data-order — this graph default is a
|
|
1045
|
+
* deliberate divergence this release (see docs/migrating-v8.md).
|
|
1046
|
+
*/
|
|
1047
|
+
sort?: 'ascending' | 'descending' | null | string[];
|
|
1048
|
+
/**
|
|
1049
|
+
* Category values to emphasize on load; the rest dim. Mirrors the chart
|
|
1050
|
+
* `encoding.color.highlight` value list. Distinct from the `highlight()`
|
|
1051
|
+
* runtime verb and `interaction.hover.mode`.
|
|
1052
|
+
*/
|
|
1053
|
+
highlight?: string | string[];
|
|
980
1054
|
}
|
|
981
1055
|
/** Graph-specific encoding mapping visual properties to node/edge data fields. */
|
|
982
1056
|
interface GraphEncoding {
|
|
983
1057
|
/** Color mapping for nodes. */
|
|
984
1058
|
nodeColor?: GraphEncodingChannel;
|
|
985
|
-
/**
|
|
1059
|
+
/**
|
|
1060
|
+
* Size mapping for nodes. `scale.type` defaults to `'sqrt'` (area-perceptual,
|
|
1061
|
+
* today's behavior); set `scale.type: 'linear'` for a linear radius ramp.
|
|
1062
|
+
* `scale.range` sets the pixel radius extent (default `[3, 12]`).
|
|
1063
|
+
*/
|
|
986
1064
|
nodeSize?: GraphEncodingChannel;
|
|
1065
|
+
/**
|
|
1066
|
+
* Opacity mapping for nodes (VL opacity channel). Quantitative fields map
|
|
1067
|
+
* linearly to `[0.25, 1]`; `scale.range` overrides.
|
|
1068
|
+
*
|
|
1069
|
+
* NOTE: there is deliberately no `edgeOpacity` channel — edge alpha is owned
|
|
1070
|
+
* by the interaction alpha-tier machinery (hover dimming, search).
|
|
1071
|
+
*/
|
|
1072
|
+
nodeOpacity?: GraphEncodingChannel;
|
|
987
1073
|
/** Color mapping for edges. */
|
|
988
1074
|
edgeColor?: GraphEncodingChannel;
|
|
989
1075
|
/** Width mapping for edges. */
|
|
@@ -992,6 +1078,13 @@ interface GraphEncoding {
|
|
|
992
1078
|
edgeStyle?: GraphEncodingChannel;
|
|
993
1079
|
/** Label field for nodes. */
|
|
994
1080
|
nodeLabel?: GraphEncodingChannel;
|
|
1081
|
+
/**
|
|
1082
|
+
* Label priority mapping for nodes. Maps a quantitative field to a 0-1
|
|
1083
|
+
* priority range; higher values are shown first as the user zooms in.
|
|
1084
|
+
* Omit to use the default degree-based priority.
|
|
1085
|
+
* `nodeOverrides[id].alwaysShowLabel` still wins as the hard override.
|
|
1086
|
+
*/
|
|
1087
|
+
nodeLabelPriority?: GraphEncodingChannel;
|
|
995
1088
|
}
|
|
996
1089
|
/** Layout algorithm for graph visualization. */
|
|
997
1090
|
interface GraphLayoutConfig {
|
|
@@ -1012,6 +1105,31 @@ interface GraphLayoutConfig {
|
|
|
1012
1105
|
linkStrength?: number;
|
|
1013
1106
|
/** Whether to apply center force (default true). */
|
|
1014
1107
|
centerForce?: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* Deterministic layout seed. Same spec + seed ⇒ identical settled layout
|
|
1110
|
+
* within a given execution path (worker vs sync parity is not guaranteed).
|
|
1111
|
+
*/
|
|
1112
|
+
seed?: number;
|
|
1113
|
+
/**
|
|
1114
|
+
* Repulsion preset (plain-language, no d3 jargon):
|
|
1115
|
+
* `gentle`/`balanced`/`energetic` → chargeStrength −150/−300/−600 and
|
|
1116
|
+
* velocityDecay 0.5/0.4/0.3. A raw `chargeStrength` wins over the preset.
|
|
1117
|
+
*/
|
|
1118
|
+
energy?: 'gentle' | 'balanced' | 'energetic';
|
|
1119
|
+
/**
|
|
1120
|
+
* Settle-speed preset: `quick`/`balanced`/`thorough` → alphaDecay
|
|
1121
|
+
* 0.05/0.0228/0.01. Higher = faster cool-down, less final refinement.
|
|
1122
|
+
*/
|
|
1123
|
+
settle?: 'quick' | 'balanced' | 'thorough';
|
|
1124
|
+
/**
|
|
1125
|
+
* Headless settle ticks run before the first paint. `true` → 100 ticks under
|
|
1126
|
+
* a 250ms budget; a number sets an explicit tick count; `false` disables.
|
|
1127
|
+
*
|
|
1128
|
+
* Lives in `layout`, NOT `animation`, on purpose: warmup *reduces* motion, so
|
|
1129
|
+
* it must survive `animation: false` (opt-out consumers get less settling
|
|
1130
|
+
* chaos, not more).
|
|
1131
|
+
*/
|
|
1132
|
+
warmup?: boolean | number;
|
|
1015
1133
|
}
|
|
1016
1134
|
/** Style overrides for a chrome text element. */
|
|
1017
1135
|
interface ChromeTextStyle {
|
|
@@ -1023,6 +1141,14 @@ interface ChromeTextStyle {
|
|
|
1023
1141
|
fontFamily?: string;
|
|
1024
1142
|
/** Text color (CSS color string). */
|
|
1025
1143
|
color?: string;
|
|
1144
|
+
/**
|
|
1145
|
+
* Maximum number of lines this chrome text may wrap to. Additional lines are
|
|
1146
|
+
* dropped and the last kept line is truncated with an ellipsis. Bounds the
|
|
1147
|
+
* chrome's contribution to layout height at any container width. Applies
|
|
1148
|
+
* whether the font size comes from the theme default or an explicit override.
|
|
1149
|
+
* Caps height only, not horizontal overflow of a single unbreakable word.
|
|
1150
|
+
*/
|
|
1151
|
+
maxLines?: number;
|
|
1026
1152
|
}
|
|
1027
1153
|
/** A chrome text element with optional style overrides. */
|
|
1028
1154
|
interface ChromeText {
|
|
@@ -1613,6 +1739,20 @@ interface AnimationPhaseConfig {
|
|
|
1613
1739
|
/** Stagger config. true = defaults, false = no stagger. Default: true for enter. */
|
|
1614
1740
|
stagger?: AnimationStagger | boolean;
|
|
1615
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Data-update phase config. Adds `maxMarks` on top of the shared phase
|
|
1744
|
+
* options; the cap is meaningless for enter/exit, which animate via CSS.
|
|
1745
|
+
*/
|
|
1746
|
+
interface UpdatePhaseConfig extends AnimationPhaseConfig {
|
|
1747
|
+
/**
|
|
1748
|
+
* Maximum mark count that still runs a tweened data-update transition.
|
|
1749
|
+
* Default: 500. Above the cap the chart swaps instantly instead, because
|
|
1750
|
+
* per-frame SVG attribute writes on thousands of elements drop frames on
|
|
1751
|
+
* low-end devices. Raise it deliberately when the audience is desktop-heavy
|
|
1752
|
+
* and you have measured the frame budget.
|
|
1753
|
+
*/
|
|
1754
|
+
maxMarks?: number;
|
|
1755
|
+
}
|
|
1616
1756
|
/**
|
|
1617
1757
|
* Full animation config object. Structured as enter/update/exit phases
|
|
1618
1758
|
* following Vega's encoding set model.
|
|
@@ -1621,7 +1761,7 @@ interface AnimationConfig {
|
|
|
1621
1761
|
/** Entrance animation when chart first renders. */
|
|
1622
1762
|
enter?: AnimationPhaseConfig | boolean;
|
|
1623
1763
|
/** Transition animation when data updates. */
|
|
1624
|
-
update?:
|
|
1764
|
+
update?: UpdatePhaseConfig | boolean;
|
|
1625
1765
|
/** Exit animation when marks are removed. */
|
|
1626
1766
|
exit?: AnimationPhaseConfig | boolean;
|
|
1627
1767
|
/** Delay before annotations animate in (ms after marks). Default: 200. */
|
|
@@ -1876,6 +2016,20 @@ interface BaseChartSpec<TData extends DataRow = DataRow> {
|
|
|
1876
2016
|
transform?: Transform[];
|
|
1877
2017
|
/** Editorial chrome (title, subtitle, source, etc.). */
|
|
1878
2018
|
chrome?: Chrome;
|
|
2019
|
+
/**
|
|
2020
|
+
* How chrome height interacts with the container height budget.
|
|
2021
|
+
*
|
|
2022
|
+
* - `'subtract'` (default): the container height is fixed and chrome text
|
|
2023
|
+
* (title/subtitle/source) is subtracted from it, shrinking the plot. This
|
|
2024
|
+
* is the historical behavior.
|
|
2025
|
+
* - `'grow'`: the container height is treated as the *plot* budget, and the
|
|
2026
|
+
* rendered SVG grows taller by the measured chrome height. The plot keeps
|
|
2027
|
+
* its full budget (minus axis/padding overhead) regardless of how many
|
|
2028
|
+
* lines the title wraps to.
|
|
2029
|
+
*
|
|
2030
|
+
* `'grow'` is a no-op for faceted specs in this version.
|
|
2031
|
+
*/
|
|
2032
|
+
chromeLayout?: 'subtract' | 'grow';
|
|
1879
2033
|
/**
|
|
1880
2034
|
* Top-level title sugar (Vega-Lite aligned). Expanded into `chrome.title`
|
|
1881
2035
|
* (and `chrome.subtitle` for the object form). `chrome.title` wins when
|
|
@@ -2200,6 +2354,70 @@ interface NodeOverride {
|
|
|
2200
2354
|
/** Force label to always show regardless of zoom/priority. */
|
|
2201
2355
|
alwaysShowLabel?: boolean;
|
|
2202
2356
|
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Per-phase and per-behavior motion config for a graph.
|
|
2359
|
+
*
|
|
2360
|
+
* DEFAULT-ON semantics (deliberately different from charts, which are opt-in):
|
|
2361
|
+
* omit `animation` → the resolver returns full defaults; `animation: false` →
|
|
2362
|
+
* no choreography (but `layout.warmup` still applies); a per-phase `false`
|
|
2363
|
+
* disables just that phase. Graphs are default-on because physics motion
|
|
2364
|
+
* already exists on load and choreography reduces the chaos.
|
|
2365
|
+
*/
|
|
2366
|
+
interface GraphAnimationConfig {
|
|
2367
|
+
/** Node/edge reveal on first render. Default `{ duration: 500, ease: 'smooth', stagger: true }`. */
|
|
2368
|
+
enter?: AnimationPhaseConfig | boolean;
|
|
2369
|
+
/** Data-update enter-fade for newly added marks. Default `{ duration: 300, ease: 'smooth' }`. */
|
|
2370
|
+
update?: AnimationPhaseConfig | boolean;
|
|
2371
|
+
/** Ghost fade-out for removed marks. Default `{ duration: 300, ease: 'smooth' }`. */
|
|
2372
|
+
exit?: AnimationPhaseConfig | boolean;
|
|
2373
|
+
/** Camera flight easing. Default duration `'auto'` (derived from the zoom distance). */
|
|
2374
|
+
camera?: {
|
|
2375
|
+
duration?: number;
|
|
2376
|
+
ease?: AnimationEase;
|
|
2377
|
+
} | boolean;
|
|
2378
|
+
/** Hover emphasis crossfade. Default `{ duration: 150, ease: 'smooth' }`. */
|
|
2379
|
+
hover?: {
|
|
2380
|
+
duration?: number;
|
|
2381
|
+
ease?: AnimationEase;
|
|
2382
|
+
} | boolean;
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Graph motion spec.
|
|
2386
|
+
* - omitted → full defaults (default-ON)
|
|
2387
|
+
* - `false` → no choreography (warmup still applies)
|
|
2388
|
+
* - object → per-phase control
|
|
2389
|
+
*
|
|
2390
|
+
* `prefers-reduced-motion` is always respected regardless of this value.
|
|
2391
|
+
*/
|
|
2392
|
+
type GraphAnimationSpec = boolean | GraphAnimationConfig;
|
|
2393
|
+
/** Interaction behavior for a graph (hover mode, select-fly, opt-in physics). */
|
|
2394
|
+
interface GraphInteractionConfig {
|
|
2395
|
+
/**
|
|
2396
|
+
* Hover emphasis behavior. `neighbors` (default) lights the hovered node and
|
|
2397
|
+
* its adjacency; `category` lights same-category nodes; `node` lights only the
|
|
2398
|
+
* hovered node; `none` disables. `dimOpacity` (default 0.15) is the node dim
|
|
2399
|
+
* tier. Named `mode` (not `highlight`) to avoid colliding with the three other
|
|
2400
|
+
* meanings of "highlight" (the encoding value list, the `highlight()` verb).
|
|
2401
|
+
*/
|
|
2402
|
+
hover?: {
|
|
2403
|
+
mode?: 'neighbors' | 'category' | 'node' | 'none';
|
|
2404
|
+
dimOpacity?: number;
|
|
2405
|
+
};
|
|
2406
|
+
/** Selecting a node flies the camera to it. Default `false`. */
|
|
2407
|
+
select?: {
|
|
2408
|
+
flyTo?: boolean;
|
|
2409
|
+
};
|
|
2410
|
+
/**
|
|
2411
|
+
* Opt-in cursor repulsion (nodes drift away from the pointer). Disabled under
|
|
2412
|
+
* `prefers-reduced-motion` and above the node-count gate.
|
|
2413
|
+
*/
|
|
2414
|
+
cursorRepulsion?: boolean | {
|
|
2415
|
+
radius?: number;
|
|
2416
|
+
strength?: number;
|
|
2417
|
+
};
|
|
2418
|
+
/** Opt-in springy node drag (user-initiated; no reduced-motion gate). */
|
|
2419
|
+
springyDrag?: boolean;
|
|
2420
|
+
}
|
|
2203
2421
|
interface GraphSpec {
|
|
2204
2422
|
/** Discriminant: always "graph". */
|
|
2205
2423
|
type: 'graph';
|
|
@@ -2221,6 +2439,21 @@ interface GraphSpec {
|
|
|
2221
2439
|
theme?: ThemeConfig;
|
|
2222
2440
|
/** Dark mode behavior. */
|
|
2223
2441
|
darkMode?: DarkMode;
|
|
2442
|
+
/**
|
|
2443
|
+
* Motion configuration. DEFAULT-ON: omit for full defaults, `false` to opt
|
|
2444
|
+
* out of choreography (layout warmup still applies).
|
|
2445
|
+
*/
|
|
2446
|
+
animation?: GraphAnimationSpec;
|
|
2447
|
+
/** Interaction behavior (hover mode, select-fly, opt-in physics). */
|
|
2448
|
+
interaction?: GraphInteractionConfig;
|
|
2449
|
+
/**
|
|
2450
|
+
* Built-in legend. Interactive by default. Set `false` if you render your own
|
|
2451
|
+
* legend, so the built-in filter UI doesn't compete with it.
|
|
2452
|
+
*/
|
|
2453
|
+
legend?: boolean | {
|
|
2454
|
+
interactive?: boolean;
|
|
2455
|
+
counts?: boolean;
|
|
2456
|
+
};
|
|
2224
2457
|
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
2225
2458
|
watermark?: boolean;
|
|
2226
2459
|
}
|
|
@@ -2446,32 +2679,32 @@ interface TileMapSpec {
|
|
|
2446
2679
|
valueFormat?: string;
|
|
2447
2680
|
}
|
|
2448
2681
|
/** Supported map projections. */
|
|
2449
|
-
type
|
|
2682
|
+
type GeoMapProjection = 'albersUsa' | 'mercator' | 'equalEarth' | 'identity';
|
|
2450
2683
|
/** Focus target for map camera: feature id(s) to zoom/pan to. */
|
|
2451
2684
|
/**
|
|
2452
2685
|
* Fit the point layer's cluster. `true` fits every point; `{ field, value }`
|
|
2453
2686
|
* fits only the points whose data row has `row[field] === value` (e.g. only the
|
|
2454
2687
|
* campuses rated "F"), which lets a story pan between sub-clusters.
|
|
2455
2688
|
*/
|
|
2456
|
-
type
|
|
2689
|
+
type GeoMapPointsFocus = true | {
|
|
2457
2690
|
field: string;
|
|
2458
2691
|
value: string | number;
|
|
2459
2692
|
};
|
|
2460
|
-
type
|
|
2693
|
+
type GeoMapFocus = string | number | Array<string | number> | {
|
|
2461
2694
|
features: string | number | Array<string | number>;
|
|
2462
2695
|
padding?: number;
|
|
2463
2696
|
} | {
|
|
2464
|
-
points:
|
|
2697
|
+
points: GeoMapPointsFocus;
|
|
2465
2698
|
padding?: number;
|
|
2466
2699
|
};
|
|
2467
2700
|
/** Geo configuration for map specs. */
|
|
2468
|
-
interface
|
|
2701
|
+
interface GeoMapGeo {
|
|
2469
2702
|
/** TopoJSON topology object. User imports this from us-atlas, world-atlas, or their own source. */
|
|
2470
2703
|
features: unknown;
|
|
2471
2704
|
/** Field in the TopoJSON feature properties to use as the join key. Defaults to 'id'. */
|
|
2472
2705
|
idField?: string;
|
|
2473
2706
|
/** Map projection. Defaults to 'albersUsa'. */
|
|
2474
|
-
projection?:
|
|
2707
|
+
projection?: GeoMapProjection;
|
|
2475
2708
|
/**
|
|
2476
2709
|
* Focus the camera. A feature id (or array) fits those features; `{ features, padding }`
|
|
2477
2710
|
* adds breathing room; `{ points: true, padding }` fits the points layer's cluster
|
|
@@ -2480,10 +2713,10 @@ interface MapGeo {
|
|
|
2480
2713
|
* `{ points: { field, value }, padding }` fits only the matching point subset, so a
|
|
2481
2714
|
* story can pan between sub-clusters. null clears focus from a prior story step.
|
|
2482
2715
|
*/
|
|
2483
|
-
focus?:
|
|
2716
|
+
focus?: GeoMapFocus | null;
|
|
2484
2717
|
}
|
|
2485
2718
|
/** Encoding channels specific to map visualizations. */
|
|
2486
|
-
interface
|
|
2719
|
+
interface GeoMapEncoding {
|
|
2487
2720
|
/** Join key field in the data. Required for choropleth; optional in basemap-only mode (points layer with empty data). */
|
|
2488
2721
|
key?: EncodingChannel;
|
|
2489
2722
|
/** Color encoding (quantitative or nominal). Drives fill color of features. Optional when a points layer is present (basemap-only mode). */
|
|
@@ -2492,7 +2725,7 @@ interface MapEncoding {
|
|
|
2492
2725
|
tooltip?: EncodingChannel | EncodingChannel[];
|
|
2493
2726
|
}
|
|
2494
2727
|
/** Point/symbol layer rendered above choropleth features. */
|
|
2495
|
-
interface
|
|
2728
|
+
interface GeoMapPointsLayer {
|
|
2496
2729
|
/** Tabular data for the points. Independent of the choropleth data join. */
|
|
2497
2730
|
data: DataRow[];
|
|
2498
2731
|
/** Field holding longitude (x coordinate). */
|
|
@@ -2503,22 +2736,23 @@ interface MapPointsLayer {
|
|
|
2503
2736
|
size?: EncodingChannel;
|
|
2504
2737
|
/** Optional color encoding (nominal or quantitative). Independent scale from choropleth. */
|
|
2505
2738
|
color?: EncodingChannel;
|
|
2506
|
-
/** Tooltip channel(s), same shape as
|
|
2739
|
+
/** Tooltip channel(s), same shape as GeoMapEncoding.tooltip. */
|
|
2507
2740
|
tooltip?: EncodingChannel | EncodingChannel[];
|
|
2508
|
-
/** Stable id for event callbacks
|
|
2741
|
+
/** Stable id for event callbacks, and the key used to match points across
|
|
2742
|
+
* renders so fill, radius, and position tween on data update. */
|
|
2509
2743
|
key?: EncodingChannel;
|
|
2510
2744
|
/** Fill opacity for point circles. Default 0.65. Range 0-1. */
|
|
2511
2745
|
opacity?: number;
|
|
2512
2746
|
}
|
|
2513
|
-
interface
|
|
2747
|
+
interface GeoMapSpec {
|
|
2514
2748
|
/** Discriminant: always "map". */
|
|
2515
2749
|
type: 'map';
|
|
2516
2750
|
/** Geo configuration: TopoJSON features, join key, and projection. */
|
|
2517
|
-
geo:
|
|
2751
|
+
geo: GeoMapGeo;
|
|
2518
2752
|
/** Tabular data to join to geo features. */
|
|
2519
2753
|
data: DataRow[];
|
|
2520
2754
|
/** Encoding channels mapping data fields to visual properties. */
|
|
2521
|
-
encoding:
|
|
2755
|
+
encoding: GeoMapEncoding;
|
|
2522
2756
|
/** Editorial chrome (title, subtitle, source, byline, footer). */
|
|
2523
2757
|
chrome?: Chrome;
|
|
2524
2758
|
/** Legend display configuration. */
|
|
@@ -2530,7 +2764,7 @@ interface MapSpec {
|
|
|
2530
2764
|
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
2531
2765
|
watermark?: boolean;
|
|
2532
2766
|
/** Optional point/symbol layer rendered above choropleth features. */
|
|
2533
|
-
points?:
|
|
2767
|
+
points?: GeoMapPointsLayer;
|
|
2534
2768
|
/** Animation configuration for entrance animations. */
|
|
2535
2769
|
animation?: AnimationSpec;
|
|
2536
2770
|
/**
|
|
@@ -2595,7 +2829,7 @@ interface BarListEncoding {
|
|
|
2595
2829
|
* - GraphSpec: has `type: 'graph'`
|
|
2596
2830
|
* - SankeySpec: has `type: 'sankey'`
|
|
2597
2831
|
* - TileMapSpec: has `type: 'tilemap'`
|
|
2598
|
-
* -
|
|
2832
|
+
* - GeoMapSpec: has `type: 'map'`
|
|
2599
2833
|
* - BarListSpec: has `type: 'barlist'`
|
|
2600
2834
|
*
|
|
2601
2835
|
* Election parliament (hemicycle) charts are `ChartSpec` with `mark:
|
|
@@ -2605,7 +2839,7 @@ interface BarListEncoding {
|
|
|
2605
2839
|
* for free instead of a second bespoke compile path (see
|
|
2606
2840
|
* `packages/engine/src/charts/parliament/`).
|
|
2607
2841
|
*/
|
|
2608
|
-
type VizSpec = ChartSpec | LayerSpec | TableSpec | GraphSpec | SankeySpec | TileMapSpec |
|
|
2842
|
+
type VizSpec = ChartSpec | LayerSpec | TableSpec | GraphSpec | SankeySpec | TileMapSpec | GeoMapSpec | BarListSpec;
|
|
2609
2843
|
/**
|
|
2610
2844
|
* Chart spec without runtime data, for persistence/storage.
|
|
2611
2845
|
* Generic: `ChartSpecWithoutData<MyRow>` constrains encoding field names.
|
|
@@ -2620,13 +2854,13 @@ type SankeySpecWithoutData = Omit<SankeySpec, 'data'>;
|
|
|
2620
2854
|
/** TileMap spec without runtime data, for persistence/storage. */
|
|
2621
2855
|
type TileMapSpecWithoutData = Omit<TileMapSpec, 'data'>;
|
|
2622
2856
|
/** Map spec without runtime data, for persistence/storage. */
|
|
2623
|
-
type
|
|
2624
|
-
points?: Omit<
|
|
2857
|
+
type GeoMapSpecWithoutData = Omit<GeoMapSpec, 'data' | 'points'> & {
|
|
2858
|
+
points?: Omit<GeoMapPointsLayer, 'data'>;
|
|
2625
2859
|
};
|
|
2626
2860
|
/** BarList spec without runtime data, for persistence/storage. */
|
|
2627
2861
|
type BarListSpecWithoutData = Omit<BarListSpec, 'data'>;
|
|
2628
2862
|
/** Union of data-stripped spec types for persistence/storage. */
|
|
2629
|
-
type StoredVizSpec = ChartSpecWithoutData | TableSpecWithoutData | GraphSpecWithoutData | SankeySpecWithoutData | TileMapSpecWithoutData |
|
|
2863
|
+
type StoredVizSpec = ChartSpecWithoutData | TableSpecWithoutData | GraphSpecWithoutData | SankeySpecWithoutData | TileMapSpecWithoutData | GeoMapSpecWithoutData | BarListSpecWithoutData;
|
|
2630
2864
|
/** Logical AND combinator for filter predicates. */
|
|
2631
2865
|
interface LogicalAnd<T> {
|
|
2632
2866
|
and: T[];
|
|
@@ -2855,8 +3089,8 @@ declare function isSankeySpec(spec: VizSpec | Record<string, unknown>): spec is
|
|
|
2855
3089
|
declare function isTileMapSpec(spec: VizSpec | Record<string, unknown>): spec is TileMapSpec;
|
|
2856
3090
|
/** Check if a spec is a BarListSpec. */
|
|
2857
3091
|
declare function isBarListSpec(spec: VizSpec | Record<string, unknown>): spec is BarListSpec;
|
|
2858
|
-
/** Check if a spec is a
|
|
2859
|
-
declare function
|
|
3092
|
+
/** Check if a spec is a GeoMapSpec. */
|
|
3093
|
+
declare function isGeoMapSpec(spec: VizSpec | Record<string, unknown>): spec is GeoMapSpec;
|
|
2860
3094
|
/** Check if an annotation is a TextAnnotation. */
|
|
2861
3095
|
declare function isTextAnnotation(annotation: Annotation): annotation is TextAnnotation;
|
|
2862
3096
|
/** Check if an annotation is a RangeAnnotation. */
|
|
@@ -3201,6 +3435,12 @@ interface ResolvedChromeElement {
|
|
|
3201
3435
|
y: number;
|
|
3202
3436
|
/** Maximum width for line wrapping. */
|
|
3203
3437
|
maxWidth: number;
|
|
3438
|
+
/**
|
|
3439
|
+
* Maximum wrapped lines. When set, the renderer caps the wrapped output to
|
|
3440
|
+
* this many lines and truncates the last kept line with an ellipsis. The
|
|
3441
|
+
* layout height reserved for this element already reflects the cap.
|
|
3442
|
+
*/
|
|
3443
|
+
maxLines?: number;
|
|
3204
3444
|
/** Computed text style. */
|
|
3205
3445
|
style: TextStyle;
|
|
3206
3446
|
}
|
|
@@ -3809,6 +4049,8 @@ interface LegendEntry {
|
|
|
3809
4049
|
active?: boolean;
|
|
3810
4050
|
/** True for overflow indicator entries ("+N more"). Not interactive. */
|
|
3811
4051
|
overflow?: boolean;
|
|
4052
|
+
/** Node/edge count for this category (graph legends). Additive; undefined elsewhere. */
|
|
4053
|
+
count?: number;
|
|
3812
4054
|
}
|
|
3813
4055
|
/** The encoding channel a legend keys. */
|
|
3814
4056
|
type LegendChannel = 'color' | 'size';
|
|
@@ -4047,6 +4289,12 @@ interface A11yMetadata {
|
|
|
4047
4289
|
altText: string;
|
|
4048
4290
|
/** Tabular data fallback for screen readers. Each inner array is a row. */
|
|
4049
4291
|
dataTableFallback: unknown[][];
|
|
4292
|
+
/**
|
|
4293
|
+
* True row count of the underlying data. Only set when `dataTableFallback`
|
|
4294
|
+
* was truncated, so its presence is the signal that rows are missing and the
|
|
4295
|
+
* caption should name the total.
|
|
4296
|
+
*/
|
|
4297
|
+
totalRows?: number;
|
|
4050
4298
|
/** ARIA role for the visualization root element. */
|
|
4051
4299
|
role: string;
|
|
4052
4300
|
/** Whether the visualization is keyboard-navigable. */
|
|
@@ -4069,6 +4317,12 @@ interface ResolvedAnimationPhase {
|
|
|
4069
4317
|
staggerDelay: number;
|
|
4070
4318
|
/** Stagger ordering. */
|
|
4071
4319
|
staggerOrder: 'index' | 'value' | 'reverse';
|
|
4320
|
+
/**
|
|
4321
|
+
* Author-set cap on the mark count that still runs a tweened data-update
|
|
4322
|
+
* transition (update phase only). Present only when explicitly set on the
|
|
4323
|
+
* spec — the renderer supplies the default so it can vary by render mode.
|
|
4324
|
+
*/
|
|
4325
|
+
maxMarks?: number;
|
|
4072
4326
|
}
|
|
4073
4327
|
/** Resolved animation config. A phase is present iff that phase is enabled. */
|
|
4074
4328
|
interface ResolvedAnimation {
|
|
@@ -4226,6 +4480,7 @@ interface FacetPanelLayout {
|
|
|
4226
4480
|
y: number;
|
|
4227
4481
|
fontSize: number;
|
|
4228
4482
|
fontWeight: number;
|
|
4483
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
4229
4484
|
};
|
|
4230
4485
|
}
|
|
4231
4486
|
/** Layout for a faceted (small-multiples) chart. */
|
|
@@ -4238,6 +4493,8 @@ interface FacetLayout {
|
|
|
4238
4493
|
columns: number;
|
|
4239
4494
|
/** Whether scales are shared across panels. */
|
|
4240
4495
|
sharedScales: boolean;
|
|
4496
|
+
/** How panels are arranged: 'row' (vertical stack), 'column' (horizontal), 'wrap' (grid). */
|
|
4497
|
+
direction: 'row' | 'column' | 'wrap';
|
|
4241
4498
|
}
|
|
4242
4499
|
/**
|
|
4243
4500
|
* ChartLayout: the complete engine output for chart visualizations.
|
|
@@ -4318,6 +4575,16 @@ interface ChartLayout {
|
|
|
4318
4575
|
yInvert?: ScaleInvert;
|
|
4319
4576
|
/** Faceted (small-multiples) layout. When present, renderers iterate panels instead of using top-level marks/axes. */
|
|
4320
4577
|
facet?: FacetLayout;
|
|
4578
|
+
/**
|
|
4579
|
+
* Resolved rendering backend for point marks. Absent means `'svg'`.
|
|
4580
|
+
*
|
|
4581
|
+
* ADVISORY metadata only: it tells the mount and export layers that a canvas
|
|
4582
|
+
* mark layer is worth creating for this layout. The SVG renderer keys solely
|
|
4583
|
+
* on its own `canvasMarks` render option and never reads this field, so a
|
|
4584
|
+
* server-side or export render of a canvas-mode layout still produces
|
|
4585
|
+
* full-fidelity SVG.
|
|
4586
|
+
*/
|
|
4587
|
+
markRenderMode?: 'svg' | 'canvas';
|
|
4321
4588
|
}
|
|
4322
4589
|
/** A resolved column definition with computed properties. */
|
|
4323
4590
|
interface ResolvedColumn {
|
|
@@ -4733,7 +5000,7 @@ interface CompileWarning {
|
|
|
4733
5000
|
context?: Record<string, unknown>;
|
|
4734
5001
|
}
|
|
4735
5002
|
/** Resolved focus target for map camera framing. */
|
|
4736
|
-
interface
|
|
5003
|
+
interface GeoMapFocusLayout {
|
|
4737
5004
|
target: {
|
|
4738
5005
|
x: number;
|
|
4739
5006
|
y: number;
|
|
@@ -4744,7 +5011,7 @@ interface MapFocusLayout {
|
|
|
4744
5011
|
ids: Array<string | number>;
|
|
4745
5012
|
}
|
|
4746
5013
|
/** A resolved map feature mark with computed SVG path and fill. */
|
|
4747
|
-
interface
|
|
5014
|
+
interface GeoMapFeatureMark {
|
|
4748
5015
|
type: 'map-feature';
|
|
4749
5016
|
/** SVG path `d` attribute for this feature's shape. */
|
|
4750
5017
|
path: string;
|
|
@@ -4775,7 +5042,7 @@ interface MapFeatureMark {
|
|
|
4775
5042
|
centroid: [number, number];
|
|
4776
5043
|
}
|
|
4777
5044
|
/** A resolved map point mark with projected coordinates and visual properties. */
|
|
4778
|
-
interface
|
|
5045
|
+
interface GeoMapPointMark {
|
|
4779
5046
|
type: 'map-point';
|
|
4780
5047
|
/** Projected center x in map-local coordinates. */
|
|
4781
5048
|
cx: number;
|
|
@@ -4801,7 +5068,7 @@ interface MapPointMark {
|
|
|
4801
5068
|
animationIndex: number;
|
|
4802
5069
|
}
|
|
4803
5070
|
/** Border paths for the map (interior borders and coastline/outline). */
|
|
4804
|
-
interface
|
|
5071
|
+
interface GeoMapBorders {
|
|
4805
5072
|
/** SVG path `d` for interior borders between features. */
|
|
4806
5073
|
interiorPath: string;
|
|
4807
5074
|
/** SVG path `d` for the outer boundary / coastline. */
|
|
@@ -4812,23 +5079,23 @@ interface MapBorders {
|
|
|
4812
5079
|
outlineStroke: string;
|
|
4813
5080
|
}
|
|
4814
5081
|
/**
|
|
4815
|
-
*
|
|
5082
|
+
* GeoMapLayout: the complete engine output for map visualizations.
|
|
4816
5083
|
*
|
|
4817
5084
|
* Contains everything an adapter needs to render the map: dimensions,
|
|
4818
5085
|
* chrome, feature paths, borders, legend, tooltip descriptors, and
|
|
4819
5086
|
* accessibility metadata.
|
|
4820
5087
|
*/
|
|
4821
|
-
interface
|
|
5088
|
+
interface GeoMapLayout {
|
|
4822
5089
|
/** The map drawing area (after chrome and legend are subtracted). */
|
|
4823
5090
|
area: Rect;
|
|
4824
5091
|
/** Resolved chrome text elements with positions and styles. */
|
|
4825
5092
|
chrome: ResolvedChrome;
|
|
4826
5093
|
/** Resolved feature marks with paths, fills, and joined data. */
|
|
4827
|
-
features:
|
|
5094
|
+
features: GeoMapFeatureMark[];
|
|
4828
5095
|
/** Border paths (interior mesh and outline). */
|
|
4829
|
-
borders:
|
|
5096
|
+
borders: GeoMapBorders;
|
|
4830
5097
|
/** Resolved point marks for the symbol layer (empty array if no points layer). */
|
|
4831
|
-
pointMarks:
|
|
5098
|
+
pointMarks: GeoMapPointMark[];
|
|
4832
5099
|
/** Categorical legend for the point color channel (null if no point color). */
|
|
4833
5100
|
pointCategoricalLegend: CategoricalLegendLayout | null;
|
|
4834
5101
|
/** Continuous legend for the point color channel (null if no point color). */
|
|
@@ -4861,7 +5128,7 @@ interface MapLayout {
|
|
|
4861
5128
|
height: number;
|
|
4862
5129
|
};
|
|
4863
5130
|
/** Resolved focus target for camera framing (null if no focus). */
|
|
4864
|
-
focus:
|
|
5131
|
+
focus: GeoMapFocusLayout | null;
|
|
4865
5132
|
}
|
|
4866
5133
|
/** A resolved bar list row with computed positions and visual properties. */
|
|
4867
5134
|
interface BarListRowMark {
|
|
@@ -4952,6 +5219,14 @@ interface CompileOptions {
|
|
|
4952
5219
|
width: number;
|
|
4953
5220
|
/** Total available height in pixels. */
|
|
4954
5221
|
height: number;
|
|
5222
|
+
/**
|
|
5223
|
+
* How chrome height interacts with the height budget. Mirrors the spec-level
|
|
5224
|
+
* `chromeLayout`; the engine reads whichever is set (spec wins).
|
|
5225
|
+
*
|
|
5226
|
+
* - `'subtract'` (default): `height` is the fixed total; chrome shrinks the plot.
|
|
5227
|
+
* - `'grow'`: `height` is the plot budget; the SVG grows by the chrome height.
|
|
5228
|
+
*/
|
|
5229
|
+
chromeLayout?: 'subtract' | 'grow';
|
|
4955
5230
|
/** Theme overrides. */
|
|
4956
5231
|
theme?: ThemeConfig;
|
|
4957
5232
|
/**
|
|
@@ -4962,6 +5237,26 @@ interface CompileOptions {
|
|
|
4962
5237
|
* before calling compile. The engine always receives a resolved boolean.
|
|
4963
5238
|
*/
|
|
4964
5239
|
darkMode?: boolean;
|
|
5240
|
+
/**
|
|
5241
|
+
* Rendering backend for point marks, mirroring vega-embed's `renderer`
|
|
5242
|
+
* embed option: backend choice is host policy, not part of the spec.
|
|
5243
|
+
* High-cardinality scatter plots draw thousands of SVG circles, which is
|
|
5244
|
+
* what makes their entrance and update transitions stutter; a canvas layer
|
|
5245
|
+
* draws the same dots in a handful of batched paint calls.
|
|
5246
|
+
*
|
|
5247
|
+
* - `'auto'` (default): canvas above 1,000 compiled point marks, SVG below.
|
|
5248
|
+
* - `'svg'`: always SVG, whatever the point count.
|
|
5249
|
+
* - `'canvas'`: always canvas, whatever the point count.
|
|
5250
|
+
*
|
|
5251
|
+
* Canvas mode trades per-mark keyboard focus and edit-mode point selection
|
|
5252
|
+
* (the screen-reader data table still carries every row), and draws the
|
|
5253
|
+
* trendline above the dots even when `trendline.layer` is `'below'`.
|
|
5254
|
+
* Tooltips, hover, and click callbacks work the same in both modes.
|
|
5255
|
+
*
|
|
5256
|
+
* Ignored with a console warning for non-point marks, and for faceted,
|
|
5257
|
+
* layered, and sparkline charts.
|
|
5258
|
+
*/
|
|
5259
|
+
renderer?: 'auto' | 'svg' | 'canvas';
|
|
4965
5260
|
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
4966
5261
|
watermark?: boolean;
|
|
4967
5262
|
/**
|
|
@@ -5010,6 +5305,13 @@ interface CompileOptions {
|
|
|
5010
5305
|
* different area than the one the axes are rendered in.
|
|
5011
5306
|
*/
|
|
5012
5307
|
frozenChartArea?: Rect;
|
|
5308
|
+
/**
|
|
5309
|
+
* Marks this compile as one leaf (or the primary spec) of a multi-leaf layer.
|
|
5310
|
+
* Set by compileLayer; callers should not set it. Only consumer today is the
|
|
5311
|
+
* canvas mark-layer resolution, which refuses canvas mode for layered charts
|
|
5312
|
+
* because the layer layout concatenates marks from several compiles.
|
|
5313
|
+
*/
|
|
5314
|
+
layered?: boolean;
|
|
5013
5315
|
}
|
|
5014
5316
|
/** Extended compile options for table visualizations. */
|
|
5015
5317
|
interface CompileTableOptions extends CompileOptions {
|
|
@@ -5530,12 +5832,20 @@ declare function computeXAxisExtentFromLabels(input: XAxisExtentInput): number;
|
|
|
5530
5832
|
*/
|
|
5531
5833
|
declare function maxRotatedLabelWidth(tickAngle: number, tickFontSize: number): number;
|
|
5532
5834
|
/**
|
|
5533
|
-
* Truncate a
|
|
5534
|
-
*
|
|
5835
|
+
* Truncate a label with an ellipsis so it fits inside an explicit pixel budget.
|
|
5836
|
+
* Returns the label unchanged when it already fits.
|
|
5535
5837
|
*
|
|
5536
5838
|
* Binary-search on character count against the real measure function, so it
|
|
5537
5839
|
* respects proportional fonts rather than assuming a fixed character width.
|
|
5538
5840
|
*/
|
|
5841
|
+
declare function truncateToWidth(label: string, budget: number, fontSize: number, fontWeight: number, measure?: (text: string, fontSize: number, fontWeight?: number) => number): string;
|
|
5842
|
+
/**
|
|
5843
|
+
* Truncate a rotated tick label with an ellipsis so it fits inside the capped
|
|
5844
|
+
* reservation. Returns the label unchanged when it already fits.
|
|
5845
|
+
*
|
|
5846
|
+
* Delegates to `truncateToWidth` with the budget derived from the rotation
|
|
5847
|
+
* geometry, so the binary-search stays in one place.
|
|
5848
|
+
*/
|
|
5539
5849
|
declare function truncateRotatedLabel(label: string, tickAngle: number, tickFontSize: number, tickFontWeight: number, measure?: (text: string, fontSize: number, fontWeight?: number) => number): string;
|
|
5540
5850
|
|
|
5541
5851
|
/**
|
|
@@ -5712,12 +6022,22 @@ declare function buildTemporalFormatter(formatStr: string | undefined): ((value:
|
|
|
5712
6022
|
* @param data - The data array.
|
|
5713
6023
|
*/
|
|
5714
6024
|
declare function generateAltText(spec: ChartSpec, data: DataRow[]): string;
|
|
6025
|
+
/**
|
|
6026
|
+
* Maximum number of data rows in the screen-reader table. A 50k-point scatter
|
|
6027
|
+
* would otherwise put 50k hidden rows in the DOM.
|
|
6028
|
+
*/
|
|
6029
|
+
declare const MAX_SR_TABLE_ROWS = 1000;
|
|
5715
6030
|
/**
|
|
5716
6031
|
* Generate a tabular data fallback for screen readers.
|
|
5717
6032
|
*
|
|
5718
6033
|
* Returns a 2D array where the first row is headers and subsequent
|
|
5719
6034
|
* rows are data values. Only includes fields referenced in the encoding.
|
|
5720
6035
|
*
|
|
6036
|
+
* Data rows are capped at MAX_SR_TABLE_ROWS (the header row does not count
|
|
6037
|
+
* against the cap). SCOPE: this caps the chart compile path only. Graph,
|
|
6038
|
+
* sankey, tilemap and map build their `dataTableFallback` independently and
|
|
6039
|
+
* stay uncapped.
|
|
6040
|
+
*
|
|
5721
6041
|
* @param spec - The chart spec.
|
|
5722
6042
|
* @param data - The data array.
|
|
5723
6043
|
*/
|
|
@@ -5970,4 +6290,4 @@ declare const CSS_TOKEN_ROOT_SELECTORS: readonly string[];
|
|
|
5970
6290
|
declare const CSS_TOKENS: readonly CssTokenDef[];
|
|
5971
6291
|
declare function cssTokenDefault(name: string, mode: 'light' | 'dark'): string;
|
|
5972
6292
|
|
|
5973
|
-
export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type ImageColumnConfig, type ImageTableCell, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
|
|
6293
|
+
export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GeoMapBorders, type GeoMapEncoding, type GeoMapFeatureMark, type GeoMapFocus, type GeoMapFocusLayout, type GeoMapGeo, type GeoMapLayout, type GeoMapPointMark, type GeoMapPointsLayer, type GeoMapProjection, type GeoMapSpec, type GeoMapSpecWithoutData, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphAnimationConfig, type GraphAnimationSpec, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphInteractionConfig, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type ImageColumnConfig, type ImageTableCell, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX, MAX_SR_TABLE_ROWS, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NodeOverride, type NumberFormatter, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type ParliamentEncoding, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type RangeEncoding, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnimationPhase, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedFillPattern, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedSeriesSearch, type ResolvedTheme, type ResolvedYouDrawIt, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, SUPPORTED_SCHEME_NAMES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleInvert, type ScaleType, type SequentialPalette, type SeriesSearchConfig, type SeriesStrategy, type SeriesStyle, type SizeLegendCircle, type SizeLegendLayout, type SortByField, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, TICK_LINE_HEIGHT_FACTOR, TOP_PAD_EXTRA_NARROW, TOP_PAD_NARROW_MAX, type TableBuilderOptions, type TableCell, type TableCellBase, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TextAnnotation, type TextEncoding, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeSpacing, type TickEncoding, type TickMarkLayout, type TileMapBuilderOptions, type TileMapEncoding, type TileMapLayout, type TileMapPalette, type TileMapSpec, type TileMapSpecWithoutData, type TileMapTileMark, type TimeUnit, type TimeUnitTransform, type TokenValue, type TooltipContent, type TooltipField, type Transform, type UpdatePhaseConfig, type ValueDef, type VizSpec, type WaffleEncoding, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_ROTATED_EXTENT_CAP, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, type YouDrawItConfig, type YouDrawItSample, type YouDrawItYInvert, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, buildCompactStepFormatter, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeFieldFormatContext, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, cssTokenDefault, dataTable, deepMergeSpec, defaultNumberFormatter, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, footnoteBandHeight, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPercent, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isAxislessMark, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGeoMapSpec, isGradientDef, isGraphSpec, isLayerSpec, isOpaqueColor, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, isValueDef, isYearContext, lineChart, maxRotatedLabelWidth, meetsAA, overlapArea, pickLabelColor, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveNumberFormatter, resolveSchemeName, resolveTheme, scatterChart, simulateColorBlindness, textAscent, tileMap, truncateRotatedLabel, truncateToWidth, wire, wrapText };
|