@opendata-ai/openchart-engine 8.8.0 → 8.9.1
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 -33
- package/dist/index.js +2853 -892
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
|
|
2
|
-
import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, GeoMapPointsLayer, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, ScaleType, EncodingChannel, FieldFormatContext, Rect, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
|
|
2
|
+
import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, GeoMapPointsLayer, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, ScaleType, EncodingChannel, FieldFormatContext, ResolvedLabel, Rect, ResolvedAnnotation, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform, ElementRef, TextAnnotation, ChartSpec, DesignDiagnostic, FieldMetadata, DatasetBinding, ReaderSelection, ObservationIdentity, SpecPatch, CompositionRecommendation, DesignQuestion } from '@opendata-ai/openchart-core';
|
|
3
3
|
export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GeoMapLayout, GeoMapSpec, GraphLayout, GraphSpec, LayerSpec, 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
|
|
|
@@ -584,6 +584,7 @@ interface NormalizedChartSpec {
|
|
|
584
584
|
responsive: boolean;
|
|
585
585
|
/** Whether auto-thinning of annotations at narrow widths is enabled. Resolved from `responsive.autoThin`. */
|
|
586
586
|
autoThin: boolean;
|
|
587
|
+
compactAnnotationLimit?: number | null;
|
|
587
588
|
theme: ThemeConfig;
|
|
588
589
|
darkMode: DarkMode;
|
|
589
590
|
/** Whether the OpenData watermark is enabled. */
|
|
@@ -681,6 +682,8 @@ interface ValidationError {
|
|
|
681
682
|
}
|
|
682
683
|
/** Result of spec validation. */
|
|
683
684
|
interface ValidationResult {
|
|
685
|
+
/** Advisory authored-option warnings; incompatible options remain accepted in 8.x. */
|
|
686
|
+
warnings?: string[];
|
|
684
687
|
/** Whether the spec is valid. */
|
|
685
688
|
valid: boolean;
|
|
686
689
|
/** Validation errors (empty if valid). */
|
|
@@ -813,6 +816,28 @@ interface ArrowheadPoints {
|
|
|
813
816
|
* @param halfWidth - Arrow half-width perpendicular to tangent (default ARROWHEAD_HALF_WIDTH)
|
|
814
817
|
*/
|
|
815
818
|
declare function computeArrowheadPoints(tipX: number, tipY: number, tangentX: number, tangentY: number, length?: number, halfWidth?: number): ArrowheadPoints;
|
|
819
|
+
/**
|
|
820
|
+
* Rebuild a connector's geometry against a (possibly moved) annotation bounds.
|
|
821
|
+
*
|
|
822
|
+
* `from` comes from the ray-box exit; `to` is recomputed by pulling back from
|
|
823
|
+
* `connector.endpoint` — never from the already-pulled-back `to`, which would
|
|
824
|
+
* shrink the line a little more on every pass.
|
|
825
|
+
*
|
|
826
|
+
* Returns `undefined` when the connector should be suppressed: the target sits
|
|
827
|
+
* inside the text block, or the resulting line is shorter than
|
|
828
|
+
* `MIN_CONNECTOR_LENGTH`.
|
|
829
|
+
*/
|
|
830
|
+
declare function automaticControlPoint(from: {
|
|
831
|
+
x: number;
|
|
832
|
+
y: number;
|
|
833
|
+
}, to: {
|
|
834
|
+
x: number;
|
|
835
|
+
y: number;
|
|
836
|
+
}, exit?: 'horizontal' | 'vertical', bend?: number): {
|
|
837
|
+
x: number;
|
|
838
|
+
y: number;
|
|
839
|
+
};
|
|
840
|
+
declare function refreshConnector(connector: NonNullable<ResolvedLabel['connector']>, bounds: Rect, markerRadius: number, keepVisible?: boolean): ResolvedLabel['connector'];
|
|
816
841
|
|
|
817
842
|
/**
|
|
818
843
|
* Annotation placement engine: typed obstacles, candidate generation,
|
|
@@ -824,22 +849,22 @@ interface PlacementObstacle extends Rect {
|
|
|
824
849
|
kind: ObstacleKind;
|
|
825
850
|
}
|
|
826
851
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
* Supports fine-grained positioning via offset, anchor, connector, and zIndex.
|
|
837
|
-
* At compact breakpoints, annotations are simplified or hidden.
|
|
838
|
-
*/
|
|
852
|
+
interface ReferenceReserve {
|
|
853
|
+
right: number;
|
|
854
|
+
top: number;
|
|
855
|
+
labelWidth: number;
|
|
856
|
+
}
|
|
857
|
+
interface ReferenceLanes {
|
|
858
|
+
rightLabels?: ResolvedAnnotation[];
|
|
859
|
+
topBottom?: number;
|
|
860
|
+
}
|
|
839
861
|
|
|
840
862
|
interface AnnotationContext {
|
|
841
863
|
scales: ResolvedScales;
|
|
842
864
|
chartArea: Rect;
|
|
865
|
+
referenceContainer?: Rect;
|
|
866
|
+
referenceLanes?: ReferenceLanes;
|
|
867
|
+
referenceReserve?: ReferenceReserve;
|
|
843
868
|
strategy: LayoutStrategy;
|
|
844
869
|
isDark: boolean;
|
|
845
870
|
obstacles: PlacementObstacle[];
|
|
@@ -850,7 +875,9 @@ interface AnnotationContext {
|
|
|
850
875
|
measure: AnnotationMeasureTextFn;
|
|
851
876
|
/** Theme font stack, so annotation text is measured and rendered in the same face. */
|
|
852
877
|
fontFamily?: string;
|
|
878
|
+
colors?: _opendata_ai_openchart_core.ThemeColors;
|
|
853
879
|
debugPlacement?: boolean;
|
|
880
|
+
onWarn?: (message: string) => void;
|
|
854
881
|
/** When true, annotations that overlap are demoted to footnote markers instead of being hidden. */
|
|
855
882
|
autoThin?: boolean;
|
|
856
883
|
/**
|
|
@@ -893,24 +920,7 @@ declare function parseAnnotationSpans(line: string): RichSpan[];
|
|
|
893
920
|
*/
|
|
894
921
|
declare function normalizeSpec(spec: VizSpec, warnings?: string[]): NormalizedSpec;
|
|
895
922
|
|
|
896
|
-
/**
|
|
897
|
-
* Runtime spec validation.
|
|
898
|
-
*
|
|
899
|
-
* TypeScript catches compile-time errors for specs written in code.
|
|
900
|
-
* This module catches runtime errors for specs coming from JSON, APIs,
|
|
901
|
-
* or Claude-generated output where the TypeScript compiler can't help.
|
|
902
|
-
*
|
|
903
|
-
* Every error includes a machine-readable code and an actionable suggestion
|
|
904
|
-
* so consumers (and LLMs) can fix issues programmatically.
|
|
905
|
-
*/
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Validate a spec at runtime.
|
|
909
|
-
*
|
|
910
|
-
* Checks structure, required fields, encoding rules, data shape, and
|
|
911
|
-
* field type compatibility. Returns structured errors with machine-readable
|
|
912
|
-
* codes and actionable suggestions for each problem found.
|
|
913
|
-
*/
|
|
923
|
+
/** Validation warnings remain advisory throughout 8.x. */
|
|
914
924
|
declare function validateSpec(spec: unknown): ValidationResult;
|
|
915
925
|
|
|
916
926
|
/**
|
|
@@ -928,7 +938,9 @@ declare function validateSpec(spec: unknown): ValidationResult;
|
|
|
928
938
|
* @returns CompileResult with the normalized spec and any warnings.
|
|
929
939
|
* @throws Error if the spec is invalid.
|
|
930
940
|
*/
|
|
931
|
-
declare function compile(spec: unknown
|
|
941
|
+
declare function compile(spec: unknown, options?: {
|
|
942
|
+
markOptionWarnings?: boolean;
|
|
943
|
+
}): CompileResult;
|
|
932
944
|
|
|
933
945
|
/**
|
|
934
946
|
* Resolve which backend paints a chart's point marks: SVG (one `<circle>` per
|
|
@@ -1146,4 +1158,82 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
1146
1158
|
*/
|
|
1147
1159
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
1148
1160
|
|
|
1149
|
-
|
|
1161
|
+
/** Frozen, engine-owned geometry for a single annotation editing gesture. */
|
|
1162
|
+
|
|
1163
|
+
/** Opaque gesture snapshot. Create a new context after a committed edit or resize. */
|
|
1164
|
+
interface AnnotationEditContext {
|
|
1165
|
+
readonly kind: 'annotation-edit-context';
|
|
1166
|
+
}
|
|
1167
|
+
/** Snapshot a compiled layout without asking callers to reconstruct scales or obstacles. */
|
|
1168
|
+
declare function createAnnotationEditContext(layout: ChartLayout, spec: unknown): AnnotationEditContext;
|
|
1169
|
+
/** Convert the rendered block box to an explicit placement, preserving its alignment. */
|
|
1170
|
+
declare function inverseLabelPlacement(ctx: AnnotationEditContext, ref: ElementRef, renderedBox: Rect): Pick<TextAnnotation, 'anchor' | 'offset' | 'responsive'>;
|
|
1171
|
+
/** Move only the label block; keep its data anchor and the surrounding layout frozen. */
|
|
1172
|
+
declare function previewAnnotationMove(ctx: AnnotationEditContext, ref: ElementRef, delta: {
|
|
1173
|
+
dx: number;
|
|
1174
|
+
dy: number;
|
|
1175
|
+
}): ResolvedAnnotation;
|
|
1176
|
+
/** Change a curve without moving its label, attachment, or marker. */
|
|
1177
|
+
declare function previewConnectorBend(ctx: AnnotationEditContext, ref: ElementRef, bend: number): ResolvedAnnotation;
|
|
1178
|
+
/** Preview a connector endpoint nudge without parsing rendered path geometry. */
|
|
1179
|
+
declare function previewConnectorOffset(ctx: AnnotationEditContext, ref: ElementRef, end: 'from' | 'to', delta: {
|
|
1180
|
+
dx: number;
|
|
1181
|
+
dy: number;
|
|
1182
|
+
}): ResolvedAnnotation;
|
|
1183
|
+
|
|
1184
|
+
/** Sample label and attachment independently. Leader visibility is chosen by the final layout. */
|
|
1185
|
+
declare function interpolateAnnotationGeometry(before: ResolvedAnnotation, after: ResolvedAnnotation, t: number): ResolvedAnnotation;
|
|
1186
|
+
|
|
1187
|
+
/** Checks use resolved geometry and authored metadata, never headline interpretation. */
|
|
1188
|
+
declare function diagnoseChart(spec: ChartSpec, layout: ChartLayout): DesignDiagnostic[];
|
|
1189
|
+
|
|
1190
|
+
/** Type-tagging avoids collisions between e.g. 1 and "1". Missing keys are invalid. */
|
|
1191
|
+
declare function observationKey(value: unknown): string | null;
|
|
1192
|
+
declare function resolveObservationIdentities(data: DataRow[], keyField?: string, seriesField?: string): ObservationIdentity[];
|
|
1193
|
+
/** Filtering supplies all rows plus visible keys; deletion supplies a new full dataset. */
|
|
1194
|
+
declare function reconcileReaderSelection(selection: ReaderSelection, rows: DataRow[], keyField?: string, seriesField?: string, visibleKeys?: ReadonlySet<string>): ReaderSelection;
|
|
1195
|
+
interface ObservationComparison {
|
|
1196
|
+
absolute: number;
|
|
1197
|
+
relative?: number;
|
|
1198
|
+
unit?: string;
|
|
1199
|
+
}
|
|
1200
|
+
/** Explicit metadata is required across views; same-field callers can share it. */
|
|
1201
|
+
declare function compareObservations(before: number, after: number, a: FieldMetadata, b: FieldMetadata): ObservationComparison | null;
|
|
1202
|
+
declare function linkedEntityKeys(row: DataRow, source: DatasetBinding, target: DatasetBinding): string[];
|
|
1203
|
+
|
|
1204
|
+
/** JSON-pointer patch application is atomic: validate all paths before returning a new document. */
|
|
1205
|
+
declare function applySpecPatch(spec: VizSpec, patch: SpecPatch): VizSpec;
|
|
1206
|
+
|
|
1207
|
+
interface RecommendationRoles {
|
|
1208
|
+
measure?: string;
|
|
1209
|
+
category?: string;
|
|
1210
|
+
time?: string;
|
|
1211
|
+
secondMeasure?: string;
|
|
1212
|
+
series?: string;
|
|
1213
|
+
}
|
|
1214
|
+
interface RecommendationResult {
|
|
1215
|
+
recommendations: CompositionRecommendation[];
|
|
1216
|
+
missingRoles: string[];
|
|
1217
|
+
explanation?: string;
|
|
1218
|
+
}
|
|
1219
|
+
/** Deterministic suggestions require an explicit question and field roles. No aggregation is inferred. */
|
|
1220
|
+
declare function recommendCompositions(data: DataRow[], question: DesignQuestion, roles: RecommendationRoles): RecommendationResult;
|
|
1221
|
+
|
|
1222
|
+
/** A documented authored-spec change made by migrateSpecV8. */
|
|
1223
|
+
interface SpecRepair {
|
|
1224
|
+
path: string;
|
|
1225
|
+
from: unknown;
|
|
1226
|
+
to: unknown;
|
|
1227
|
+
reason: string;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Rewrite v8 aliases without mutating the input. Safe to run repeatedly.
|
|
1231
|
+
* Legacy end-of-line labels become endpoint labels; their manual offsets are
|
|
1232
|
+
* reported as lost repairs because the two placement models are different.
|
|
1233
|
+
*/
|
|
1234
|
+
declare function migrateSpecV8<T>(input: T): {
|
|
1235
|
+
spec: T;
|
|
1236
|
+
repairs: SpecRepair[];
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, 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, MAX_3D_NODES, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObstacleKind, type PlacementObstacle, type RecommendationResult, type RecommendationRoles, type RichSpan, type SimulationConfig, type SpecRepair, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildLinePath, clampStaggerDelay, clearRenderers, compareObservations, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, getChartRenderer, heuristicMeasure, interpolateAnnotationGeometry, inverseLabelPlacement, isConditionalValueDef, legendGap, linkedEntityKeys, migrateSpecV8, normalizeSpec, observationKey, parseAnnotationSpans, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, recommendCompositions, reconcileReaderSelection, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveObservationIdentities, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };
|