@opendata-ai/openchart-core 6.25.4 → 6.27.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 +267 -14
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/helpers/spec-builders.ts +63 -0
- package/src/index.ts +2 -0
- package/src/styles/animation.css +20 -0
- package/src/styles/base.css +2 -1
- package/src/styles/index.css +1 -0
- package/src/styles/sparkline.css +14 -0
- package/src/styles/tokens.css +2 -1
- package/src/types/index.ts +17 -0
- package/src/types/layout.ts +114 -5
- package/src/types/spec.ts +145 -8
package/dist/index.d.ts
CHANGED
|
@@ -328,6 +328,8 @@ interface AxisConfig {
|
|
|
328
328
|
labelPadding?: number;
|
|
329
329
|
/** Color override for axis tick labels and title. Useful in dual-axis charts to match axis color to its series. */
|
|
330
330
|
labelColor?: string;
|
|
331
|
+
/** Secondary data field to display alongside each tick label. Renders in lighter weight/color. Only effective on categorical y-axis labels (horizontal bar charts). */
|
|
332
|
+
labelField?: string;
|
|
331
333
|
}
|
|
332
334
|
/** Scale configuration for an encoding channel. */
|
|
333
335
|
interface ScaleConfig {
|
|
@@ -815,6 +817,16 @@ interface AnimationConfig {
|
|
|
815
817
|
* - AnimationConfig: full control via enter/update/exit phases
|
|
816
818
|
*/
|
|
817
819
|
type AnimationSpec = boolean | AnimationConfig;
|
|
820
|
+
/**
|
|
821
|
+
* Chart display mode.
|
|
822
|
+
* - `'full'` (default): standard chart with chrome, axes, legend, padding.
|
|
823
|
+
* - `'sparkline'`: minimal inline mini-chart. Strips chrome, axes, legend,
|
|
824
|
+
* watermark, animation, and reduces margins to a tiny safety pad. The mark
|
|
825
|
+
* fills the container edge-to-edge. Best with `mark: 'line' | 'area' | 'bar'`.
|
|
826
|
+
* Explicit user fields (chrome, legend, encoding.x.axis, etc.) still render
|
|
827
|
+
* when set, so users can opt in to specific elements.
|
|
828
|
+
*/
|
|
829
|
+
type Display = 'full' | 'sparkline';
|
|
818
830
|
/**
|
|
819
831
|
* Breakpoint-conditional overrides for chart specs.
|
|
820
832
|
*
|
|
@@ -833,6 +845,12 @@ interface ChartSpecOverride {
|
|
|
833
845
|
annotations?: Annotation[];
|
|
834
846
|
/** Override animation at this breakpoint. */
|
|
835
847
|
animation?: AnimationSpec;
|
|
848
|
+
/** Override display mode (`'full'` or `'sparkline'`) at this breakpoint. */
|
|
849
|
+
display?: Display;
|
|
850
|
+
/** Override watermark visibility at this breakpoint. */
|
|
851
|
+
watermark?: boolean;
|
|
852
|
+
/** Override crosshair behavior at this breakpoint. */
|
|
853
|
+
crosshair?: boolean;
|
|
836
854
|
}
|
|
837
855
|
/**
|
|
838
856
|
* Chart specification: the primary input for standard chart types.
|
|
@@ -887,6 +905,28 @@ interface ChartSpec {
|
|
|
887
905
|
* - AnimationConfig: full control via enter/update/exit phases
|
|
888
906
|
*/
|
|
889
907
|
animation?: AnimationSpec;
|
|
908
|
+
/**
|
|
909
|
+
* Show a vertical crosshair line that tracks the nearest data point on
|
|
910
|
+
* line and area charts. Only active when a voronoi overlay is present.
|
|
911
|
+
* Defaults to false. In sparkline display mode, defaults to false unless
|
|
912
|
+
* explicitly set.
|
|
913
|
+
*/
|
|
914
|
+
crosshair?: boolean;
|
|
915
|
+
/**
|
|
916
|
+
* Display mode controlling how much chart chrome is rendered.
|
|
917
|
+
*
|
|
918
|
+
* - `'full'` (default): full publication chart with chrome, axes, legend, padding.
|
|
919
|
+
* - `'sparkline'`: inline mini-chart for dashboards/KPI cards. Strips chrome,
|
|
920
|
+
* axes, legend, watermark, animation, and crosshair. The mark fills the
|
|
921
|
+
* container edge-to-edge with a small safety margin. Best with
|
|
922
|
+
* `mark: 'line' | 'area' | 'bar' | 'point'`.
|
|
923
|
+
*
|
|
924
|
+
* **Override precedence:** explicit user fields always win, even in sparkline
|
|
925
|
+
* mode. Setting `chrome.title` on a sparkline still renders the title.
|
|
926
|
+
* Setting `legend: { show: true }` still renders the legend. This applies at
|
|
927
|
+
* top-level and per-breakpoint overrides.
|
|
928
|
+
*/
|
|
929
|
+
display?: Display;
|
|
890
930
|
/**
|
|
891
931
|
* Render order within a LayerSpec. Higher values render on top.
|
|
892
932
|
* When omitted, layers render in array order (later layers paint on top).
|
|
@@ -1110,6 +1150,51 @@ interface SankeySpec {
|
|
|
1110
1150
|
*/
|
|
1111
1151
|
valueFormat?: string;
|
|
1112
1152
|
}
|
|
1153
|
+
/** Encoding channels specific to tile map visualizations. */
|
|
1154
|
+
interface TileMapEncoding {
|
|
1155
|
+
/** State code field (required, nominal). Maps to US state abbreviations. */
|
|
1156
|
+
state: EncodingChannel;
|
|
1157
|
+
/** Value field (required, quantitative). Maps to the sequential color scale. */
|
|
1158
|
+
value: EncodingChannel;
|
|
1159
|
+
/** Tooltip encoding (optional). */
|
|
1160
|
+
tooltip?: EncodingChannel | EncodingChannel[];
|
|
1161
|
+
}
|
|
1162
|
+
/** Sequential color palette names available for tile maps. */
|
|
1163
|
+
type TileMapPalette = 'blue' | 'green' | 'orange' | 'purple';
|
|
1164
|
+
interface TileMapSpec {
|
|
1165
|
+
/** Discriminant: always "tilemap". */
|
|
1166
|
+
type: 'tilemap';
|
|
1167
|
+
/**
|
|
1168
|
+
* Data for the tile map. Accepts either:
|
|
1169
|
+
* - A record mapping state codes to numeric values: `{ "CA": 12000, "TX": 8500 }`
|
|
1170
|
+
* - Tabular data rows with state and value fields (requires encoding)
|
|
1171
|
+
*/
|
|
1172
|
+
data: Record<string, number | null> | DataRow[];
|
|
1173
|
+
/**
|
|
1174
|
+
* Encoding channels mapping data fields to visual properties.
|
|
1175
|
+
* Required when data is DataRow[]. Auto-generated when data is a record map.
|
|
1176
|
+
*/
|
|
1177
|
+
encoding?: TileMapEncoding;
|
|
1178
|
+
/** Sequential color palette. Defaults to 'blue'. */
|
|
1179
|
+
palette?: TileMapPalette;
|
|
1180
|
+
/** Editorial chrome (title, subtitle, source, byline, footer). */
|
|
1181
|
+
chrome?: Chrome;
|
|
1182
|
+
/** Legend display configuration. */
|
|
1183
|
+
legend?: LegendConfig;
|
|
1184
|
+
/** Theme configuration overrides. */
|
|
1185
|
+
theme?: ThemeConfig;
|
|
1186
|
+
/** Dark mode behavior. Defaults to "off". */
|
|
1187
|
+
darkMode?: DarkMode;
|
|
1188
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
1189
|
+
watermark?: boolean;
|
|
1190
|
+
/** Animation configuration for entrance animations. */
|
|
1191
|
+
animation?: AnimationSpec;
|
|
1192
|
+
/**
|
|
1193
|
+
* d3-format string applied to tile values, legend labels, and tooltips.
|
|
1194
|
+
* Examples: ".1f" for one decimal, "$,.0f" for currency, "~s" for SI.
|
|
1195
|
+
*/
|
|
1196
|
+
valueFormat?: string;
|
|
1197
|
+
}
|
|
1113
1198
|
/**
|
|
1114
1199
|
* Top-level visualization spec: union discriminated by structural shape.
|
|
1115
1200
|
*
|
|
@@ -1118,8 +1203,9 @@ interface SankeySpec {
|
|
|
1118
1203
|
* - TableSpec: has `type: 'table'`
|
|
1119
1204
|
* - GraphSpec: has `type: 'graph'`
|
|
1120
1205
|
* - SankeySpec: has `type: 'sankey'`
|
|
1206
|
+
* - TileMapSpec: has `type: 'tilemap'`
|
|
1121
1207
|
*/
|
|
1122
|
-
type VizSpec = ChartSpec | LayerSpec | TableSpec | GraphSpec | SankeySpec;
|
|
1208
|
+
type VizSpec = ChartSpec | LayerSpec | TableSpec | GraphSpec | SankeySpec | TileMapSpec;
|
|
1123
1209
|
/** Chart spec without runtime data, for persistence/storage. */
|
|
1124
1210
|
type ChartSpecWithoutData = Omit<ChartSpec, 'data'>;
|
|
1125
1211
|
/** Table spec without runtime data and columns, for persistence/storage. Columns can be auto-generated via dataTable(). */
|
|
@@ -1128,8 +1214,10 @@ type TableSpecWithoutData = Omit<TableSpec, 'data' | 'columns'>;
|
|
|
1128
1214
|
type GraphSpecWithoutData = Omit<GraphSpec, 'nodes' | 'edges'>;
|
|
1129
1215
|
/** Sankey spec without runtime data, for persistence/storage. */
|
|
1130
1216
|
type SankeySpecWithoutData = Omit<SankeySpec, 'data'>;
|
|
1217
|
+
/** TileMap spec without runtime data, for persistence/storage. */
|
|
1218
|
+
type TileMapSpecWithoutData = Omit<TileMapSpec, 'data'>;
|
|
1131
1219
|
/** Union of data-stripped spec types for persistence/storage. */
|
|
1132
|
-
type StoredVizSpec = ChartSpecWithoutData | TableSpecWithoutData | GraphSpecWithoutData | SankeySpecWithoutData;
|
|
1220
|
+
type StoredVizSpec = ChartSpecWithoutData | TableSpecWithoutData | GraphSpecWithoutData | SankeySpecWithoutData | TileMapSpecWithoutData;
|
|
1133
1221
|
/** Logical AND combinator for filter predicates. */
|
|
1134
1222
|
interface LogicalAnd<T> {
|
|
1135
1223
|
and: T[];
|
|
@@ -1142,6 +1230,12 @@ interface LogicalOr<T> {
|
|
|
1142
1230
|
interface LogicalNot<T> {
|
|
1143
1231
|
not: T;
|
|
1144
1232
|
}
|
|
1233
|
+
/** A relative-time reference that resolves against the data extent. */
|
|
1234
|
+
interface RelativeTimeRef {
|
|
1235
|
+
anchor: 'max' | 'min';
|
|
1236
|
+
offset: number;
|
|
1237
|
+
unit: 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
1238
|
+
}
|
|
1145
1239
|
/** A predicate that tests a field value against a condition. */
|
|
1146
1240
|
interface FieldPredicate {
|
|
1147
1241
|
/** Data field to test. */
|
|
@@ -1149,15 +1243,15 @@ interface FieldPredicate {
|
|
|
1149
1243
|
/** Equals comparison. */
|
|
1150
1244
|
equal?: unknown;
|
|
1151
1245
|
/** Less than. */
|
|
1152
|
-
lt?: number;
|
|
1246
|
+
lt?: number | RelativeTimeRef;
|
|
1153
1247
|
/** Less than or equal. */
|
|
1154
|
-
lte?: number;
|
|
1248
|
+
lte?: number | RelativeTimeRef;
|
|
1155
1249
|
/** Greater than. */
|
|
1156
|
-
gt?: number;
|
|
1250
|
+
gt?: number | RelativeTimeRef;
|
|
1157
1251
|
/** Greater than or equal. */
|
|
1158
|
-
gte?: number;
|
|
1252
|
+
gte?: number | RelativeTimeRef;
|
|
1159
1253
|
/** Inclusive range [min, max]. */
|
|
1160
|
-
range?: [number, number];
|
|
1254
|
+
range?: [number | RelativeTimeRef, number | RelativeTimeRef];
|
|
1161
1255
|
/** Value is one of these. */
|
|
1162
1256
|
oneOf?: unknown[];
|
|
1163
1257
|
/** Whether the value is valid (non-null, non-undefined, non-NaN). */
|
|
@@ -1237,8 +1331,31 @@ interface FoldTransform {
|
|
|
1237
1331
|
/** Output field names for [key, value]. Defaults to ['key', 'value']. */
|
|
1238
1332
|
as?: [string, string];
|
|
1239
1333
|
}
|
|
1334
|
+
/** Window operation types for computing values relative to other rows. */
|
|
1335
|
+
type WindowOp = 'lag' | 'lead' | 'diff' | 'pct_change' | 'cumsum' | 'rank' | 'first_value';
|
|
1336
|
+
/** Sort field definition for window transforms. */
|
|
1337
|
+
interface WindowSortField {
|
|
1338
|
+
field: string;
|
|
1339
|
+
order?: 'ascending' | 'descending';
|
|
1340
|
+
}
|
|
1341
|
+
/** Window field definition specifying which operation to compute. */
|
|
1342
|
+
interface WindowFieldDef {
|
|
1343
|
+
op: WindowOp;
|
|
1344
|
+
field: string;
|
|
1345
|
+
/** Row offset for lag/lead/diff/pct_change. Defaults to 1. */
|
|
1346
|
+
offset?: number;
|
|
1347
|
+
as: string;
|
|
1348
|
+
}
|
|
1349
|
+
/** Window transform: computes values relative to other rows in sort order within a partition. */
|
|
1350
|
+
interface WindowTransform {
|
|
1351
|
+
window: WindowFieldDef[];
|
|
1352
|
+
/** Fields to sort by within each partition. */
|
|
1353
|
+
sort: WindowSortField[];
|
|
1354
|
+
/** Fields to partition (group) by. Each group is windowed independently. */
|
|
1355
|
+
groupby?: string[];
|
|
1356
|
+
}
|
|
1240
1357
|
/** Discriminated union of all transform types. */
|
|
1241
|
-
type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform | AggregateTransform | FoldTransform;
|
|
1358
|
+
type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform | AggregateTransform | FoldTransform | WindowTransform;
|
|
1242
1359
|
/**
|
|
1243
1360
|
* A single condition with a test predicate and resulting value/field.
|
|
1244
1361
|
* When the test passes for a datum, the condition's value/field is used.
|
|
@@ -1295,6 +1412,8 @@ declare function isTableSpec(spec: VizSpec | Record<string, unknown>): spec is T
|
|
|
1295
1412
|
declare function isGraphSpec(spec: VizSpec | Record<string, unknown>): spec is GraphSpec;
|
|
1296
1413
|
/** Check if a spec is a SankeySpec. */
|
|
1297
1414
|
declare function isSankeySpec(spec: VizSpec | Record<string, unknown>): spec is SankeySpec;
|
|
1415
|
+
/** Check if a spec is a TileMapSpec. */
|
|
1416
|
+
declare function isTileMapSpec(spec: VizSpec | Record<string, unknown>): spec is TileMapSpec;
|
|
1298
1417
|
/** Check if an annotation is a TextAnnotation. */
|
|
1299
1418
|
declare function isTextAnnotation(annotation: Annotation): annotation is TextAnnotation;
|
|
1300
1419
|
/** Check if an annotation is a RangeAnnotation. */
|
|
@@ -1731,6 +1850,8 @@ interface AxisTick {
|
|
|
1731
1850
|
position: number;
|
|
1732
1851
|
/** Formatted label string for display. */
|
|
1733
1852
|
label: string;
|
|
1853
|
+
/** Secondary label text from axis.labelField. */
|
|
1854
|
+
subtitle?: string;
|
|
1734
1855
|
}
|
|
1735
1856
|
/** A single gridline with computed positions. */
|
|
1736
1857
|
interface Gridline {
|
|
@@ -2131,7 +2252,7 @@ interface ResolvedAnnotation {
|
|
|
2131
2252
|
/** Z-index for render ordering. Higher values render on top. */
|
|
2132
2253
|
zIndex?: number;
|
|
2133
2254
|
}
|
|
2134
|
-
/** A single entry in
|
|
2255
|
+
/** A single entry in a categorical legend. */
|
|
2135
2256
|
interface LegendEntry {
|
|
2136
2257
|
/** The label text (category name or range description). */
|
|
2137
2258
|
label: string;
|
|
@@ -2144,16 +2265,21 @@ interface LegendEntry {
|
|
|
2144
2265
|
/** True for overflow indicator entries ("+N more"). Not interactive. */
|
|
2145
2266
|
overflow?: boolean;
|
|
2146
2267
|
}
|
|
2147
|
-
/**
|
|
2148
|
-
interface
|
|
2268
|
+
/** Base legend layout fields shared by all legend types. */
|
|
2269
|
+
interface BaseLegendLayout {
|
|
2149
2270
|
/** Where the legend is positioned relative to the chart area. */
|
|
2150
2271
|
position: 'top' | 'right' | 'bottom' | 'bottom-right' | 'inline';
|
|
2151
|
-
/** Legend entries. */
|
|
2152
|
-
entries: LegendEntry[];
|
|
2153
2272
|
/** Bounding box for the legend (pixel coordinates). */
|
|
2154
2273
|
bounds: Rect;
|
|
2155
2274
|
/** Entry label style. */
|
|
2156
2275
|
labelStyle: TextStyle;
|
|
2276
|
+
}
|
|
2277
|
+
/** Categorical legend with discrete swatch entries. */
|
|
2278
|
+
interface CategoricalLegendLayout extends BaseLegendLayout {
|
|
2279
|
+
/** Discriminant for legend type. Omitted means categorical (backwards compat). */
|
|
2280
|
+
type?: 'categorical';
|
|
2281
|
+
/** Legend entries. */
|
|
2282
|
+
entries: LegendEntry[];
|
|
2157
2283
|
/** Swatch size in pixels. */
|
|
2158
2284
|
swatchSize: number;
|
|
2159
2285
|
/** Gap between swatch and label. */
|
|
@@ -2161,6 +2287,26 @@ interface LegendLayout {
|
|
|
2161
2287
|
/** Gap between entries. */
|
|
2162
2288
|
entryGap: number;
|
|
2163
2289
|
}
|
|
2290
|
+
/** A color stop in a gradient legend. */
|
|
2291
|
+
interface GradientColorStop {
|
|
2292
|
+
/** Position along the gradient (0 to 1). */
|
|
2293
|
+
offset: number;
|
|
2294
|
+
/** CSS color value. */
|
|
2295
|
+
color: string;
|
|
2296
|
+
}
|
|
2297
|
+
/** Gradient legend for continuous color scales. */
|
|
2298
|
+
interface GradientLegendLayout extends BaseLegendLayout {
|
|
2299
|
+
/** Discriminant for legend type. */
|
|
2300
|
+
type: 'gradient';
|
|
2301
|
+
/** Color stops for the gradient bar. */
|
|
2302
|
+
colorStops: GradientColorStop[];
|
|
2303
|
+
/** Formatted minimum value label. */
|
|
2304
|
+
minLabel: string;
|
|
2305
|
+
/** Formatted maximum value label. */
|
|
2306
|
+
maxLabel: string;
|
|
2307
|
+
}
|
|
2308
|
+
/** Resolved legend layout — either categorical (swatches) or gradient (continuous bar). */
|
|
2309
|
+
type LegendLayout = CategoricalLegendLayout | GradientLegendLayout;
|
|
2164
2310
|
/** A single field-value pair in a tooltip. */
|
|
2165
2311
|
interface TooltipField {
|
|
2166
2312
|
/** Field label (e.g. "GDP Growth"). */
|
|
@@ -2244,6 +2390,10 @@ interface ChartLayout {
|
|
|
2244
2390
|
animation?: ResolvedAnimation;
|
|
2245
2391
|
/** Whether the tryOpenData.ai watermark is enabled. */
|
|
2246
2392
|
watermark: boolean;
|
|
2393
|
+
/** Display mode controlling chrome/axes/legend stripping. `'sparkline'` produces an edge-to-edge mini chart. */
|
|
2394
|
+
display: Display;
|
|
2395
|
+
/** Whether the crosshair (vertical snap line) is enabled. */
|
|
2396
|
+
crosshair: boolean;
|
|
2247
2397
|
/** Real text measurement function from the adapter (for accurate SVG text wrapping). */
|
|
2248
2398
|
measureText?: MeasureTextFn;
|
|
2249
2399
|
}
|
|
@@ -2582,6 +2732,74 @@ interface SankeyLayout {
|
|
|
2582
2732
|
/** Real text measurement function from the adapter (for accurate SVG text wrapping). */
|
|
2583
2733
|
measureText?: MeasureTextFn;
|
|
2584
2734
|
}
|
|
2735
|
+
/** A resolved tile map tile with computed position and visual properties. */
|
|
2736
|
+
interface TileMapTileMark {
|
|
2737
|
+
type: 'tile';
|
|
2738
|
+
/** Left edge x position. */
|
|
2739
|
+
x: number;
|
|
2740
|
+
/** Top edge y position. */
|
|
2741
|
+
y: number;
|
|
2742
|
+
/** Tile width and height (tiles are square). */
|
|
2743
|
+
size: number;
|
|
2744
|
+
/** Fill color from the sequential color scale. */
|
|
2745
|
+
fill: string;
|
|
2746
|
+
/** Tile border color. */
|
|
2747
|
+
stroke: string;
|
|
2748
|
+
/** Tile border width. */
|
|
2749
|
+
strokeWidth: number;
|
|
2750
|
+
/** Corner radius. */
|
|
2751
|
+
cornerRadius: number;
|
|
2752
|
+
/** US state abbreviation (e.g. "CA", "TX"). */
|
|
2753
|
+
stateCode: string;
|
|
2754
|
+
/** Numeric value (null if state has no data). */
|
|
2755
|
+
value: number | null;
|
|
2756
|
+
/** Formatted value string (e.g. "12,000" or "–" for missing). */
|
|
2757
|
+
formattedValue: string;
|
|
2758
|
+
/** Whether this state has data. False for missing states. */
|
|
2759
|
+
hasData: boolean;
|
|
2760
|
+
/** State code text label (positioned inside tile). */
|
|
2761
|
+
label: ResolvedLabel;
|
|
2762
|
+
/** Value text label (positioned inside tile, below state code). */
|
|
2763
|
+
valueLabel: ResolvedLabel;
|
|
2764
|
+
/** Accessibility attributes. */
|
|
2765
|
+
aria: MarkAria;
|
|
2766
|
+
/** Index for stagger animation ordering. */
|
|
2767
|
+
animationIndex?: number;
|
|
2768
|
+
/** Original data associated with this tile. */
|
|
2769
|
+
data: Record<string, unknown>;
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* TileMapLayout: the complete engine output for tile map visualizations.
|
|
2773
|
+
*
|
|
2774
|
+
* Contains everything an adapter needs to render the tile map: dimensions,
|
|
2775
|
+
* chrome, tiles, gradient legend, tooltip descriptors, and accessibility metadata.
|
|
2776
|
+
*/
|
|
2777
|
+
interface TileMapLayout {
|
|
2778
|
+
/** The tile map drawing area (after chrome and legend are subtracted). */
|
|
2779
|
+
area: Rect;
|
|
2780
|
+
/** Resolved chrome text elements with positions and styles. */
|
|
2781
|
+
chrome: ResolvedChrome;
|
|
2782
|
+
/** Resolved tile marks with positions, colors, and labels. */
|
|
2783
|
+
tiles: TileMapTileMark[];
|
|
2784
|
+
/** Gradient color legend (null if legend is hidden). */
|
|
2785
|
+
gradientLegend: GradientLegendLayout | null;
|
|
2786
|
+
/** Tooltip content descriptors keyed by state code. */
|
|
2787
|
+
tooltipDescriptors: Map<string, TooltipContent>;
|
|
2788
|
+
/** Accessibility metadata for the tile map. */
|
|
2789
|
+
a11y: A11yMetadata;
|
|
2790
|
+
/** Resolved theme. */
|
|
2791
|
+
theme: ResolvedTheme;
|
|
2792
|
+
/** Total SVG width in pixels. */
|
|
2793
|
+
width: number;
|
|
2794
|
+
/** Total SVG height in pixels. */
|
|
2795
|
+
height: number;
|
|
2796
|
+
/** Resolved animation config (undefined if animation is disabled). */
|
|
2797
|
+
animation: ResolvedAnimation | undefined;
|
|
2798
|
+
/** Whether to render the watermark. */
|
|
2799
|
+
watermark: boolean;
|
|
2800
|
+
/** Text measurement function for the rendering adapter. */
|
|
2801
|
+
measureText: MeasureTextFn;
|
|
2802
|
+
}
|
|
2585
2803
|
/** Function signature for text measurement provided by adapters. */
|
|
2586
2804
|
type MeasureTextFn = (text: string, fontSize: number, fontWeight?: number) => {
|
|
2587
2805
|
width: number;
|
|
@@ -3247,5 +3465,40 @@ declare function scatterChart(data: DataRow[], x: FieldRef, y: FieldRef, options
|
|
|
3247
3465
|
* @param options - Column definitions, chrome, pagination, search, etc.
|
|
3248
3466
|
*/
|
|
3249
3467
|
declare function dataTable(data: DataRow[], options?: TableBuilderOptions): TableSpec;
|
|
3468
|
+
/** Options for the tileMap convenience builder. */
|
|
3469
|
+
interface TileMapBuilderOptions {
|
|
3470
|
+
/** Encoding channels (required when data is DataRow[]). */
|
|
3471
|
+
encoding?: TileMapEncoding;
|
|
3472
|
+
/** Sequential color palette name. */
|
|
3473
|
+
palette?: TileMapPalette;
|
|
3474
|
+
/** Editorial chrome. */
|
|
3475
|
+
chrome?: Chrome;
|
|
3476
|
+
/** Legend display configuration. */
|
|
3477
|
+
legend?: LegendConfig;
|
|
3478
|
+
/** Theme overrides. */
|
|
3479
|
+
theme?: ThemeConfig;
|
|
3480
|
+
/** Dark mode setting. */
|
|
3481
|
+
darkMode?: DarkMode;
|
|
3482
|
+
/** Whether to show the watermark. */
|
|
3483
|
+
watermark?: boolean;
|
|
3484
|
+
/** Animation configuration. */
|
|
3485
|
+
animation?: AnimationSpec;
|
|
3486
|
+
/** d3-format string for value formatting. */
|
|
3487
|
+
valueFormat?: string;
|
|
3488
|
+
}
|
|
3489
|
+
/**
|
|
3490
|
+
* Build a TileMapSpec from a state-to-value record or tabular data.
|
|
3491
|
+
*
|
|
3492
|
+
* @example Record map (simplest):
|
|
3493
|
+
* ```ts
|
|
3494
|
+
* tileMap({ CA: 4.4, TX: 17.6, NY: 4.5 })
|
|
3495
|
+
* ```
|
|
3496
|
+
*
|
|
3497
|
+
* @example Tabular data with encoding:
|
|
3498
|
+
* ```ts
|
|
3499
|
+
* tileMap(data, { encoding: { state: { field: 'code' }, value: { field: 'rate' } } })
|
|
3500
|
+
* ```
|
|
3501
|
+
*/
|
|
3502
|
+
declare function tileMap(data: Record<string, number | null> | DataRow[], options?: TileMapBuilderOptions): TileMapSpec;
|
|
3250
3503
|
|
|
3251
|
-
export { type A11yMetadata, 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 ArcMark, 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 BarTableCell, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, CHART_ENCODING_RULES, CHART_TYPES, COMPACT_WIDTH, type CalculateExpression, type CalculateTransform, 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 ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type Condition, type ConditionalValueDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type FieldPredicate, type FieldRef, type FieldType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GradientDef, 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 LegendLayout, type LegendPosition, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, 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, NARROW_VIEWPORT_MAX, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointMark, type RadialGradient, type RangeAnnotation, type Rect, type RectMark, type RefLineAnnotation, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, 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 TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeSpacing, type TickMarkLayout, type TimeUnit, type TimeUnitTransform, type TooltipContent, type TooltipField, type Transform, type VizSpec, abbreviateNumber, adaptColorForDarkMode, adaptTheme, areaChart, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, contrastRatio, dataTable, detectCollision, donutChart, dotChart, elementRef, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, inferFieldType, isChartSpec, isConditionalDef, isEncodingChannel, isGradientDef, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, lineChart, meetsAA, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveTheme, scatterChart, simulateColorBlindness, wrapText };
|
|
3504
|
+
export { type A11yMetadata, 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 ArcMark, 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 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 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 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 LegendLayout, type LegendPosition, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, 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, NARROW_VIEWPORT_MAX, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointMark, type RadialGradient, type RangeAnnotation, type Rect, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, 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 TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeSpacing, 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, abbreviateNumber, adaptColorForDarkMode, adaptTheme, areaChart, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, contrastRatio, dataTable, detectCollision, donutChart, dotChart, elementRef, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, inferFieldType, isChartSpec, isConditionalDef, isEncodingChannel, isGradientDef, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, lineChart, meetsAA, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveTheme, scatterChart, simulateColorBlindness, tileMap, wrapText };
|
package/dist/index.js
CHANGED
|
@@ -212,6 +212,9 @@ function isGraphSpec(spec) {
|
|
|
212
212
|
function isSankeySpec(spec) {
|
|
213
213
|
return "type" in spec && spec.type === "sankey";
|
|
214
214
|
}
|
|
215
|
+
function isTileMapSpec(spec) {
|
|
216
|
+
return "type" in spec && spec.type === "tilemap";
|
|
217
|
+
}
|
|
215
218
|
function isTextAnnotation(annotation) {
|
|
216
219
|
return annotation.type === "text";
|
|
217
220
|
}
|
|
@@ -2856,6 +2859,21 @@ function dataTable(data, options) {
|
|
|
2856
2859
|
if (options?.responsive !== void 0) spec.responsive = options.responsive;
|
|
2857
2860
|
return spec;
|
|
2858
2861
|
}
|
|
2862
|
+
function tileMap(data, options) {
|
|
2863
|
+
return {
|
|
2864
|
+
type: "tilemap",
|
|
2865
|
+
data,
|
|
2866
|
+
...options?.encoding && { encoding: options.encoding },
|
|
2867
|
+
...options?.palette && { palette: options.palette },
|
|
2868
|
+
...options?.chrome && { chrome: options.chrome },
|
|
2869
|
+
...options?.legend && { legend: options.legend },
|
|
2870
|
+
...options?.theme && { theme: options.theme },
|
|
2871
|
+
...options?.darkMode && { darkMode: options.darkMode },
|
|
2872
|
+
...options?.watermark !== void 0 && { watermark: options.watermark },
|
|
2873
|
+
...options?.animation && { animation: options.animation },
|
|
2874
|
+
...options?.valueFormat && { valueFormat: options.valueFormat }
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2859
2877
|
export {
|
|
2860
2878
|
AXIS_TITLE_OFFSET_COMPACT,
|
|
2861
2879
|
AXIS_TITLE_OFFSET_DEFAULT,
|
|
@@ -2934,6 +2952,7 @@ export {
|
|
|
2934
2952
|
isSankeySpec,
|
|
2935
2953
|
isTableSpec,
|
|
2936
2954
|
isTextAnnotation,
|
|
2955
|
+
isTileMapSpec,
|
|
2937
2956
|
lineChart,
|
|
2938
2957
|
meetsAA,
|
|
2939
2958
|
pieChart,
|
|
@@ -2943,6 +2962,7 @@ export {
|
|
|
2943
2962
|
resolveTheme,
|
|
2944
2963
|
scatterChart,
|
|
2945
2964
|
simulateColorBlindness,
|
|
2965
|
+
tileMap,
|
|
2946
2966
|
wrapText
|
|
2947
2967
|
};
|
|
2948
2968
|
//# sourceMappingURL=index.js.map
|