@opendata-ai/openchart-core 6.3.0 → 6.5.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.
@@ -217,6 +217,8 @@ export interface LineMark {
217
217
  label?: ResolvedLabel;
218
218
  /** Accessibility attributes. */
219
219
  aria: MarkAria;
220
+ /** Index for stagger animation ordering. */
221
+ animationIndex?: number;
220
222
  }
221
223
 
222
224
  /**
@@ -257,6 +259,8 @@ export interface AreaMark {
257
259
  }>;
258
260
  /** Accessibility attributes. */
259
261
  aria: MarkAria;
262
+ /** Index for stagger animation ordering. */
263
+ animationIndex?: number;
260
264
  }
261
265
 
262
266
  /**
@@ -287,6 +291,14 @@ export interface RectMark {
287
291
  label?: ResolvedLabel;
288
292
  /** Accessibility attributes. */
289
293
  aria: MarkAria;
294
+ /** Index for stagger animation ordering. */
295
+ animationIndex?: number;
296
+ /** Bar orientation for animation direction. Set by the engine based on encoding. */
297
+ orient?: 'horizontal' | 'vertical';
298
+ /** Stacking group key (e.g. category name). Segments sharing this key animate together. */
299
+ stackGroup?: string;
300
+ /** Position of this segment within its stack group (0, 1, 2...). Set by engine for stacked bars. */
301
+ stackPos?: number;
290
302
  }
291
303
 
292
304
  /**
@@ -321,6 +333,8 @@ export interface ArcMark {
321
333
  label?: ResolvedLabel;
322
334
  /** Accessibility attributes. */
323
335
  aria: MarkAria;
336
+ /** Index for stagger animation ordering. */
337
+ animationIndex?: number;
324
338
  }
325
339
 
326
340
  /**
@@ -349,6 +363,8 @@ export interface PointMark {
349
363
  label?: ResolvedLabel;
350
364
  /** Accessibility attributes. */
351
365
  aria: MarkAria;
366
+ /** Index for stagger animation ordering. */
367
+ animationIndex?: number;
352
368
  }
353
369
 
354
370
  /**
@@ -381,6 +397,8 @@ export interface TextMarkLayout {
381
397
  label?: ResolvedLabel;
382
398
  /** Accessibility attributes. */
383
399
  aria: MarkAria;
400
+ /** Index for stagger animation ordering. */
401
+ animationIndex?: number;
384
402
  }
385
403
 
386
404
  /**
@@ -409,6 +427,8 @@ export interface RuleMarkLayout {
409
427
  data: Record<string, unknown>;
410
428
  /** Accessibility attributes. */
411
429
  aria: MarkAria;
430
+ /** Index for stagger animation ordering. */
431
+ animationIndex?: number;
412
432
  }
413
433
 
414
434
  /**
@@ -435,6 +455,8 @@ export interface TickMarkLayout {
435
455
  data: Record<string, unknown>;
436
456
  /** Accessibility attributes. */
437
457
  aria: MarkAria;
458
+ /** Index for stagger animation ordering. */
459
+ animationIndex?: number;
438
460
  }
439
461
 
440
462
  /** Discriminated union of all mark types. */
@@ -490,6 +512,8 @@ export interface ResolvedLabel {
490
512
  export interface ResolvedAnnotation {
491
513
  /** Original annotation type. */
492
514
  type: 'text' | 'range' | 'refline';
515
+ /** Stable identifier from the spec annotation, for selection/edit callbacks. */
516
+ id?: string;
493
517
  /** Label text (if any). */
494
518
  label?: ResolvedLabel;
495
519
  /** For range: the highlighted rectangle in pixel coordinates. */
@@ -584,6 +608,26 @@ export interface A11yMetadata {
584
608
  keyboardNavigable: boolean;
585
609
  }
586
610
 
611
+ // ---------------------------------------------------------------------------
612
+ // Animation (resolved)
613
+ // ---------------------------------------------------------------------------
614
+
615
+ /** Resolved entrance animation config with all defaults applied. */
616
+ export interface ResolvedAnimation {
617
+ /** Whether entrance animation is enabled. */
618
+ enabled: boolean;
619
+ /** Duration in ms. */
620
+ duration: number;
621
+ /** Easing preset name. */
622
+ ease: import('./spec').AnimationEase;
623
+ /** Stagger delay between elements in ms. */
624
+ staggerDelay: number;
625
+ /** Stagger ordering. */
626
+ staggerOrder: 'index' | 'value' | 'reverse';
627
+ /** Delay before annotations animate in (ms after marks). */
628
+ annotationDelay: number;
629
+ }
630
+
587
631
  // ---------------------------------------------------------------------------
588
632
  // ChartLayout (the main engine output for charts)
589
633
  // ---------------------------------------------------------------------------
@@ -620,6 +664,8 @@ export interface ChartLayout {
620
664
  theme: ResolvedTheme;
621
665
  /** Total SVG dimensions. */
622
666
  dimensions: { width: number; height: number };
667
+ /** Resolved animation config. Present only when animation is enabled. */
668
+ animation?: ResolvedAnimation;
623
669
  }
624
670
 
625
671
  // ---------------------------------------------------------------------------
@@ -794,6 +840,8 @@ export interface TableLayout {
794
840
  a11y: { caption: string; summary: string };
795
841
  /** The resolved theme. */
796
842
  theme: ResolvedTheme;
843
+ /** Resolved animation config. Present only when animation is enabled. */
844
+ animation?: ResolvedAnimation;
797
845
  }
798
846
 
799
847
  // ---------------------------------------------------------------------------
package/src/types/spec.ts CHANGED
@@ -382,6 +382,8 @@ export type AnnotationAnchor = 'top' | 'bottom' | 'left' | 'right' | 'auto';
382
382
 
383
383
  /** Base properties shared by all annotation types. */
384
384
  interface AnnotationBase {
385
+ /** Stable identifier for selection and edit callbacks. When provided, edit events include this ID for reliable element matching. */
386
+ id?: string;
385
387
  /** Human-readable label for the annotation. */
386
388
  label?: string;
387
389
  /** Fill color for the annotation element. */
@@ -593,6 +595,62 @@ export interface SeriesStyle {
593
595
  opacity?: number;
594
596
  }
595
597
 
598
+ // ---------------------------------------------------------------------------
599
+ // Animation
600
+ // ---------------------------------------------------------------------------
601
+
602
+ /**
603
+ * Named easing presets for entrance animations.
604
+ * Uses CSS linear() curves. Named 'ease' (not 'easing') to match Vega convention.
605
+ */
606
+ export type AnimationEase = 'smooth' | 'snappy';
607
+
608
+ /** Stagger configuration for sequential element reveal. */
609
+ export interface AnimationStagger {
610
+ /** Delay between each element in ms. Default: 30 */
611
+ delay?: number;
612
+ /** Ordering strategy. Default: 'index' (DOM order) */
613
+ order?: 'index' | 'value' | 'reverse';
614
+ }
615
+
616
+ /**
617
+ * Animation phase config. Follows Vega's enter/update/exit model.
618
+ * Each phase can be true (use defaults) or a config object.
619
+ */
620
+ export interface AnimationPhaseConfig {
621
+ /** Duration in ms. Default: 500 for enter. */
622
+ duration?: number;
623
+ /** Easing preset. Default: 'smooth'. */
624
+ ease?: AnimationEase;
625
+ /** Stagger config. true = defaults, false = no stagger. Default: true for enter. */
626
+ stagger?: AnimationStagger | boolean;
627
+ }
628
+
629
+ /**
630
+ * Full animation config object. Structured as enter/update/exit phases
631
+ * following Vega's encoding set model.
632
+ *
633
+ * v1 implements enter only. update and exit reserved for v2.
634
+ */
635
+ export interface AnimationConfig {
636
+ /** Entrance animation when chart first renders. */
637
+ enter?: AnimationPhaseConfig | boolean;
638
+ /** Transition animation when data updates. Reserved for v2. */
639
+ update?: AnimationPhaseConfig | boolean;
640
+ /** Exit animation when marks are removed. Reserved for v2. */
641
+ exit?: AnimationPhaseConfig | boolean;
642
+ /** Delay before annotations animate in (ms after marks). Default: 200. */
643
+ annotationDelay?: number;
644
+ }
645
+
646
+ /**
647
+ * Animation spec property.
648
+ * - true: enable entrance animation with sensible defaults
649
+ * - false/omitted: no animation (current behavior)
650
+ * - AnimationConfig: full control via enter/update/exit phases
651
+ */
652
+ export type AnimationSpec = boolean | AnimationConfig;
653
+
596
654
  /**
597
655
  * Breakpoint-conditional overrides for chart specs.
598
656
  *
@@ -609,6 +667,8 @@ export interface ChartSpecOverride {
609
667
  legend?: LegendConfig;
610
668
  /** Override annotations at this breakpoint. */
611
669
  annotations?: Annotation[];
670
+ /** Override animation at this breakpoint. */
671
+ animation?: AnimationSpec;
612
672
  }
613
673
 
614
674
  /**
@@ -655,6 +715,13 @@ export interface ChartSpec {
655
715
  * are shallow-merged into the spec before layout computation.
656
716
  */
657
717
  overrides?: Partial<Record<Breakpoint, ChartSpecOverride>>;
718
+ /**
719
+ * Animation configuration.
720
+ * - true: enable entrance animation with sensible defaults
721
+ * - false/omitted: no animation (current behavior)
722
+ * - AnimationConfig: full control via enter/update/exit phases
723
+ */
724
+ animation?: AnimationSpec;
658
725
  }
659
726
 
660
727
  /**
@@ -688,6 +755,8 @@ export interface TableSpec {
688
755
  compact?: boolean;
689
756
  /** Whether the table adapts to container width. Defaults to true. */
690
757
  responsive?: boolean;
758
+ /** Animation configuration for entrance animations. */
759
+ animation?: AnimationSpec;
691
760
  }
692
761
 
693
762
  /** Graph node: must have an id, plus arbitrary data fields. */
@@ -800,6 +869,8 @@ export interface LayerSpec {
800
869
  resolve?: ResolveConfig;
801
870
  /** Hidden series names. */
802
871
  hiddenSeries?: string[];
872
+ /** Animation configuration. */
873
+ animation?: AnimationSpec;
803
874
  }
804
875
 
805
876
  /**