@opendata-ai/openchart-core 6.4.1 → 6.5.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/src/types/spec.ts CHANGED
@@ -595,6 +595,62 @@ export interface SeriesStyle {
595
595
  opacity?: number;
596
596
  }
597
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: 80 */
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
+
598
654
  /**
599
655
  * Breakpoint-conditional overrides for chart specs.
600
656
  *
@@ -611,6 +667,8 @@ export interface ChartSpecOverride {
611
667
  legend?: LegendConfig;
612
668
  /** Override annotations at this breakpoint. */
613
669
  annotations?: Annotation[];
670
+ /** Override animation at this breakpoint. */
671
+ animation?: AnimationSpec;
614
672
  }
615
673
 
616
674
  /**
@@ -657,6 +715,13 @@ export interface ChartSpec {
657
715
  * are shallow-merged into the spec before layout computation.
658
716
  */
659
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;
660
725
  }
661
726
 
662
727
  /**
@@ -690,6 +755,8 @@ export interface TableSpec {
690
755
  compact?: boolean;
691
756
  /** Whether the table adapts to container width. Defaults to true. */
692
757
  responsive?: boolean;
758
+ /** Animation configuration for entrance animations. */
759
+ animation?: AnimationSpec;
693
760
  }
694
761
 
695
762
  /** Graph node: must have an id, plus arbitrary data fields. */
@@ -802,6 +869,8 @@ export interface LayerSpec {
802
869
  resolve?: ResolveConfig;
803
870
  /** Hidden series names. */
804
871
  hiddenSeries?: string[];
872
+ /** Animation configuration. */
873
+ animation?: AnimationSpec;
805
874
  }
806
875
 
807
876
  /**