@opendata-ai/openchart-core 7.6.1 → 7.8.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 +468 -179
- package/dist/index.js +155 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/colors/palettes.ts +3 -3
- package/src/helpers/spec-builders.ts +5 -2
- package/src/index.ts +5 -0
- package/src/styles/dark.css +5 -1
- package/src/styles/tokens.css +6 -0
- package/src/theme/__tests__/dark-mode.test.ts +80 -0
- package/src/theme/__tests__/resolve.test.ts +114 -0
- package/src/theme/dark-mode.ts +56 -26
- package/src/theme/defaults.ts +2 -1
- package/src/theme/index.ts +1 -0
- package/src/theme/presets.ts +64 -0
- package/src/theme/resolve.ts +85 -12
- package/src/types/index.ts +8 -0
- package/src/types/layout.ts +57 -1
- package/src/types/spec.ts +158 -29
- package/src/types/theme.ts +36 -0
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,183 @@ interface ColumnConfig {
|
|
|
159
159
|
autoAssign?: boolean;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Theme types: color palettes, typography, spacing, and chrome defaults.
|
|
164
|
+
*
|
|
165
|
+
* Theme is the user-facing partial config (all optional).
|
|
166
|
+
* ResolvedTheme is the engine-internal fully resolved version (no optionals).
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* A color token value: either a plain CSS color string, or a light/dark pair.
|
|
170
|
+
* When a pair is given, the resolver picks the appropriate value based on
|
|
171
|
+
* dark mode state. When a plain string is given, dark-mode adaptation
|
|
172
|
+
* derives the dark value algorithmically (existing behavior).
|
|
173
|
+
*/
|
|
174
|
+
type TokenValue = string | {
|
|
175
|
+
light: string;
|
|
176
|
+
dark: string;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Series color assignment strategy.
|
|
180
|
+
*
|
|
181
|
+
* - `'palette'` — always assign from the full categorical palette (current
|
|
182
|
+
* default, zero visual drift).
|
|
183
|
+
* - `'accent-neutral'` — assign by series count: a single series gets the
|
|
184
|
+
* accent (first categorical color) only; 2-4 series get accent for the
|
|
185
|
+
* first and neutral grays for the rest; 5+ fall back to the full palette.
|
|
186
|
+
*/
|
|
187
|
+
type SeriesStrategy = 'palette' | 'accent-neutral';
|
|
188
|
+
/** Color palettes for the visualization. */
|
|
189
|
+
interface ThemeColors {
|
|
190
|
+
/** Categorical palette for nominal data. Array of CSS color strings. */
|
|
191
|
+
categorical: string[];
|
|
192
|
+
/** Sequential palettes keyed by name. Each is an array of color stops from light to dark. */
|
|
193
|
+
sequential: Record<string, string[]>;
|
|
194
|
+
/** Diverging palettes keyed by name. Each is an array of color stops with a neutral midpoint. */
|
|
195
|
+
diverging: Record<string, string[]>;
|
|
196
|
+
/** Background color for the visualization container. */
|
|
197
|
+
background: string;
|
|
198
|
+
/** Default text color. */
|
|
199
|
+
text: string;
|
|
200
|
+
/** Gridline color. */
|
|
201
|
+
gridline: string;
|
|
202
|
+
/** Axis line and tick color. */
|
|
203
|
+
axis: string;
|
|
204
|
+
/** Annotation fill color. */
|
|
205
|
+
annotationFill: string;
|
|
206
|
+
/** Annotation text color. */
|
|
207
|
+
annotationText: string;
|
|
208
|
+
/** Semantic color for positive/up-trend values (e.g. sparkline trend coloring). */
|
|
209
|
+
positive: string;
|
|
210
|
+
/** Semantic color for negative/down-trend values (e.g. sparkline trend coloring). */
|
|
211
|
+
negative: string;
|
|
212
|
+
}
|
|
213
|
+
/** Font size presets for the typography scale. */
|
|
214
|
+
interface ThemeFontSizes {
|
|
215
|
+
/** Title font size in pixels. */
|
|
216
|
+
title: number;
|
|
217
|
+
/** Subtitle font size in pixels. */
|
|
218
|
+
subtitle: number;
|
|
219
|
+
/** Body/label font size in pixels. */
|
|
220
|
+
body: number;
|
|
221
|
+
/** Small text (source, footer) font size in pixels. */
|
|
222
|
+
small: number;
|
|
223
|
+
/** Axis tick label font size in pixels. */
|
|
224
|
+
axisTick: number;
|
|
225
|
+
/** KPI metric uppercase label font size in pixels. */
|
|
226
|
+
metricLabel: number;
|
|
227
|
+
/** KPI metric primary value font size in pixels. The delta and secondary
|
|
228
|
+
* values derive from this (each ~0.55x), so scaling this scales the whole cell. */
|
|
229
|
+
metricValue: number;
|
|
230
|
+
}
|
|
231
|
+
/** Font weight presets. */
|
|
232
|
+
interface ThemeFontWeights {
|
|
233
|
+
/** Normal text weight. */
|
|
234
|
+
normal: number;
|
|
235
|
+
/** Medium text weight (subtitles). */
|
|
236
|
+
medium: number;
|
|
237
|
+
/** Semibold text weight (titles). */
|
|
238
|
+
semibold: number;
|
|
239
|
+
/** Bold text weight. */
|
|
240
|
+
bold: number;
|
|
241
|
+
}
|
|
242
|
+
/** Complete typography configuration. */
|
|
243
|
+
interface ThemeFonts {
|
|
244
|
+
/** Primary font family. */
|
|
245
|
+
family: string;
|
|
246
|
+
/** Monospace font family (for tabular numbers). */
|
|
247
|
+
mono: string;
|
|
248
|
+
/** Font sizes. */
|
|
249
|
+
sizes: ThemeFontSizes;
|
|
250
|
+
/** Font weights. */
|
|
251
|
+
weights: ThemeFontWeights;
|
|
252
|
+
}
|
|
253
|
+
/** Spacing configuration in pixels. */
|
|
254
|
+
interface ThemeSpacing {
|
|
255
|
+
/** Padding inside the visualization container (all sides). */
|
|
256
|
+
padding: number;
|
|
257
|
+
/** Gap between chrome elements (title to subtitle, subtitle to chart, etc.). */
|
|
258
|
+
chromeGap: number;
|
|
259
|
+
/** Gap between the last chrome element and the chart area. */
|
|
260
|
+
chromeToChart: number;
|
|
261
|
+
/** Gap between chart area and source/footer below. */
|
|
262
|
+
chartToFooter: number;
|
|
263
|
+
/** Internal padding within the chart area (axes margins). */
|
|
264
|
+
axisMargin: number;
|
|
265
|
+
/** Height reserved below the chart area for x-axis tick labels (and optional axis title). */
|
|
266
|
+
xAxisHeight: number;
|
|
267
|
+
/** Gap in pixels between the x-axis line and the top of non-rotated tick label text. */
|
|
268
|
+
xAxisLabelPadding: number;
|
|
269
|
+
}
|
|
270
|
+
/** Default style configuration for a chrome text element. */
|
|
271
|
+
interface ChromeDefaults {
|
|
272
|
+
/** Font size in pixels. */
|
|
273
|
+
fontSize: number;
|
|
274
|
+
/** Font weight. */
|
|
275
|
+
fontWeight: number;
|
|
276
|
+
/** Text color (CSS color string). */
|
|
277
|
+
color: string;
|
|
278
|
+
/** Line height multiplier. */
|
|
279
|
+
lineHeight: number;
|
|
280
|
+
}
|
|
281
|
+
/** Default chrome styles for each element type. */
|
|
282
|
+
interface ThemeChromeDefaults {
|
|
283
|
+
eyebrow: ChromeDefaults;
|
|
284
|
+
title: ChromeDefaults;
|
|
285
|
+
subtitle: ChromeDefaults;
|
|
286
|
+
source: ChromeDefaults;
|
|
287
|
+
byline: ChromeDefaults;
|
|
288
|
+
footer: ChromeDefaults;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Complete theme interface. Used internally after merging user overrides
|
|
292
|
+
* onto defaults. All fields are required here (this is what the engine
|
|
293
|
+
* works with).
|
|
294
|
+
*
|
|
295
|
+
* Users provide ThemeConfig (from spec.ts) which is the partial/optional
|
|
296
|
+
* version. The theme resolver deep-merges ThemeConfig onto the default Theme
|
|
297
|
+
* to produce a ResolvedTheme.
|
|
298
|
+
*/
|
|
299
|
+
interface Theme {
|
|
300
|
+
/** Color palettes. */
|
|
301
|
+
colors: ThemeColors;
|
|
302
|
+
/** Typography settings. */
|
|
303
|
+
fonts: ThemeFonts;
|
|
304
|
+
/** Spacing values in pixels. */
|
|
305
|
+
spacing: ThemeSpacing;
|
|
306
|
+
/** Border radius for containers and tooltips. */
|
|
307
|
+
borderRadius: number;
|
|
308
|
+
/** Default chrome text styles. */
|
|
309
|
+
chrome: ThemeChromeDefaults;
|
|
310
|
+
/** Series color assignment strategy. Default: 'palette' (full categorical). */
|
|
311
|
+
seriesStrategy: SeriesStrategy;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Fully resolved theme with no optional fields.
|
|
315
|
+
*
|
|
316
|
+
* This is the result of resolveTheme(): the default theme with user
|
|
317
|
+
* overrides deep-merged in. Every property is guaranteed to have a value.
|
|
318
|
+
* The engine uses ResolvedTheme internally so it never needs null checks.
|
|
319
|
+
*
|
|
320
|
+
* Structurally identical to Theme (both have all required fields), but
|
|
321
|
+
* exists as a separate type for semantic clarity: Theme is the default
|
|
322
|
+
* definition, ResolvedTheme is the runtime-resolved instance.
|
|
323
|
+
*/
|
|
324
|
+
interface ResolvedTheme extends Theme {
|
|
325
|
+
/** Whether dark mode adaptations have been applied to this theme. */
|
|
326
|
+
isDark: boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Original light/dark token pairs from the user's ThemeConfig. Used
|
|
329
|
+
* by adaptTheme() to skip algorithmic adaptation for tokens with
|
|
330
|
+
* explicit dark values. Engine-internal, not part of the public API.
|
|
331
|
+
* @internal
|
|
332
|
+
*/
|
|
333
|
+
_tokenPairs?: Record<string, {
|
|
334
|
+
light: string;
|
|
335
|
+
dark: string;
|
|
336
|
+
}>;
|
|
337
|
+
}
|
|
338
|
+
|
|
162
339
|
/**
|
|
163
340
|
* Spec types: the user-facing input contract.
|
|
164
341
|
*
|
|
@@ -489,6 +666,36 @@ interface EncodingChannel<TData extends DataRow = DataRow> {
|
|
|
489
666
|
* Used in tooltips; `axis.format` takes precedence for axis tick labels.
|
|
490
667
|
*/
|
|
491
668
|
format?: string;
|
|
669
|
+
/**
|
|
670
|
+
* Emphasis highlight for the color channel. Names one or more series values
|
|
671
|
+
* to visually emphasize; all other series are muted to a neutral gray.
|
|
672
|
+
*
|
|
673
|
+
* Only meaningful on the `color` encoding channel. On other channels this
|
|
674
|
+
* property is ignored.
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* encoding: {
|
|
678
|
+
* color: { field: 'region', type: 'nominal', highlight: 'West' }
|
|
679
|
+
* }
|
|
680
|
+
*/
|
|
681
|
+
highlight?: string | string[];
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Facet channel definition: partitions data into small-multiple panels.
|
|
685
|
+
*
|
|
686
|
+
* Unlike positional channels, facet only needs a field, a categorical type,
|
|
687
|
+
* and optional layout hints (columns, sort). It does not carry scale/axis
|
|
688
|
+
* config because it produces a grid, not a visual encoding.
|
|
689
|
+
*/
|
|
690
|
+
interface FacetChannel<TData extends DataRow = DataRow> {
|
|
691
|
+
/** Data field to partition by. Each unique value produces one panel. */
|
|
692
|
+
field: keyof TData & string;
|
|
693
|
+
/** Must be categorical. */
|
|
694
|
+
type: 'nominal' | 'ordinal';
|
|
695
|
+
/** Number of columns in the wrap grid. Auto-computed when omitted. */
|
|
696
|
+
columns?: number;
|
|
697
|
+
/** Sort order for panel values. Default ascending. */
|
|
698
|
+
sort?: 'ascending' | 'descending' | null;
|
|
492
699
|
}
|
|
493
700
|
/**
|
|
494
701
|
* Encoding object mapping visual channels to data fields.
|
|
@@ -583,6 +790,13 @@ interface Encoding<TData extends DataRow = DataRow> {
|
|
|
583
790
|
* Not used by any other mark type.
|
|
584
791
|
*/
|
|
585
792
|
radius?: EncodingChannel<TData>;
|
|
793
|
+
/**
|
|
794
|
+
* Facet channel: partitions data into a grid of small-multiple panels.
|
|
795
|
+
* Each unique value of the facet field produces one panel. Panels share
|
|
796
|
+
* scales by default; use `resolve: { scale: { y: 'independent' } }` for
|
|
797
|
+
* per-panel axes.
|
|
798
|
+
*/
|
|
799
|
+
facet?: FacetChannel<TData>;
|
|
586
800
|
}
|
|
587
801
|
/** Encoding channel for graph nodes and edges. */
|
|
588
802
|
interface GraphEncodingChannel {
|
|
@@ -727,6 +941,8 @@ interface TextAnnotation extends AnnotationBase {
|
|
|
727
941
|
y: string | number;
|
|
728
942
|
/** The annotation text. Required for text annotations. */
|
|
729
943
|
text: string;
|
|
944
|
+
/** Thinning priority (lower = kept longer at narrow widths). When omitted, spec order is used. */
|
|
945
|
+
priority?: number;
|
|
730
946
|
/**
|
|
731
947
|
* Optional muted second-tone text rendered below the primary `text`.
|
|
732
948
|
* Used for supporting context (e.g. methodology, source). Newlines in
|
|
@@ -843,6 +1059,20 @@ type Annotation = TextAnnotation | RangeAnnotation | RefLineAnnotation;
|
|
|
843
1059
|
* when no explicit prop is passed.
|
|
844
1060
|
*/
|
|
845
1061
|
type DarkMode = 'auto' | 'force' | 'off';
|
|
1062
|
+
/**
|
|
1063
|
+
* Per-element chrome theme override. Pass a plain string (color only,
|
|
1064
|
+
* backward-compatible) or an object with full typography control.
|
|
1065
|
+
*/
|
|
1066
|
+
interface ChromeThemeOverride {
|
|
1067
|
+
/** Text color. Accepts a TokenValue for light/dark pairs. */
|
|
1068
|
+
color?: TokenValue;
|
|
1069
|
+
/** Font size in pixels. */
|
|
1070
|
+
fontSize?: number;
|
|
1071
|
+
/** Font weight. */
|
|
1072
|
+
fontWeight?: number;
|
|
1073
|
+
/** Line height multiplier. */
|
|
1074
|
+
lineHeight?: number;
|
|
1075
|
+
}
|
|
846
1076
|
/**
|
|
847
1077
|
* User-facing theme configuration for overriding defaults.
|
|
848
1078
|
* All fields are optional. The engine deep-merges these onto the default theme.
|
|
@@ -860,14 +1090,22 @@ interface ThemeConfig {
|
|
|
860
1090
|
sequential?: Record<string, string[]>;
|
|
861
1091
|
/** Diverging palettes keyed by name. Each is an array of color stops with a neutral midpoint. */
|
|
862
1092
|
diverging?: Record<string, string[]>;
|
|
863
|
-
/** Background color. */
|
|
864
|
-
background?:
|
|
865
|
-
/** Default text color. */
|
|
866
|
-
text?:
|
|
867
|
-
/** Gridline color. */
|
|
868
|
-
gridline?:
|
|
869
|
-
/** Axis line and tick color. */
|
|
870
|
-
axis?:
|
|
1093
|
+
/** Background color. Accepts a TokenValue for light/dark pairs. */
|
|
1094
|
+
background?: TokenValue;
|
|
1095
|
+
/** Default text color. Accepts a TokenValue for light/dark pairs. */
|
|
1096
|
+
text?: TokenValue;
|
|
1097
|
+
/** Gridline color. Accepts a TokenValue for light/dark pairs. */
|
|
1098
|
+
gridline?: TokenValue;
|
|
1099
|
+
/** Axis line and tick color. Accepts a TokenValue for light/dark pairs. */
|
|
1100
|
+
axis?: TokenValue;
|
|
1101
|
+
/** Annotation fill color. Accepts a TokenValue for light/dark pairs. */
|
|
1102
|
+
annotationFill?: TokenValue;
|
|
1103
|
+
/** Annotation text color. Accepts a TokenValue for light/dark pairs. */
|
|
1104
|
+
annotationText?: TokenValue;
|
|
1105
|
+
/** Semantic color for positive/up-trend values. Accepts a TokenValue for light/dark pairs. */
|
|
1106
|
+
positive?: TokenValue;
|
|
1107
|
+
/** Semantic color for negative/down-trend values. Accepts a TokenValue for light/dark pairs. */
|
|
1108
|
+
negative?: TokenValue;
|
|
871
1109
|
};
|
|
872
1110
|
/** Font overrides. */
|
|
873
1111
|
fonts?: {
|
|
@@ -892,6 +1130,17 @@ interface ThemeConfig {
|
|
|
892
1130
|
/** KPI metric primary value. Default: 22. Delta/secondary derive from this. */
|
|
893
1131
|
metricValue?: number;
|
|
894
1132
|
};
|
|
1133
|
+
/** Font weight overrides. Partial — only specified keys are overridden. */
|
|
1134
|
+
weights?: {
|
|
1135
|
+
/** Normal text weight. Default: 450. */
|
|
1136
|
+
normal?: number;
|
|
1137
|
+
/** Medium text weight. Default: 550. */
|
|
1138
|
+
medium?: number;
|
|
1139
|
+
/** Semibold text weight. Default: 590. */
|
|
1140
|
+
semibold?: number;
|
|
1141
|
+
/** Bold text weight. Default: 700. */
|
|
1142
|
+
bold?: number;
|
|
1143
|
+
};
|
|
895
1144
|
};
|
|
896
1145
|
/** Spacing overrides in pixels. */
|
|
897
1146
|
spacing?: {
|
|
@@ -899,6 +1148,12 @@ interface ThemeConfig {
|
|
|
899
1148
|
padding?: number;
|
|
900
1149
|
/** Gap between chrome elements (title to subtitle, etc.). */
|
|
901
1150
|
chromeGap?: number;
|
|
1151
|
+
/** Gap between the last chrome element and the chart area. */
|
|
1152
|
+
chromeToChart?: number;
|
|
1153
|
+
/** Gap between chart area and source/footer below. */
|
|
1154
|
+
chartToFooter?: number;
|
|
1155
|
+
/** Internal padding within the chart area (axes margins). */
|
|
1156
|
+
axisMargin?: number;
|
|
902
1157
|
/** Height reserved below chart area for x-axis tick labels. Increase when large axisTick font sizes cause label clipping. */
|
|
903
1158
|
xAxisHeight?: number;
|
|
904
1159
|
/** Gap in pixels between the x-axis line and tick label text. Increase when larger axisTick fonts sit too close to the axis line. */
|
|
@@ -907,25 +1162,29 @@ interface ThemeConfig {
|
|
|
907
1162
|
/** Border radius for chart container and tooltips. */
|
|
908
1163
|
borderRadius?: number;
|
|
909
1164
|
/**
|
|
910
|
-
* Per-element chrome
|
|
911
|
-
*
|
|
912
|
-
*
|
|
913
|
-
* chrome color the spec set explicitly).
|
|
1165
|
+
* Per-element chrome style overrides. Pass a plain string for color-only
|
|
1166
|
+
* (backward-compatible), or a ChromeThemeOverride object for full
|
|
1167
|
+
* typography control (color, fontSize, fontWeight, lineHeight).
|
|
914
1168
|
*/
|
|
915
1169
|
chrome?: {
|
|
916
|
-
/** Eyebrow (kicker)
|
|
917
|
-
eyebrow?: string;
|
|
918
|
-
/** Title
|
|
919
|
-
title?: string;
|
|
920
|
-
/** Subtitle
|
|
921
|
-
subtitle?: string;
|
|
922
|
-
/** Source/attribution
|
|
923
|
-
source?: string;
|
|
924
|
-
/** Byline
|
|
925
|
-
byline?: string;
|
|
926
|
-
/** Footer
|
|
927
|
-
footer?: string;
|
|
1170
|
+
/** Eyebrow (kicker) style override. */
|
|
1171
|
+
eyebrow?: string | ChromeThemeOverride;
|
|
1172
|
+
/** Title style override. */
|
|
1173
|
+
title?: string | ChromeThemeOverride;
|
|
1174
|
+
/** Subtitle style override. */
|
|
1175
|
+
subtitle?: string | ChromeThemeOverride;
|
|
1176
|
+
/** Source/attribution style override. */
|
|
1177
|
+
source?: string | ChromeThemeOverride;
|
|
1178
|
+
/** Byline style override. */
|
|
1179
|
+
byline?: string | ChromeThemeOverride;
|
|
1180
|
+
/** Footer style override. */
|
|
1181
|
+
footer?: string | ChromeThemeOverride;
|
|
928
1182
|
};
|
|
1183
|
+
/**
|
|
1184
|
+
* Series color assignment strategy.
|
|
1185
|
+
* Default: 'palette' (full categorical palette always, zero visual drift).
|
|
1186
|
+
*/
|
|
1187
|
+
seriesStrategy?: SeriesStrategy;
|
|
929
1188
|
}
|
|
930
1189
|
/**
|
|
931
1190
|
* Label density mode controlling how many data labels are shown.
|
|
@@ -1000,6 +1259,14 @@ interface LegendConfig {
|
|
|
1000
1259
|
interface EndpointLabelsConfig {
|
|
1001
1260
|
/** Explicit on/off. When undefined, the chart auto-decides based on series count. */
|
|
1002
1261
|
show?: boolean;
|
|
1262
|
+
/** Maximum number of series before endpoint labels switch to a legend. Default 8. */
|
|
1263
|
+
maxSeries?: number;
|
|
1264
|
+
/**
|
|
1265
|
+
* Which ends of the chart get label columns.
|
|
1266
|
+
* - `'end'` (default): labels on the right (trailing) edge only.
|
|
1267
|
+
* - `'both'`: labels on both left (leading) and right (trailing) edges.
|
|
1268
|
+
*/
|
|
1269
|
+
ends?: 'end' | 'both';
|
|
1003
1270
|
/** Field to read the displayed value from. Defaults to `encoding.y.field`. */
|
|
1004
1271
|
valueField?: string;
|
|
1005
1272
|
/** d3-format string for the value. Defaults to `encoding.y.axis.format`. */
|
|
@@ -1049,6 +1316,16 @@ interface AnimationStagger {
|
|
|
1049
1316
|
/** Ordering strategy. Default: 'index' (DOM order) */
|
|
1050
1317
|
order?: 'index' | 'value' | 'reverse';
|
|
1051
1318
|
}
|
|
1319
|
+
/** Fine-grained responsive behavior configuration. */
|
|
1320
|
+
interface ResponsiveConfig {
|
|
1321
|
+
/**
|
|
1322
|
+
* Automatic annotation thinning at narrow widths. When true (default),
|
|
1323
|
+
* annotations that can't be placed without overlap are demoted to numbered
|
|
1324
|
+
* dot markers with footnote text below the chart. Set false to restore
|
|
1325
|
+
* the pre-auto-thinning behavior (annotations hidden at compact breakpoints).
|
|
1326
|
+
*/
|
|
1327
|
+
autoThin?: boolean;
|
|
1328
|
+
}
|
|
1052
1329
|
/**
|
|
1053
1330
|
* Animation phase config. Follows Vega's enter/update/exit model.
|
|
1054
1331
|
* Each phase can be true (use defaults) or a config object.
|
|
@@ -1267,8 +1544,12 @@ interface BaseChartSpec<TData extends DataRow = DataRow> {
|
|
|
1267
1544
|
* relates this flag to `legend.show` and the legacy end-of-line labels.
|
|
1268
1545
|
*/
|
|
1269
1546
|
endpointLabels?: boolean | EndpointLabelsConfig;
|
|
1270
|
-
/**
|
|
1271
|
-
|
|
1547
|
+
/**
|
|
1548
|
+
* Responsive behavior. `true`/`false` enables/disables container-width
|
|
1549
|
+
* adaptation. Pass a `ResponsiveConfig` object for fine-grained control
|
|
1550
|
+
* (e.g. `{ autoThin: false }` to disable automatic annotation thinning).
|
|
1551
|
+
*/
|
|
1552
|
+
responsive?: boolean | ResponsiveConfig;
|
|
1272
1553
|
/** Theme configuration overrides. */
|
|
1273
1554
|
theme?: ThemeConfig;
|
|
1274
1555
|
/** Dark mode behavior. Defaults to "off". */
|
|
@@ -1314,6 +1595,13 @@ interface BaseChartSpec<TData extends DataRow = DataRow> {
|
|
|
1314
1595
|
* top-level and per-breakpoint overrides.
|
|
1315
1596
|
*/
|
|
1316
1597
|
display?: Display;
|
|
1598
|
+
/**
|
|
1599
|
+
* Resolution strategy for shared/independent scales and axes across facet
|
|
1600
|
+
* panels. Only meaningful when `encoding.facet` is present. Shared scales
|
|
1601
|
+
* (the default) let readers compare across panels; independent scales give
|
|
1602
|
+
* each panel its own domain.
|
|
1603
|
+
*/
|
|
1604
|
+
resolve?: ResolveConfig;
|
|
1317
1605
|
/**
|
|
1318
1606
|
* Render order within a LayerSpec. Higher values render on top.
|
|
1319
1607
|
* When omitted, layers render in array order (later layers paint on top).
|
|
@@ -1639,8 +1927,14 @@ interface SankeySpec {
|
|
|
1639
1927
|
interface TileMapEncoding {
|
|
1640
1928
|
/** State code field (required, nominal). Maps to US state abbreviations. */
|
|
1641
1929
|
state: EncodingChannel;
|
|
1642
|
-
/**
|
|
1930
|
+
/**
|
|
1931
|
+
* Value field. For quantitative mode, maps to a sequential color scale.
|
|
1932
|
+
* For categorical mode (when color channel is present or values are strings),
|
|
1933
|
+
* maps to category labels shown in tooltips.
|
|
1934
|
+
*/
|
|
1643
1935
|
value: EncodingChannel;
|
|
1936
|
+
/** Color encoding channel (optional, nominal). When present, enables categorical coloring. */
|
|
1937
|
+
color?: EncodingChannel;
|
|
1644
1938
|
/** Tooltip encoding (optional). */
|
|
1645
1939
|
tooltip?: EncodingChannel | EncodingChannel[];
|
|
1646
1940
|
}
|
|
@@ -1652,16 +1946,24 @@ interface TileMapSpec {
|
|
|
1652
1946
|
/**
|
|
1653
1947
|
* Data for the tile map. Accepts either:
|
|
1654
1948
|
* - A record mapping state codes to numeric values: `{ "CA": 12000, "TX": 8500 }`
|
|
1949
|
+
* - A record mapping state codes to string categories: `{ "CA": "high", "TX": "low" }`
|
|
1655
1950
|
* - Tabular data rows with state and value fields (requires encoding)
|
|
1656
1951
|
*/
|
|
1657
|
-
data: Record<string, number | null> | DataRow[];
|
|
1952
|
+
data: Record<string, number | string | null> | DataRow[];
|
|
1658
1953
|
/**
|
|
1659
1954
|
* Encoding channels mapping data fields to visual properties.
|
|
1660
1955
|
* Required when data is DataRow[]. Auto-generated when data is a record map.
|
|
1661
1956
|
*/
|
|
1662
1957
|
encoding?: TileMapEncoding;
|
|
1663
|
-
/** Sequential color palette. Defaults to 'blue'. */
|
|
1958
|
+
/** Sequential color palette. Defaults to 'blue'. Only used in quantitative mode. */
|
|
1664
1959
|
palette?: TileMapPalette;
|
|
1960
|
+
/**
|
|
1961
|
+
* Custom category-to-color mapping for categorical tilemaps.
|
|
1962
|
+
* Keys are category values, values are CSS color strings.
|
|
1963
|
+
* When provided, forces categorical mode regardless of encoding.
|
|
1964
|
+
* Example: `{ "medical_only": "#ee4a73", "religious": "#e07d00", "philosophical": "#06b6d4" }`
|
|
1965
|
+
*/
|
|
1966
|
+
colors?: Record<string, string>;
|
|
1665
1967
|
/** Editorial chrome (title, subtitle, source, byline, footer). */
|
|
1666
1968
|
chrome?: Chrome;
|
|
1667
1969
|
/** Legend display configuration. */
|
|
@@ -2195,151 +2497,6 @@ interface ChartEventHandlers {
|
|
|
2195
2497
|
onTextEdit?: (element: ElementRef, oldText: string, newText: string) => void;
|
|
2196
2498
|
}
|
|
2197
2499
|
|
|
2198
|
-
/**
|
|
2199
|
-
* Theme types: color palettes, typography, spacing, and chrome defaults.
|
|
2200
|
-
*
|
|
2201
|
-
* Theme is the user-facing partial config (all optional).
|
|
2202
|
-
* ResolvedTheme is the engine-internal fully resolved version (no optionals).
|
|
2203
|
-
*/
|
|
2204
|
-
/** Color palettes for the visualization. */
|
|
2205
|
-
interface ThemeColors {
|
|
2206
|
-
/** Categorical palette for nominal data. Array of CSS color strings. */
|
|
2207
|
-
categorical: string[];
|
|
2208
|
-
/** Sequential palettes keyed by name. Each is an array of color stops from light to dark. */
|
|
2209
|
-
sequential: Record<string, string[]>;
|
|
2210
|
-
/** Diverging palettes keyed by name. Each is an array of color stops with a neutral midpoint. */
|
|
2211
|
-
diverging: Record<string, string[]>;
|
|
2212
|
-
/** Background color for the visualization container. */
|
|
2213
|
-
background: string;
|
|
2214
|
-
/** Default text color. */
|
|
2215
|
-
text: string;
|
|
2216
|
-
/** Gridline color. */
|
|
2217
|
-
gridline: string;
|
|
2218
|
-
/** Axis line and tick color. */
|
|
2219
|
-
axis: string;
|
|
2220
|
-
/** Annotation fill color. */
|
|
2221
|
-
annotationFill: string;
|
|
2222
|
-
/** Annotation text color. */
|
|
2223
|
-
annotationText: string;
|
|
2224
|
-
/** Semantic color for positive/up-trend values (e.g. sparkline trend coloring). */
|
|
2225
|
-
positive: string;
|
|
2226
|
-
/** Semantic color for negative/down-trend values (e.g. sparkline trend coloring). */
|
|
2227
|
-
negative: string;
|
|
2228
|
-
}
|
|
2229
|
-
/** Font size presets for the typography scale. */
|
|
2230
|
-
interface ThemeFontSizes {
|
|
2231
|
-
/** Title font size in pixels. */
|
|
2232
|
-
title: number;
|
|
2233
|
-
/** Subtitle font size in pixels. */
|
|
2234
|
-
subtitle: number;
|
|
2235
|
-
/** Body/label font size in pixels. */
|
|
2236
|
-
body: number;
|
|
2237
|
-
/** Small text (source, footer) font size in pixels. */
|
|
2238
|
-
small: number;
|
|
2239
|
-
/** Axis tick label font size in pixels. */
|
|
2240
|
-
axisTick: number;
|
|
2241
|
-
/** KPI metric uppercase label font size in pixels. */
|
|
2242
|
-
metricLabel: number;
|
|
2243
|
-
/** KPI metric primary value font size in pixels. The delta and secondary
|
|
2244
|
-
* values derive from this (each ~0.55x), so scaling this scales the whole cell. */
|
|
2245
|
-
metricValue: number;
|
|
2246
|
-
}
|
|
2247
|
-
/** Font weight presets. */
|
|
2248
|
-
interface ThemeFontWeights {
|
|
2249
|
-
/** Normal text weight. */
|
|
2250
|
-
normal: number;
|
|
2251
|
-
/** Medium text weight (subtitles). */
|
|
2252
|
-
medium: number;
|
|
2253
|
-
/** Semibold text weight (titles). */
|
|
2254
|
-
semibold: number;
|
|
2255
|
-
/** Bold text weight. */
|
|
2256
|
-
bold: number;
|
|
2257
|
-
}
|
|
2258
|
-
/** Complete typography configuration. */
|
|
2259
|
-
interface ThemeFonts {
|
|
2260
|
-
/** Primary font family. */
|
|
2261
|
-
family: string;
|
|
2262
|
-
/** Monospace font family (for tabular numbers). */
|
|
2263
|
-
mono: string;
|
|
2264
|
-
/** Font sizes. */
|
|
2265
|
-
sizes: ThemeFontSizes;
|
|
2266
|
-
/** Font weights. */
|
|
2267
|
-
weights: ThemeFontWeights;
|
|
2268
|
-
}
|
|
2269
|
-
/** Spacing configuration in pixels. */
|
|
2270
|
-
interface ThemeSpacing {
|
|
2271
|
-
/** Padding inside the visualization container (all sides). */
|
|
2272
|
-
padding: number;
|
|
2273
|
-
/** Gap between chrome elements (title to subtitle, subtitle to chart, etc.). */
|
|
2274
|
-
chromeGap: number;
|
|
2275
|
-
/** Gap between the last chrome element and the chart area. */
|
|
2276
|
-
chromeToChart: number;
|
|
2277
|
-
/** Gap between chart area and source/footer below. */
|
|
2278
|
-
chartToFooter: number;
|
|
2279
|
-
/** Internal padding within the chart area (axes margins). */
|
|
2280
|
-
axisMargin: number;
|
|
2281
|
-
/** Height reserved below the chart area for x-axis tick labels (and optional axis title). */
|
|
2282
|
-
xAxisHeight: number;
|
|
2283
|
-
/** Gap in pixels between the x-axis line and the top of non-rotated tick label text. */
|
|
2284
|
-
xAxisLabelPadding: number;
|
|
2285
|
-
}
|
|
2286
|
-
/** Default style configuration for a chrome text element. */
|
|
2287
|
-
interface ChromeDefaults {
|
|
2288
|
-
/** Font size in pixels. */
|
|
2289
|
-
fontSize: number;
|
|
2290
|
-
/** Font weight. */
|
|
2291
|
-
fontWeight: number;
|
|
2292
|
-
/** Text color (CSS color string). */
|
|
2293
|
-
color: string;
|
|
2294
|
-
/** Line height multiplier. */
|
|
2295
|
-
lineHeight: number;
|
|
2296
|
-
}
|
|
2297
|
-
/** Default chrome styles for each element type. */
|
|
2298
|
-
interface ThemeChromeDefaults {
|
|
2299
|
-
eyebrow: ChromeDefaults;
|
|
2300
|
-
title: ChromeDefaults;
|
|
2301
|
-
subtitle: ChromeDefaults;
|
|
2302
|
-
source: ChromeDefaults;
|
|
2303
|
-
byline: ChromeDefaults;
|
|
2304
|
-
footer: ChromeDefaults;
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* Complete theme interface. Used internally after merging user overrides
|
|
2308
|
-
* onto defaults. All fields are required here (this is what the engine
|
|
2309
|
-
* works with).
|
|
2310
|
-
*
|
|
2311
|
-
* Users provide ThemeConfig (from spec.ts) which is the partial/optional
|
|
2312
|
-
* version. The theme resolver deep-merges ThemeConfig onto the default Theme
|
|
2313
|
-
* to produce a ResolvedTheme.
|
|
2314
|
-
*/
|
|
2315
|
-
interface Theme {
|
|
2316
|
-
/** Color palettes. */
|
|
2317
|
-
colors: ThemeColors;
|
|
2318
|
-
/** Typography settings. */
|
|
2319
|
-
fonts: ThemeFonts;
|
|
2320
|
-
/** Spacing values in pixels. */
|
|
2321
|
-
spacing: ThemeSpacing;
|
|
2322
|
-
/** Border radius for containers and tooltips. */
|
|
2323
|
-
borderRadius: number;
|
|
2324
|
-
/** Default chrome text styles. */
|
|
2325
|
-
chrome: ThemeChromeDefaults;
|
|
2326
|
-
}
|
|
2327
|
-
/**
|
|
2328
|
-
* Fully resolved theme with no optional fields.
|
|
2329
|
-
*
|
|
2330
|
-
* This is the result of resolveTheme(): the default theme with user
|
|
2331
|
-
* overrides deep-merged in. Every property is guaranteed to have a value.
|
|
2332
|
-
* The engine uses ResolvedTheme internally so it never needs null checks.
|
|
2333
|
-
*
|
|
2334
|
-
* Structurally identical to Theme (both have all required fields), but
|
|
2335
|
-
* exists as a separate type for semantic clarity: Theme is the default
|
|
2336
|
-
* definition, ResolvedTheme is the runtime-resolved instance.
|
|
2337
|
-
*/
|
|
2338
|
-
interface ResolvedTheme extends Theme {
|
|
2339
|
-
/** Whether dark mode adaptations have been applied to this theme. */
|
|
2340
|
-
isDark: boolean;
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
2500
|
/** A rectangle defined by position and dimensions. */
|
|
2344
2501
|
interface Rect {
|
|
2345
2502
|
x: number;
|
|
@@ -2419,6 +2576,8 @@ interface ResolvedChrome {
|
|
|
2419
2576
|
byline?: ResolvedChromeElement;
|
|
2420
2577
|
footer?: ResolvedChromeElement;
|
|
2421
2578
|
brand?: ResolvedChromeElement;
|
|
2579
|
+
/** Annotation footnotes generated by auto-thinning. Rendered as a numbered list above the source line. */
|
|
2580
|
+
footnotes?: AnnotationFootnote[];
|
|
2422
2581
|
/** Absolute y at which bottom-chrome relative offsets are anchored: area.y + area.height + x-axis extent. */
|
|
2423
2582
|
bottomAnchorY?: number;
|
|
2424
2583
|
}
|
|
@@ -2893,6 +3052,19 @@ interface ResolvedAnnotation {
|
|
|
2893
3052
|
};
|
|
2894
3053
|
/** Full placed extent: label bounds unioned with subtitle bounds. Collision and placement source of truth. */
|
|
2895
3054
|
bounds?: Rect;
|
|
3055
|
+
/**
|
|
3056
|
+
* When set, this annotation was demoted to a footnote marker by auto-thinning.
|
|
3057
|
+
* The label is replaced by a numbered dot at the data point; the original text
|
|
3058
|
+
* appears in the chrome footnote band. 1-indexed.
|
|
3059
|
+
*/
|
|
3060
|
+
footnoteIndex?: number;
|
|
3061
|
+
}
|
|
3062
|
+
/** A footnote entry generated by annotation auto-thinning. */
|
|
3063
|
+
interface AnnotationFootnote {
|
|
3064
|
+
/** 1-indexed footnote number matching the dot marker on the chart. */
|
|
3065
|
+
index: number;
|
|
3066
|
+
/** The original annotation text that was demoted. */
|
|
3067
|
+
text: string;
|
|
2896
3068
|
}
|
|
2897
3069
|
/** A single entry in a categorical legend. */
|
|
2898
3070
|
interface LegendEntry {
|
|
@@ -3017,6 +3189,10 @@ interface EndpointLabelsLayout {
|
|
|
3017
3189
|
valueGap: number;
|
|
3018
3190
|
/** Fill color for the rounded chip background behind the colored bar. */
|
|
3019
3191
|
swatchChipFill: string;
|
|
3192
|
+
/** Leading-edge (left side) entries when `ends: 'both'`. Empty when trailing only. */
|
|
3193
|
+
leading?: EndpointLabelEntry[];
|
|
3194
|
+
/** Bounding box for the leading column. Only set when `ends: 'both'`. */
|
|
3195
|
+
leadingBounds?: Rect;
|
|
3020
3196
|
}
|
|
3021
3197
|
/** A single field-value pair in a tooltip. */
|
|
3022
3198
|
interface TooltipField {
|
|
@@ -3090,6 +3266,45 @@ interface ResolvedMetricBar {
|
|
|
3090
3266
|
/** Cells laid out evenly across the chart width. */
|
|
3091
3267
|
cells: ResolvedMetricCell[];
|
|
3092
3268
|
}
|
|
3269
|
+
/**
|
|
3270
|
+
* A single panel in a faceted (small-multiples) layout.
|
|
3271
|
+
* Each panel has its own marks, axes, and drawing area but typically
|
|
3272
|
+
* shares scales with sibling panels.
|
|
3273
|
+
*/
|
|
3274
|
+
interface FacetPanelLayout {
|
|
3275
|
+
/** Facet value that produced this panel. */
|
|
3276
|
+
key: string;
|
|
3277
|
+
/** Panel drawing area in SVG coordinates. */
|
|
3278
|
+
area: Rect;
|
|
3279
|
+
/** Data marks for this panel. */
|
|
3280
|
+
marks: Mark[];
|
|
3281
|
+
/** Per-panel axis layouts. Inner panels may have ticks suppressed. */
|
|
3282
|
+
axes: {
|
|
3283
|
+
x?: AxisLayout;
|
|
3284
|
+
y?: AxisLayout;
|
|
3285
|
+
};
|
|
3286
|
+
/** Per-panel annotations. */
|
|
3287
|
+
annotations: ResolvedAnnotation[];
|
|
3288
|
+
/** Panel header label (facet value) positioned above the panel. */
|
|
3289
|
+
header: {
|
|
3290
|
+
text: string;
|
|
3291
|
+
x: number;
|
|
3292
|
+
y: number;
|
|
3293
|
+
fontSize: number;
|
|
3294
|
+
fontWeight: number;
|
|
3295
|
+
};
|
|
3296
|
+
}
|
|
3297
|
+
/** Layout for a faceted (small-multiples) chart. */
|
|
3298
|
+
interface FacetLayout {
|
|
3299
|
+
/** Ordered array of panel layouts. */
|
|
3300
|
+
panels: FacetPanelLayout[];
|
|
3301
|
+
/** The data field used for faceting. */
|
|
3302
|
+
facetField: string;
|
|
3303
|
+
/** Number of columns in the wrap grid. */
|
|
3304
|
+
columns: number;
|
|
3305
|
+
/** Whether scales are shared across panels. */
|
|
3306
|
+
sharedScales: boolean;
|
|
3307
|
+
}
|
|
3093
3308
|
/**
|
|
3094
3309
|
* ChartLayout: the complete engine output for chart visualizations.
|
|
3095
3310
|
*
|
|
@@ -3145,6 +3360,8 @@ interface ChartLayout {
|
|
|
3145
3360
|
crosshair: boolean;
|
|
3146
3361
|
/** Real text measurement function from the adapter (for accurate SVG text wrapping). */
|
|
3147
3362
|
measureText?: MeasureTextFn;
|
|
3363
|
+
/** Faceted (small-multiples) layout. When present, renderers iterate panels instead of using top-level marks/axes. */
|
|
3364
|
+
facet?: FacetLayout;
|
|
3148
3365
|
}
|
|
3149
3366
|
/** A resolved column definition with computed properties. */
|
|
3150
3367
|
interface ResolvedColumn {
|
|
@@ -3532,8 +3749,10 @@ interface TileMapLayout {
|
|
|
3532
3749
|
chrome: ResolvedChrome;
|
|
3533
3750
|
/** Resolved tile marks with positions, colors, and labels. */
|
|
3534
3751
|
tiles: TileMapTileMark[];
|
|
3535
|
-
/** Gradient color legend (null if
|
|
3752
|
+
/** Gradient color legend for quantitative mode (null if hidden or categorical). */
|
|
3536
3753
|
gradientLegend: GradientLegendLayout | null;
|
|
3754
|
+
/** Categorical swatch legend for nominal mode (null if hidden or quantitative). */
|
|
3755
|
+
categoricalLegend: CategoricalLegendLayout | null;
|
|
3537
3756
|
/** Tooltip content descriptors keyed by state code. */
|
|
3538
3757
|
tooltipDescriptors: Map<string, TooltipContent>;
|
|
3539
3758
|
/** Accessibility metadata for the tile map. */
|
|
@@ -3745,6 +3964,41 @@ declare function meetsAA(fg: string, bg: string, largeText?: boolean): boolean;
|
|
|
3745
3964
|
*/
|
|
3746
3965
|
declare function findAccessibleColor(baseColor: string, bg: string, targetRatio?: number): string;
|
|
3747
3966
|
|
|
3967
|
+
/**
|
|
3968
|
+
* Color palettes for @opendata-ai.
|
|
3969
|
+
*
|
|
3970
|
+
* Categorical palette leads with cyan and uses an OKLCH-balanced multi-hue
|
|
3971
|
+
* ramp tuned to L≈0.70, C≈0.13–0.15. Hex values are precomputed sRGB
|
|
3972
|
+
* (rather than raw `oklch()` strings) because raw OKLCH strings parse
|
|
3973
|
+
* unreliably through d3-color and the dark-mode adapter's hsl-based
|
|
3974
|
+
* binary search. Source OKLCH values are documented inline so the ramp
|
|
3975
|
+
* can be regenerated if needed.
|
|
3976
|
+
*
|
|
3977
|
+
* Convention for low-cardinality charts (1 / 2-4 / 5+ series) is available
|
|
3978
|
+
* as an opt-in via `theme.seriesStrategy`. The default strategy is 'palette'
|
|
3979
|
+
* (full categorical ramp always). The accent-neutral convention is:
|
|
3980
|
+
* - 1 series: cyan only
|
|
3981
|
+
* - 2-4 series: cyan + zinc-400/500/600 (achromatic)
|
|
3982
|
+
* - 5+ series: full multi-hue ramp below
|
|
3983
|
+
*
|
|
3984
|
+
* Sequential palettes: 5-7 stops from light to dark.
|
|
3985
|
+
* Diverging palettes: 7 stops with a neutral midpoint.
|
|
3986
|
+
*/
|
|
3987
|
+
/**
|
|
3988
|
+
* Achromatic surface and supporting-series ramp. Values are the canonical
|
|
3989
|
+
* dark-mode tokens; light-mode equivalents are derived per token in
|
|
3990
|
+
* `theme/dark-mode.ts` and the CSS partials, not mirrored here.
|
|
3991
|
+
*/
|
|
3992
|
+
declare const ACHROMATIC_RAMP: {
|
|
3993
|
+
readonly fg: "#f7f8f8";
|
|
3994
|
+
readonly fg2: "#d0d6e0";
|
|
3995
|
+
readonly fgMuted: "#a1a1aa";
|
|
3996
|
+
readonly fgSubtle: "#71717a";
|
|
3997
|
+
readonly fgFaint: "#52525b";
|
|
3998
|
+
readonly secondary: "#27272a";
|
|
3999
|
+
readonly card: "#111113";
|
|
4000
|
+
readonly bg: "#09090b";
|
|
4001
|
+
};
|
|
3748
4002
|
/**
|
|
3749
4003
|
* Default categorical palette. Cyan-led OKLCH-balanced multi-hue ramp.
|
|
3750
4004
|
*
|
|
@@ -3795,12 +4049,30 @@ declare function adaptColorForDarkMode(color: string, lightBg: string, darkBg: s
|
|
|
3795
4049
|
* adjusts gridline and axis colors for the dark background.
|
|
3796
4050
|
*/
|
|
3797
4051
|
declare function adaptTheme(theme: ResolvedTheme): ResolvedTheme;
|
|
4052
|
+
/**
|
|
4053
|
+
* Returns a darker variant of a color for use as a foreground stroke on
|
|
4054
|
+
* light backgrounds, where mid-lightness palette colors (e.g. cyan-500
|
|
4055
|
+
* `#06b6d4`) lack contrast against white. Drops HSL lightness by ~12%
|
|
4056
|
+
* absolute (clamped to >= 0) while preserving hue and saturation, which
|
|
4057
|
+
* reproduces the cyan-500 → cyan-600 step the cyan accent originally
|
|
4058
|
+
* needed and works for any other palette accent the user picks.
|
|
4059
|
+
*
|
|
4060
|
+
* Returns the input unchanged when:
|
|
4061
|
+
* - the color is already dark enough (L <= ~0.40) — further darkening
|
|
4062
|
+
* just muddies the stroke without adding contrast
|
|
4063
|
+
* - the color isn't parseable
|
|
4064
|
+
* - the color is achromatic (NaN hue) — HSL lightness on grays drifts
|
|
4065
|
+
* toward black instead of staying neutral
|
|
4066
|
+
*
|
|
4067
|
+
* Exposed via the `--oc-accent-strong` CSS token.
|
|
4068
|
+
*/
|
|
4069
|
+
declare function adaptForLightLineStroke(color: string): string;
|
|
3798
4070
|
|
|
3799
4071
|
/**
|
|
3800
4072
|
* Default theme definition.
|
|
3801
4073
|
*
|
|
3802
4074
|
* Editorial design system with cyan-led categorical palette, Inter
|
|
3803
|
-
* Variable typography (weights
|
|
4075
|
+
* Variable typography (weights 450/550/590/700), and zinc-based achromatic
|
|
3804
4076
|
* surfaces. Light is the default surface; dark adaptation lives in
|
|
3805
4077
|
* dark-mode.ts.
|
|
3806
4078
|
*
|
|
@@ -3812,6 +4084,21 @@ declare function adaptTheme(theme: ResolvedTheme): ResolvedTheme;
|
|
|
3812
4084
|
*/
|
|
3813
4085
|
declare const DEFAULT_THEME: Theme;
|
|
3814
4086
|
|
|
4087
|
+
/**
|
|
4088
|
+
* Named theme presets built on the design token system.
|
|
4089
|
+
*
|
|
4090
|
+
* Each preset is a ThemeConfig object that can be passed to createChart()
|
|
4091
|
+
* or the React/Svelte/Vue Chart component. The engine deep-merges them
|
|
4092
|
+
* onto DEFAULT_THEME, so only the deltas are specified here.
|
|
4093
|
+
*/
|
|
4094
|
+
|
|
4095
|
+
/** Editorial preset: the current default look. Exported for explicit selection. */
|
|
4096
|
+
declare const editorial: ThemeConfig;
|
|
4097
|
+
/** Essay preset: serif display titles, warmer background, generous spacing. */
|
|
4098
|
+
declare const essay: ThemeConfig;
|
|
4099
|
+
/** Wire preset: dense, mono numerals, tighter chrome. Dashboard/agency feel. */
|
|
4100
|
+
declare const wire: ThemeConfig;
|
|
4101
|
+
|
|
3815
4102
|
/**
|
|
3816
4103
|
* Theme resolver: deep-merges user overrides onto default theme.
|
|
3817
4104
|
*
|
|
@@ -4393,8 +4680,10 @@ declare function dataTable(data: DataRow[], options?: TableBuilderOptions): Tabl
|
|
|
4393
4680
|
interface TileMapBuilderOptions {
|
|
4394
4681
|
/** Encoding channels (required when data is DataRow[]). */
|
|
4395
4682
|
encoding?: TileMapEncoding;
|
|
4396
|
-
/** Sequential color palette name. */
|
|
4683
|
+
/** Sequential color palette name (quantitative mode only). */
|
|
4397
4684
|
palette?: TileMapPalette;
|
|
4685
|
+
/** Custom category-to-color mapping. Forces categorical mode. */
|
|
4686
|
+
colors?: Record<string, string>;
|
|
4398
4687
|
/** Editorial chrome. */
|
|
4399
4688
|
chrome?: Chrome;
|
|
4400
4689
|
/** Legend display configuration. */
|
|
@@ -4423,6 +4712,6 @@ interface TileMapBuilderOptions {
|
|
|
4423
4712
|
* tileMap(data, { encoding: { state: { field: 'code' }, value: { field: 'rate' } } })
|
|
4424
4713
|
* ```
|
|
4425
4714
|
*/
|
|
4426
|
-
declare function tileMap(data: Record<string, number | null> | DataRow[], options?: TileMapBuilderOptions): TileMapSpec;
|
|
4715
|
+
declare function tileMap(data: Record<string, number | string | null> | DataRow[], options?: TileMapBuilderOptions): TileMapSpec;
|
|
4427
4716
|
|
|
4428
|
-
export { type A11yMetadata, 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 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 BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, CHART_ENCODING_RULES, CHART_TYPES, COMPACT_WIDTH, type CalculateExpression, type CalculateTransform, 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 ChartType, type Chrome, type ChromeDefaults, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type Condition, type ConditionalValueDef, 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 EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, type FieldPredicate, type FieldRef, type FieldType, 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 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, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedTheme, type RuleMarkLayout, SEQUENTIAL_PALETTES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleType, type SequentialPalette, type SeriesStyle, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, 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 TooltipContent, type TooltipField, type Transform, type VizSpec, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, abbreviateNumber, adaptColorForDarkMode, adaptTheme, areaChart, axisTitleOffset, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, dataTable, detectCollision, donutChart, dotChart, elementRef, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGradientDef, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, lineChart, meetsAA, overlapArea, pickLabelColor, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveTheme, scatterChart, simulateColorBlindness, textAscent, tileMap, wrapText };
|
|
4717
|
+
export { 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 BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, CHART_ENCODING_RULES, CHART_TYPES, COMPACT_WIDTH, type CalculateExpression, type CalculateTransform, 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 ChartType, 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 Condition, type ConditionalValueDef, 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 EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldPredicate, type FieldRef, type FieldType, 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 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, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedTheme, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleType, type SequentialPalette, type SeriesStrategy, type SeriesStyle, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, 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 VizSpec, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, dataTable, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGradientDef, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, lineChart, meetsAA, overlapArea, pickLabelColor, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveTheme, scatterChart, simulateColorBlindness, textAscent, tileMap, wire, wrapText };
|