@opendata-ai/openchart-engine 7.11.0 → 8.0.0-rc.2
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 +123 -14
- package/dist/index.js +16166 -10027
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
- package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +170 -56
- package/src/__tests__/annotation-behavior.test.ts +721 -0
- package/src/__tests__/axes.test.ts +50 -3
- package/src/__tests__/compile-chart.test.ts +30 -0
- package/src/__tests__/compile-footnotes.test.ts +277 -0
- package/src/__tests__/compile-layer.test.ts +120 -1
- package/src/__tests__/helpers/invariants.ts +54 -20
- package/src/__tests__/known-bugs.test.ts +455 -2
- package/src/__tests__/legend.test.ts +69 -4
- package/src/__tests__/ranking-recipes.test.ts +260 -0
- package/src/__tests__/scales.test.ts +9 -3
- package/src/__tests__/series-search.test.ts +92 -0
- package/src/__tests__/spec-sugar.test.ts +801 -0
- package/src/__tests__/you-draw-it.test.ts +160 -0
- package/src/annotations/__tests__/compute.test.ts +207 -92
- package/src/annotations/__tests__/geometry.test.ts +66 -0
- package/src/annotations/__tests__/resolve-text.test.ts +527 -27
- package/src/annotations/__tests__/rich-text.test.ts +91 -0
- package/src/annotations/__tests__/thinning.test.ts +148 -0
- package/src/annotations/collisions.ts +130 -84
- package/src/annotations/compute.ts +83 -85
- package/src/annotations/constants.ts +116 -6
- package/src/annotations/geometry.ts +222 -77
- package/src/annotations/move.ts +135 -0
- package/src/annotations/placement.ts +62 -14
- package/src/annotations/resolve-range.ts +2 -0
- package/src/annotations/resolve-refline.ts +2 -0
- package/src/annotations/resolve-text.ts +312 -111
- package/src/annotations/rich-text.ts +65 -0
- package/src/annotations/thinning.ts +84 -10
- package/src/barlist/compile-barlist.ts +16 -6
- package/src/charts/_shared/format-label-value.ts +9 -8
- package/src/charts/bar/__tests__/compute.test.ts +57 -10
- package/src/charts/bar/__tests__/labels.test.ts +5 -4
- package/src/charts/bar/compute.ts +2 -6
- package/src/charts/bar/index.ts +8 -1
- package/src/charts/bar/labels.ts +3 -3
- package/src/charts/beeswarm/__tests__/compute.test.ts +280 -0
- package/src/charts/beeswarm/__tests__/dodge.test.ts +148 -0
- package/src/charts/beeswarm/compute.ts +203 -0
- package/src/charts/beeswarm/dodge.ts +155 -0
- package/src/charts/beeswarm/index.ts +32 -0
- package/src/charts/builtin.ts +12 -1
- package/src/charts/calendar/__tests__/compute.test.ts +417 -0
- package/src/charts/calendar/compute.ts +319 -0
- package/src/charts/calendar/index.ts +32 -0
- package/src/charts/column/__tests__/compute.test.ts +21 -7
- package/src/charts/column/__tests__/labels.test.ts +76 -1
- package/src/charts/column/compute.ts +2 -6
- package/src/charts/column/index.ts +10 -2
- package/src/charts/column/labels.ts +95 -21
- package/src/charts/dot/index.ts +8 -1
- package/src/charts/dot/labels.ts +3 -3
- package/src/charts/line/__tests__/compute.test.ts +15 -19
- package/src/charts/line/area.ts +8 -23
- package/src/charts/line/compute.ts +32 -2
- package/src/charts/parliament/__tests__/compute.test.ts +411 -0
- package/src/charts/parliament/compute.ts +313 -0
- package/src/charts/parliament/index.ts +32 -0
- package/src/charts/pie/__tests__/compute.test.ts +103 -0
- package/src/charts/pie/compute.ts +63 -8
- package/src/charts/pie/labels.ts +1 -0
- package/src/charts/range/__tests__/compute.test.ts +486 -0
- package/src/charts/range/compute.ts +273 -0
- package/src/charts/range/index.ts +82 -0
- package/src/charts/range/labels.ts +169 -0
- package/src/charts/rect/__tests__/compute.test.ts +120 -0
- package/src/charts/rect/index.ts +127 -0
- package/src/charts/scatter/compute.ts +7 -21
- package/src/charts/text/__tests__/compute.test.ts +307 -0
- package/src/charts/text/index.ts +44 -7
- package/src/charts/tick/__tests__/compute.test.ts +75 -0
- package/src/charts/tick/index.ts +7 -4
- package/src/charts/utils.ts +5 -3
- package/src/charts/waffle/__tests__/compute.test.ts +305 -0
- package/src/charts/waffle/compute.ts +197 -0
- package/src/charts/waffle/index.ts +31 -0
- package/src/compile/__tests__/color-scale-reverse.test.ts +89 -0
- package/src/compile/__tests__/data-clip.test.ts +68 -0
- package/src/compile/__tests__/fill-patterns.test.ts +154 -0
- package/src/compile/__tests__/size-scale.test.ts +108 -0
- package/src/compile/color-scale-range.ts +54 -33
- package/src/compile/data-clip.ts +21 -6
- package/src/compile/fill-patterns.ts +74 -0
- package/src/compile/layer.ts +117 -21
- package/src/compile/size-scale.ts +139 -0
- package/src/compile/spec-sugar.ts +758 -0
- package/src/compile/you-draw-it.ts +123 -0
- package/src/compile.ts +310 -103
- package/src/compiler/__tests__/a11y-warnings.test.ts +148 -0
- package/src/compiler/__tests__/fixtures/vl-parity/axis-null.json +19 -0
- package/src/compiler/__tests__/fixtures/vl-parity/color-value.json +20 -0
- package/src/compiler/__tests__/fixtures/vl-parity/count-aggregate.json +22 -0
- package/src/compiler/__tests__/fixtures/vl-parity/data-values.json +19 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-axis-null.json +14 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-count.json +34 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-data-values.json +22 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-legend-null.json +41 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-scheme.json +38 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-sort.json +28 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-theta.json +28 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-title.json +30 -0
- package/src/compiler/__tests__/fixtures/vl-parity/layer-value-def.json +29 -0
- package/src/compiler/__tests__/fixtures/vl-parity/legend-null.json +32 -0
- package/src/compiler/__tests__/fixtures/vl-parity/scheme.json +25 -0
- package/src/compiler/__tests__/fixtures/vl-parity/sort-by-value.json +19 -0
- package/src/compiler/__tests__/fixtures/vl-parity/theta-arc.json +19 -0
- package/src/compiler/__tests__/fixtures/vl-parity/title-subtitle.json +21 -0
- package/src/compiler/__tests__/fixtures/vl-parity/width-height.json +23 -0
- package/src/compiler/__tests__/keys.test.ts +3 -9
- package/src/compiler/__tests__/normalize.test.ts +65 -1
- package/src/compiler/__tests__/validate-did-you-mean.test.ts +86 -0
- package/src/compiler/__tests__/validate-near-miss.test.ts +89 -0
- package/src/compiler/__tests__/validate.test.ts +156 -0
- package/src/compiler/__tests__/vl-parity.test.ts +68 -0
- package/src/compiler/a11y-warnings.ts +110 -0
- package/src/compiler/keys.ts +5 -4
- package/src/compiler/normalize.ts +150 -7
- package/src/compiler/types.ts +11 -0
- package/src/compiler/validate.ts +664 -18
- package/src/endpoint-labels/__tests__/compute.test.ts +88 -0
- package/src/endpoint-labels/compute.ts +40 -12
- package/src/endpoint-labels/format.ts +45 -15
- package/src/endpoint-labels/predict.ts +50 -36
- package/src/format/__tests__/field-format.test.ts +164 -0
- package/src/format/field-format.ts +27 -0
- package/src/geo/__tests__/compile-map.test.ts +621 -0
- package/src/geo/compile-map.ts +856 -0
- package/src/geo/join.ts +115 -0
- package/src/geo/projections.ts +45 -0
- package/src/geo/types.ts +24 -0
- package/src/graphs/__tests__/compile-graph.test.ts +25 -0
- package/src/graphs/compile-graph.ts +27 -18
- package/src/index.ts +20 -2
- package/src/layout/axes/ticks.ts +59 -10
- package/src/layout/axes.ts +35 -6
- package/src/layout/dimensions.ts +139 -83
- package/src/layout/facet.ts +14 -3
- package/src/layout/plan.ts +83 -33
- package/src/layout/scales.ts +132 -15
- package/src/legend/__tests__/continuous.test.ts +318 -0
- package/src/legend/__tests__/size.test.ts +348 -0
- package/src/legend/__tests__/suppression.test.ts +17 -1
- package/src/legend/compute.ts +119 -13
- package/src/legend/continuous.ts +327 -0
- package/src/legend/size.ts +407 -0
- package/src/legend/suppression.ts +8 -7
- package/src/sankey/compile-sankey.ts +31 -19
- package/src/tables/format-cells.ts +16 -7
- package/src/tilemap/__tests__/compile-tilemap.test.ts +39 -0
- package/src/tilemap/compile-tilemap.ts +24 -7
- package/src/tooltips/__tests__/compute.test.ts +2 -2
- package/src/tooltips/compute.ts +422 -41
- package/src/transforms/__tests__/conditional.test.ts +18 -0
- package/src/transforms/aggregate.ts +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
|
|
2
|
-
import { LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode,
|
|
3
|
-
export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
2
|
+
import { LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode, MapGeo, MapEncoding, LegendConfig, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, ScaleType, EncodingChannel, FieldFormatContext, Rect, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
|
|
3
|
+
export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, MapLayout, MapSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
4
4
|
import { ScaleLinear, ScaleTime, ScaleLogarithmic, ScalePower, ScaleSymLog, ScaleBand, ScalePoint, ScaleOrdinal, ScaleQuantile, ScaleQuantize, ScaleThreshold } from 'd3-scale';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -113,11 +113,12 @@ interface GraphCompilation {
|
|
|
113
113
|
* ChartLayout with positions, colors, and marks ready for rendering.
|
|
114
114
|
*
|
|
115
115
|
* @param spec - Raw chart spec (validated and normalized internally).
|
|
116
|
-
* @param
|
|
116
|
+
* @param optionsInput - Compile options (width, height, theme, darkMode).
|
|
117
|
+
* Top-level spec width/height, when present, override the option values.
|
|
117
118
|
* @returns ChartLayout with all computed positions.
|
|
118
119
|
* @throws Error if spec is invalid or not a chart type.
|
|
119
120
|
*/
|
|
120
|
-
declare function compileChart(spec: unknown,
|
|
121
|
+
declare function compileChart(spec: unknown, optionsInput: CompileOptions): ChartLayout;
|
|
121
122
|
declare function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLayout;
|
|
122
123
|
/**
|
|
123
124
|
* Compile a table spec into a TableLayout.
|
|
@@ -171,6 +172,19 @@ declare function compileSankey(spec: unknown, options: CompileOptions): _opendat
|
|
|
171
172
|
* @throws Error if spec is invalid or not a tilemap type.
|
|
172
173
|
*/
|
|
173
174
|
declare function compileTileMap(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.TileMapLayout;
|
|
175
|
+
/**
|
|
176
|
+
* Compile a map spec into a MapLayout.
|
|
177
|
+
*
|
|
178
|
+
* Takes a raw map spec, validates, normalizes, resolves theme and chrome,
|
|
179
|
+
* projects geo features, joins data, builds feature marks with color fills,
|
|
180
|
+
* and returns a MapLayout ready for rendering.
|
|
181
|
+
*
|
|
182
|
+
* @param spec - Raw map spec (validated and normalized internally).
|
|
183
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
184
|
+
* @returns MapLayout with computed positions and visual properties.
|
|
185
|
+
* @throws Error if spec is invalid or not a map type.
|
|
186
|
+
*/
|
|
187
|
+
declare function compileMap(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.MapLayout;
|
|
174
188
|
/**
|
|
175
189
|
* Compile a barlist spec into a BarListLayout.
|
|
176
190
|
*
|
|
@@ -232,13 +246,6 @@ declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
|
232
246
|
* - null/undefined -> null sentinel
|
|
233
247
|
*/
|
|
234
248
|
declare function serializeKeyValue(v: unknown): string;
|
|
235
|
-
/**
|
|
236
|
-
* Append occurrence suffixes to duplicate keys, in order.
|
|
237
|
-
*
|
|
238
|
-
* Only keys that appear more than once get suffixed. Unique keys pass
|
|
239
|
-
* through unchanged so keys remain human-readable when possible.
|
|
240
|
-
* Uses SOH (\x01) as separator to avoid collisions with real data values.
|
|
241
|
-
*/
|
|
242
249
|
declare function dedupeKeys(keys: string[]): string[];
|
|
243
250
|
|
|
244
251
|
/**
|
|
@@ -282,6 +289,20 @@ interface NormalizedBarListSpec {
|
|
|
282
289
|
valueFormat?: string;
|
|
283
290
|
}
|
|
284
291
|
|
|
292
|
+
interface NormalizedMapSpec {
|
|
293
|
+
type: 'map';
|
|
294
|
+
geo: Required<MapGeo>;
|
|
295
|
+
data: Record<string, unknown>[];
|
|
296
|
+
encoding: MapEncoding;
|
|
297
|
+
chrome: NormalizedChrome;
|
|
298
|
+
legend?: LegendConfig;
|
|
299
|
+
theme: ThemeConfig;
|
|
300
|
+
darkMode: DarkMode;
|
|
301
|
+
watermark: boolean;
|
|
302
|
+
animation?: AnimationSpec;
|
|
303
|
+
valueFormat?: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
285
306
|
/**
|
|
286
307
|
* Internal normalized tilemap spec type used by the compilation pipeline.
|
|
287
308
|
*
|
|
@@ -356,6 +377,13 @@ interface NormalizedChartSpec {
|
|
|
356
377
|
chrome: NormalizedChrome;
|
|
357
378
|
/** Optional KPI metric cells, passed through unchanged. */
|
|
358
379
|
metrics?: _opendata_ai_openchart_core.Metric[];
|
|
380
|
+
/**
|
|
381
|
+
* Searchable series highlight config. Present only when `seriesSearch` is
|
|
382
|
+
* enabled AND the spec has a categorical color encoding to search over.
|
|
383
|
+
*/
|
|
384
|
+
seriesSearch?: _opendata_ai_openchart_core.SeriesSearchConfig;
|
|
385
|
+
/** Resolved "you draw it" config with defaults filled in. Present only when `youDrawIt` is enabled. */
|
|
386
|
+
youDrawIt?: _opendata_ai_openchart_core.YouDrawItConfig;
|
|
359
387
|
annotations: Annotation[];
|
|
360
388
|
/** Normalized label configuration with defaults applied. density, format, and prefix are always set; offsets and color stay optional. */
|
|
361
389
|
labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, 'offsets' | 'color' | 'fontSize' | 'suffix'>;
|
|
@@ -374,6 +402,8 @@ interface NormalizedChartSpec {
|
|
|
374
402
|
hiddenSeries: string[];
|
|
375
403
|
/** Per-series visual style overrides. */
|
|
376
404
|
seriesStyles: Record<string, _opendata_ai_openchart_core.SeriesStyle>;
|
|
405
|
+
/** Author accessibility overrides (alt-text description, aria-hidden opt-out). */
|
|
406
|
+
a11y?: _opendata_ai_openchart_core.A11yConfig;
|
|
377
407
|
/** Display mode controlling chrome/axes/legend stripping. Defaults to `'full'`. */
|
|
378
408
|
display: Display;
|
|
379
409
|
/** Resolve configuration for independent/shared scales in faceted charts. */
|
|
@@ -425,7 +455,7 @@ interface NormalizedGraphSpec {
|
|
|
425
455
|
watermark: boolean;
|
|
426
456
|
}
|
|
427
457
|
/** Discriminated union of all normalized spec types. */
|
|
428
|
-
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedBarListSpec;
|
|
458
|
+
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedMapSpec | NormalizedBarListSpec;
|
|
429
459
|
/** Machine-readable error code for programmatic handling. */
|
|
430
460
|
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
431
461
|
/** A single validation error with context. */
|
|
@@ -509,6 +539,8 @@ interface ResolvedScale {
|
|
|
509
539
|
type: ResolvedScaleType;
|
|
510
540
|
/** The encoding channel this scale was derived from. */
|
|
511
541
|
channel: EncodingChannel;
|
|
542
|
+
/** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
|
|
543
|
+
formatContext?: FieldFormatContext;
|
|
512
544
|
}
|
|
513
545
|
/** All resolved scales for a chart. */
|
|
514
546
|
interface ResolvedScales {
|
|
@@ -520,16 +552,66 @@ interface ResolvedScales {
|
|
|
520
552
|
defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
|
|
521
553
|
}
|
|
522
554
|
|
|
555
|
+
/** Default font size for annotation labels. */
|
|
556
|
+
declare const DEFAULT_ANNOTATION_FONT_SIZE = 13;
|
|
557
|
+
/** Default line height multiplier for annotation text. */
|
|
558
|
+
declare const DEFAULT_LINE_HEIGHT = 1.3;
|
|
559
|
+
/**
|
|
560
|
+
* Arrowhead length along the tangent. The renderer pulls the connector's line end
|
|
561
|
+
* back by exactly this much so the stroke stops at the open V instead of poking
|
|
562
|
+
* through its tip — a hand-copied duplicate on the vanilla side would silently
|
|
563
|
+
* drift the next time this changes.
|
|
564
|
+
*/
|
|
565
|
+
declare const ARROWHEAD_LENGTH = 7;
|
|
566
|
+
|
|
523
567
|
/**
|
|
524
568
|
* Geometry utilities for annotation text bounds, connector origins, and offsets.
|
|
525
569
|
*/
|
|
526
570
|
|
|
571
|
+
/**
|
|
572
|
+
* Measure one run of text at a given size and weight.
|
|
573
|
+
*
|
|
574
|
+
* Deliberately takes no `fontFamily`: neither implementation could use one.
|
|
575
|
+
* `heuristicMeasure` below is family-blind, and the real canvas measurer gets its
|
|
576
|
+
* family from the `createMeasureText(fontFamily)` closure, not per call -- so a
|
|
577
|
+
* family passed here would be silently dropped while implying the opposite.
|
|
578
|
+
* `style.fontFamily` on a *resolved label* is a different thing: that one is real
|
|
579
|
+
* and gets rendered.
|
|
580
|
+
*/
|
|
527
581
|
type AnnotationMeasureTextFn = (text: string, font: {
|
|
528
582
|
fontSize: number;
|
|
529
583
|
fontWeight: number;
|
|
530
|
-
fontFamily?: string;
|
|
531
584
|
}) => number;
|
|
532
585
|
declare const heuristicMeasure: AnnotationMeasureTextFn;
|
|
586
|
+
/** Arrowhead triangle points: tip + two base corners. */
|
|
587
|
+
interface ArrowheadPoints {
|
|
588
|
+
tip: {
|
|
589
|
+
x: number;
|
|
590
|
+
y: number;
|
|
591
|
+
};
|
|
592
|
+
baseLeft: {
|
|
593
|
+
x: number;
|
|
594
|
+
y: number;
|
|
595
|
+
};
|
|
596
|
+
baseRight: {
|
|
597
|
+
x: number;
|
|
598
|
+
y: number;
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Compute arrowhead triangle geometry at a connector endpoint.
|
|
604
|
+
* Returns the tip (at the endpoint) and two base corners perpendicular to the
|
|
605
|
+
* tangent direction.
|
|
606
|
+
*
|
|
607
|
+
* @param tipX - X coordinate of the arrowhead tip
|
|
608
|
+
* @param tipY - Y coordinate of the arrowhead tip
|
|
609
|
+
* @param tangentX - X component of the tangent direction (toward the tip)
|
|
610
|
+
* @param tangentY - Y component of the tangent direction (toward the tip)
|
|
611
|
+
* @param length - Arrow length along the tangent (default ARROWHEAD_LENGTH)
|
|
612
|
+
* @param halfWidth - Arrow half-width perpendicular to tangent (default ARROWHEAD_HALF_WIDTH)
|
|
613
|
+
*/
|
|
614
|
+
declare function computeArrowheadPoints(tipX: number, tipY: number, tangentX: number, tangentY: number, length?: number, halfWidth?: number): ArrowheadPoints;
|
|
533
615
|
|
|
534
616
|
/**
|
|
535
617
|
* Annotation placement engine: typed obstacles, candidate generation,
|
|
@@ -565,11 +647,36 @@ interface AnnotationContext {
|
|
|
565
647
|
height: number;
|
|
566
648
|
};
|
|
567
649
|
measure: AnnotationMeasureTextFn;
|
|
650
|
+
/** Theme font stack, so annotation text is measured and rendered in the same face. */
|
|
651
|
+
fontFamily?: string;
|
|
568
652
|
debugPlacement?: boolean;
|
|
569
653
|
/** When true, annotations that overlap are demoted to footnote markers instead of being hidden. */
|
|
570
654
|
autoThin?: boolean;
|
|
571
655
|
}
|
|
572
656
|
|
|
657
|
+
/**
|
|
658
|
+
* Inline rich text for annotation labels: `**bold**` spans inside an otherwise
|
|
659
|
+
* regular-weight sentence. This is the NYT/Datawrapper voice — emphasis lands on
|
|
660
|
+
* the key phrase, not on the whole block.
|
|
661
|
+
*/
|
|
662
|
+
/** One run of annotation text at a single weight. */
|
|
663
|
+
interface RichSpan {
|
|
664
|
+
text: string;
|
|
665
|
+
bold: boolean;
|
|
666
|
+
}
|
|
667
|
+
/** Weight bold spans are measured and rendered at. */
|
|
668
|
+
declare const BOLD_SPAN_FONT_WEIGHT = 700;
|
|
669
|
+
/**
|
|
670
|
+
* Parse `**bold**` markers in a single line of annotation text.
|
|
671
|
+
*
|
|
672
|
+
* Only matched pairs turn bold; an unmatched `**` renders literally, so specs
|
|
673
|
+
* that legitimately contain asterisks are never mangled. Empty `****` also
|
|
674
|
+
* renders literally (there's nothing to emphasize).
|
|
675
|
+
*
|
|
676
|
+
* The line is expected to be a single line — callers split on `\n` first.
|
|
677
|
+
*/
|
|
678
|
+
declare function parseAnnotationSpans(line: string): RichSpan[];
|
|
679
|
+
|
|
573
680
|
/**
|
|
574
681
|
* Normalize a validated VizSpec, filling in all defaults.
|
|
575
682
|
*
|
|
@@ -658,6 +765,8 @@ declare function getChartRenderer(type: string): ChartRenderer | undefined;
|
|
|
658
765
|
*/
|
|
659
766
|
declare function clearRenderers(): void;
|
|
660
767
|
|
|
768
|
+
declare function facetMinHeight(panelCount: number, columns: number): number;
|
|
769
|
+
|
|
661
770
|
/**
|
|
662
771
|
* Legend row-wrap geometry.
|
|
663
772
|
*
|
|
@@ -811,4 +920,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
811
920
|
*/
|
|
812
921
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
813
922
|
|
|
814
|
-
export { type AnnotationContext, type AnnotationMeasureTextFn, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, ENTER_DEFAULTS, EXIT_DEFAULTS, type GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type SimulationConfig, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, buildAreaPath, buildLinePath, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, dedupeKeys, evaluatePredicate, getChartRenderer, heuristicMeasure, isConditionalValueDef, legendGap, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };
|
|
923
|
+
export { ARROWHEAD_LENGTH, type AnnotationContext, type AnnotationMeasureTextFn, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedMapSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type RichSpan, type SimulationConfig, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, buildAreaPath, buildLinePath, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileMap, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, dedupeKeys, evaluatePredicate, facetMinHeight, getChartRenderer, heuristicMeasure, isConditionalValueDef, legendGap, normalizeSpec, parseAnnotationSpans, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };
|