@moderneinc/react-charts 1.2.0-next.ceab4e → 1.2.0-next.d03b3a

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.
@@ -1,3 +1,10 @@
1
1
  import { FunctionComponent } from 'react';
2
2
  import { ChronoChartProps } from './chrono-chart.types';
3
+ /**
4
+ * ChronoChart: A dual-mode time-series visualization component.
5
+ *
6
+ * Renders either a parliament diagram (point-in-time) or stacked area chart (historical)
7
+ * with smooth animated transitions between modes. Delegates rendering to MorphChart
8
+ * while managing mode logic, data transformation, and user interactions.
9
+ */
3
10
  export declare const ChronoChart: FunctionComponent<ChronoChartProps>;
@@ -1,31 +1,56 @@
1
1
  import { TimelineEvent } from '../timeline-chart/timeline-chart.types';
2
- export type ChronoMode = 'point-in-time' | 'historical';
2
+ /**
3
+ * Represents a data category with visual styling and optional parliament-specific mappings.
4
+ */
3
5
  export type ChronoCategory = {
6
+ /** Unique identifier for the category */
4
7
  id: string;
8
+ /** Display label for the category */
5
9
  label: string;
10
+ /** Color hex code (e.g., '#FF5733') */
6
11
  color: string;
12
+ /** Optional dash pattern for the stroke (e.g., '5 5' for dashed lines) */
13
+ strokeDasharray?: string;
14
+ /** Parliament-specific configuration for special category rendering */
7
15
  parliamentMapping?: {
16
+ /** Whether this category receives special visual treatment in parliament view */
8
17
  isSpecialCategory: boolean;
18
+ /** Hatch pattern identifier for special categories */
9
19
  hatchPattern?: string;
10
20
  };
11
21
  };
22
+ /**
23
+ * Complete dataset for the ChronoChart including time series, categories, and metadata.
24
+ */
12
25
  export type ChronoData = {
26
+ /** Array of time-series data points, each containing a timestamp and category values */
13
27
  timeSeries: Array<{
28
+ /** Unix timestamp or date number */
14
29
  timestamp: number;
30
+ /** Map of category IDs to their numeric values at this timestamp */
15
31
  values: Record<string, number>;
16
32
  }>;
33
+ /** Category definitions with styling and metadata */
17
34
  categories: ChronoCategory[];
35
+ /** Aggregate information about the dataset */
18
36
  metadata: {
19
- totalRepositories: number;
37
+ /** Total count across all categories */
38
+ total: number;
39
+ /** Counts for special categories (optional) */
20
40
  specialCounts?: {
21
41
  notApplicable: number;
22
42
  noLst: number;
23
43
  unavailable: number;
24
44
  };
25
45
  };
46
+ /** Optional timeline events to display alongside the historical view */
26
47
  events?: TimelineEvent[];
27
48
  };
49
+ /**
50
+ * Props for the ChronoChart component.
51
+ */
28
52
  export type ChronoChartProps = {
53
+ /** Complete dataset to visualize */
29
54
  data: ChronoData;
30
55
  /**
31
56
  * Index of the time series data point to display in point-in-time mode.
@@ -37,22 +62,62 @@ export type ChronoChartProps = {
37
62
  * plays when toggling between point-in-time and historical modes.
38
63
  */
39
64
  selectedIndex?: number;
65
+ /** Chart title displayed at the top */
40
66
  title?: string;
67
+ /** Chart subtitle displayed below the title */
41
68
  subtitle?: string;
69
+ /** Whether to show the title/subtitle header section */
42
70
  showHeader?: boolean;
71
+ /** Chart width in pixels (default: 900) */
43
72
  width?: number;
73
+ /** Chart height in pixels (default: 600) */
44
74
  height?: number;
75
+ /** Initial time range for the historical view [startTimestamp, endTimestamp] */
45
76
  timeRange?: [number, number];
77
+ /** Callback when the time range changes (via brush or other interactions) */
46
78
  onTimeRangeChange?: (range: [number, number]) => void;
79
+ /** Minimum allowed timestamp for time range selection (constrains brush selection) */
80
+ minAllowedTime?: number;
81
+ /** Maximum allowed timestamp for time range selection (constrains brush selection) */
82
+ maxAllowedTime?: number;
83
+ /** Enable brush selection for time range in historical mode */
47
84
  enableBrush?: boolean;
85
+ /** Show the legend/category table */
48
86
  showLegend?: boolean;
87
+ /** Enable tooltips on hover */
49
88
  showTooltip?: boolean;
89
+ /** Show background grid lines */
50
90
  showGrid?: boolean;
91
+ /**
92
+ * Color for axis labels (dates on x-axis, values on y-axis).
93
+ * @default undefined (inherits from SVG default, typically black)
94
+ */
95
+ axisLabelColor?: string;
96
+ /** Enable animations when switching between modes */
51
97
  enableAnimation?: boolean;
98
+ /** Duration of animations in milliseconds */
52
99
  animationDuration?: number;
100
+ /**
101
+ * Disable the timeline in historical mode.
102
+ * By default, the timeline is always shown in historical mode, even when there are no events.
103
+ * Set this to true to hide the timeline.
104
+ * @default false
105
+ */
106
+ disableTimeline?: boolean;
107
+ /** Custom function to format timestamps for display */
53
108
  formatDate?: (timestamp: number) => string;
109
+ /** Custom function to format numeric values for display */
54
110
  formatValue?: (value: number) => string;
111
+ /** Callback when animation state changes (starting/stopping) */
55
112
  onAnimationStateChange?: (isAnimating: boolean) => void;
113
+ /** Callback when the GSAP timeline is initialized */
56
114
  onTimelineReady?: (timeline: unknown) => void;
115
+ /** Callback for animation progress updates */
57
116
  onAnimationProgress?: (progress: number, stage: string) => void;
117
+ /**
118
+ * Color for brush selection overlay in historical mode.
119
+ * Used for both the selection area and drag handles.
120
+ * @default '#69b3a2'
121
+ */
122
+ brushColor?: string;
58
123
  };
@@ -1,3 +1,13 @@
1
1
  import { FunctionComponent } from 'react';
2
2
  import { CategoryTableProps } from './category-table.types';
3
+ /**
4
+ * CategoryTable displays a legend/data table for ChronoChart categories.
5
+ *
6
+ * The table adapts its columns based on the display mode:
7
+ * - Point-in-time: Shows current count and percentage for each category
8
+ * - Historical: Shows last value, maximum, and minimum across the time series
9
+ *
10
+ * Special categories (N/A, Data Missing, No LST) use hatch patterns instead of
11
+ * solid colors to distinguish them from regular data categories.
12
+ */
3
13
  export declare const CategoryTable: FunctionComponent<CategoryTableProps>;
@@ -1,17 +1,42 @@
1
+ /**
2
+ * Type definitions for the CategoryTable component.
3
+ *
4
+ * The CategoryTable displays a legend/data table showing all categories with their
5
+ * values, percentages, and colors. It supports both point-in-time and historical modes.
6
+ */
7
+ /**
8
+ * Represents a single category row in the table.
9
+ */
1
10
  export type CategoryTableItem = {
11
+ /** Unique identifier for the category */
2
12
  id: string;
13
+ /** Display label for the category */
3
14
  label: string;
15
+ /** Current value: "#" column in point-in-time mode OR "Last" column in historical mode */
4
16
  value: number;
17
+ /** Percentage of total (displayed in point-in-time mode only) */
5
18
  percentage: number;
19
+ /** Color hex code for the category's visual representation */
6
20
  color: string;
21
+ /** Optional tooltip text providing additional context */
7
22
  tooltip?: string;
23
+ /** Maximum value across time series (historical mode only) */
8
24
  max?: number;
25
+ /** Minimum value across time series (historical mode only) */
9
26
  min?: number;
10
27
  };
28
+ /**
29
+ * Props for the CategoryTable component.
30
+ */
11
31
  export type CategoryTableProps = {
32
+ /** Array of category items to display in the table */
12
33
  categories: CategoryTableItem[];
34
+ /** Currently hovered category ID for highlighting, or null if none */
13
35
  activeCategory: string | null;
36
+ /** Callback when user hovers over or leaves a category row */
14
37
  onCategoryHover: (categoryId: string | null) => void;
38
+ /** Display mode affecting which columns are shown */
15
39
  mode: 'point-in-time' | 'historical';
40
+ /** Whether the table is visible (affects opacity/display) */
16
41
  visible?: boolean;
17
42
  };
@@ -1,9 +1,41 @@
1
1
  import { MorphChartCategory, MorphChartDataPoint } from '../../morph-chart/morph-chart.types';
2
2
  import { ChronoData } from '../chrono-chart.types';
3
3
  import { CategoryTableItem } from '../components/category-table.types';
4
+ /**
5
+ * Extracts the latest values from ChronoData and formats them for display in the category table.
6
+ *
7
+ * In point-in-time mode: Returns the latest value for each category
8
+ * In historical mode: Also includes min/max values across the time series
9
+ *
10
+ * @param data - The complete ChronoData dataset
11
+ * @param mode - Display mode affecting which values are included
12
+ * @returns Array of formatted category items with values, percentages, and metadata
13
+ */
4
14
  export declare const extractLatestValues: (data: ChronoData, mode?: "point-in-time" | "historical") => CategoryTableItem[];
15
+ /**
16
+ * Transforms ChronoData format to MorphChart format for visualization.
17
+ *
18
+ * This conversion is necessary because ChronoChart uses its own data structure
19
+ * but delegates rendering to the MorphChart component.
20
+ *
21
+ * @param data - The ChronoData to transform
22
+ * @returns Object containing MorphChart-compatible data points and categories
23
+ * @throws Error if no data points are available
24
+ */
5
25
  export declare const transformToMorphChart: (data: ChronoData) => {
6
26
  data: MorphChartDataPoint[];
7
27
  categories: MorphChartCategory[];
8
28
  };
29
+ /**
30
+ * Validates the structure and integrity of ChronoData.
31
+ *
32
+ * Checks for:
33
+ * - Non-empty time series and categories
34
+ * - Required metadata fields
35
+ * - Proper timestamp ordering (ascending)
36
+ * - Category presence in data points
37
+ *
38
+ * @param data - The ChronoData to validate
39
+ * @throws Error with descriptive message if validation fails
40
+ */
9
41
  export declare const validateChronoData: (data: ChronoData) => void;
@@ -68,9 +68,16 @@ export type D3StackedAreaChartProps = {
68
68
  timestamp: number;
69
69
  label?: string;
70
70
  color?: string;
71
+ strokeDasharray?: string;
71
72
  }>;
72
73
  /** Marker visibility mode: 'hover' shows only nearest marker on hover, 'always' shows all markers */
73
74
  markerVisibilityMode?: 'always' | 'hover';
75
+ /**
76
+ * Color for brush selection overlay.
77
+ * Used for both the selection area and drag handles.
78
+ * @default '#69b3a2'
79
+ */
80
+ brushColor?: string;
74
81
  /** Mode for morphing animation */
75
82
  morphMode?: 'area' | 'parliament' | 'morphing';
76
83
  /** Parliament layout data (for morphing) */
@@ -25,8 +25,11 @@ type UseD3StackedAreaProps = {
25
25
  timestamp: number;
26
26
  label?: string;
27
27
  color?: string;
28
+ strokeDasharray?: string;
28
29
  }>;
29
30
  markerVisibilityMode?: 'always' | 'hover';
31
+ onMarkerHoverChange?: (isHovering: boolean) => void;
32
+ brushColor?: string;
30
33
  };
31
- export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, markers, markerVisibilityMode }: UseD3StackedAreaProps) => void;
34
+ export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, markers, markerVisibilityMode, onMarkerHoverChange, brushColor }: UseD3StackedAreaProps) => void;
32
35
  export {};
@@ -3,11 +3,12 @@ import { StageDurations } from './types';
3
3
  * Calculate stage durations from total animation duration
4
4
  *
5
5
  * Splits the total duration into proportional stages for smooth timing:
6
- * - 27% Seats to bar transformation
7
- * - 3% Pause to appreciate seat-to-bar transition
8
- * - 25% Bar slide to timeline + axes appear
9
- * - 25% Other bars grow from baseline
10
- * - 20% Bars morph to curved areas
6
+ * - 20% Seats transform to zig-zag lines (accordion shape)
7
+ * - 7% Lines collapse into vertical bar
8
+ * - 0.3% Pause to appreciate seat-to-bar transition
9
+ * - 22% Bar slide to timeline + axes appear
10
+ * - 22% Other bars grow from baseline
11
+ * - 28.7% Bars morph to curved areas
11
12
  *
12
13
  * @param totalDuration - Total animation duration in milliseconds
13
14
  * @returns Object with duration for each stage in milliseconds
@@ -16,11 +17,12 @@ import { StageDurations } from './types';
16
17
  * ```ts
17
18
  * const durations = calculateStageDurations(2000);
18
19
  * // {
19
- * // seatsToBar: 540, // 27%
20
- * // crossFadePause: 60, // 3%
21
- * // barSlideToTimeline: 500, // 25%
22
- * // axesAndBarsGrow: 500, // 25%
23
- * // barsToArea: 400 // 20%
20
+ * // seatsToLines: 400, // 20%
21
+ * // seatsToBar: 140, // 7%
22
+ * // crossFadePause: 6, // 0.3%
23
+ * // barSlideToTimeline: 440, // 22%
24
+ * // axesAndBarsGrow: 440, // 22%
25
+ * // barsToArea: 574 // 28.7%
24
26
  * // }
25
27
  * ```
26
28
  */
@@ -5,18 +5,20 @@
5
5
  * timing and duration calculations.
6
6
  */
7
7
  /**
8
- * Animation stage durations for parliament → area morph (4 stages)
8
+ * Animation stage durations for parliament → area morph (5 stages)
9
9
  * Calculated as fractions of total duration for smooth timing
10
10
  */
11
11
  export type StageDurations = {
12
- /** Frame 1→2: Seats directly transform to vertical bar (27% of total) */
12
+ /** Frame 0→1: Seats transform to zig-zag lines forming accordion (20% of total) */
13
+ seatsToLines: number;
14
+ /** Frame 1→2: Lines collapse into vertical bar (15% of total) */
13
15
  seatsToBar: number;
14
16
  /** Pause after cross-fade to appreciate seat-to-bar transition (3% of total) */
15
17
  crossFadePause: number;
16
- /** Frame 2→3: Bar slides to timeline + axes/grid appear (25% of total) */
18
+ /** Frame 2→3: Bar slides to timeline + axes/grid appear (22% of total) */
17
19
  barSlideToTimeline: number;
18
- /** Frame 3→4: Other bars grow from baseline (25% of total) */
20
+ /** Frame 3→4: Other bars grow from baseline (22% of total) */
19
21
  axesAndBarsGrow: number;
20
- /** Frame 4→5: Bars morph to curved area (20% of total) */
22
+ /** Frame 4→5: Bars morph to curved area (18% of total) */
21
23
  barsToArea: number;
22
24
  };
@@ -16,6 +16,7 @@ type UseMorphChartProps = {
16
16
  timeRange?: [number, number];
17
17
  showGrid?: boolean;
18
18
  showAxes?: boolean;
19
+ axisLabelColor?: string;
19
20
  formatDate?: (timestamp: number) => string;
20
21
  formatValue?: (value: number) => string;
21
22
  markers?: Array<{
@@ -37,13 +38,52 @@ type UseMorphChartProps = {
37
38
  parliamentTimestamp?: number;
38
39
  enableBrush?: boolean;
39
40
  onTimeRangeChange?: (range: [number, number]) => void;
41
+ minAllowedTime?: number;
42
+ maxAllowedTime?: number;
40
43
  showScaleIndicator?: boolean;
41
44
  reposPerSeat?: number;
45
+ timelineEvents?: Array<{
46
+ timestamp: number;
47
+ eventName: string;
48
+ color?: string;
49
+ }>;
50
+ showTimeline?: boolean;
51
+ timelineHeight?: number;
52
+ timelineOffset?: number;
53
+ brushColor?: string;
42
54
  };
43
- export declare const useMorphChart: ({ containerRef, data, categories, mode, width, height, margin, timeRange, showGrid, showAxes, formatDate, formatValue, markers: _markers, arcAngle, parliamentRadius, seatSize, animationDuration, onMorphComplete, onAnimationStateChange, onTimelineReady, onAnimationProgress, onHoveredDataChange, hoveredCategory: externalHoveredCategory, maxSeats, parliamentTimestamp, enableBrush, onTimeRangeChange, showScaleIndicator, reposPerSeat }: UseMorphChartProps) => {
55
+ export declare const useMorphChart: ({ containerRef, data, categories, mode, width, height, margin, timeRange, showGrid, showAxes, axisLabelColor, formatDate, formatValue, markers, arcAngle, parliamentRadius, seatSize, animationDuration, onMorphComplete, onAnimationStateChange, onTimelineReady, onAnimationProgress, onHoveredDataChange, hoveredCategory: externalHoveredCategory, maxSeats, parliamentTimestamp, enableBrush, onTimeRangeChange, minAllowedTime: minAllowedTimeConstraint, maxAllowedTime: maxAllowedTimeConstraint, showScaleIndicator, reposPerSeat, timelineEvents, showTimeline, timelineHeight, timelineOffset, brushColor }: UseMorphChartProps) => {
44
56
  isMorphing: boolean;
45
57
  currentMode: MorphMode;
46
58
  hoveredCategory: string | null;
47
59
  scaleIndicatorOpacity: number;
60
+ visibleMarkers: {
61
+ timestamp: number;
62
+ label?: string;
63
+ color?: string;
64
+ x: number;
65
+ }[];
66
+ hoveredMarker: {
67
+ timestamp: number;
68
+ label?: string;
69
+ color?: string;
70
+ x: number;
71
+ } | null;
72
+ setHoveredMarker: import('react').Dispatch<import('react').SetStateAction<{
73
+ timestamp: number;
74
+ label?: string;
75
+ color?: string;
76
+ x: number;
77
+ } | null>>;
78
+ hoveredTimelineEvent: {
79
+ timestamp: number;
80
+ eventName: string;
81
+ x: number;
82
+ } | null;
83
+ setHoveredTimelineEvent: import('react').Dispatch<import('react').SetStateAction<{
84
+ timestamp: number;
85
+ eventName: string;
86
+ x: number;
87
+ } | null>>;
48
88
  };
49
89
  export {};
@@ -43,10 +43,19 @@ export type MorphChartProps = {
43
43
  showGrid?: boolean;
44
44
  /** Show axes */
45
45
  showAxes?: boolean;
46
+ /**
47
+ * Color for axis labels (dates on x-axis, values on y-axis).
48
+ * @default undefined (inherits from SVG default, typically black)
49
+ */
50
+ axisLabelColor?: string;
46
51
  /** Enable brush selection */
47
52
  enableBrush?: boolean;
48
53
  /** Callback when time range changes */
49
54
  onTimeRangeChange?: (range: [number, number]) => void;
55
+ /** Minimum allowed timestamp for time range selection (constrains brush selection) */
56
+ minAllowedTime?: number;
57
+ /** Maximum allowed timestamp for time range selection (constrains brush selection) */
58
+ maxAllowedTime?: number;
50
59
  /** Format date for axis */
51
60
  formatDate?: (timestamp: number) => string;
52
61
  /** Format value for axis */
@@ -94,6 +103,24 @@ export type MorphChartProps = {
94
103
  * If not provided, defaults to the rightmost (most recent) timestamp.
95
104
  */
96
105
  parliamentTimestamp?: number;
106
+ /** Timeline events to display below the x-axis (area mode only) */
107
+ timelineEvents?: Array<{
108
+ timestamp: number;
109
+ eventName: string;
110
+ color?: string;
111
+ }>;
112
+ /** Show timeline track (default: false) */
113
+ showTimeline?: boolean;
114
+ /** Timeline track height in pixels (default: 40) */
115
+ timelineHeight?: number;
116
+ /** Space between x-axis and timeline in pixels (default: 35) */
117
+ timelineOffset?: number;
118
+ /**
119
+ * Color for brush selection overlay.
120
+ * Used for both the selection area and drag handles.
121
+ * @default '#69b3a2'
122
+ */
123
+ brushColor?: string;
97
124
  };
98
125
  /**
99
126
  * Seat position in parliament layout
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Utility functions for generating accordion-style zig-zag lines
3
+ * Used in the seats-to-lines animation stage
4
+ */
5
+ export interface AccordionLinePoint {
6
+ x: number;
7
+ y: number;
8
+ category: string;
9
+ categoryIndex: number;
10
+ }
11
+ export interface AccordionLineConfig {
12
+ centerX: number;
13
+ centerY: number;
14
+ radius: number;
15
+ startAngle: number;
16
+ endAngle: number;
17
+ amplitude: number;
18
+ segments: number;
19
+ }
20
+ /**
21
+ * Generate zig-zag line points for a category's accordion section
22
+ *
23
+ * @param config - Configuration for the accordion line
24
+ * @returns Array of points forming the zig-zag pattern
25
+ */
26
+ export declare function generateAccordionLine(config: AccordionLineConfig): AccordionLinePoint[];
27
+ /**
28
+ * Generate accordion lines for all categories
29
+ *
30
+ * @param categories - Array of categories with their seat counts
31
+ * @param parliamentCenter - Center point of the parliament
32
+ * @param radius - Base radius of the parliament arc
33
+ * @param arcAngle - Total angle of the parliament arc (in radians)
34
+ * @returns Map of category to accordion line points
35
+ */
36
+ export declare function generateCategoryAccordionLines(categories: Array<{
37
+ name: string;
38
+ seatCount: number;
39
+ color: string;
40
+ }>, parliamentCenter: {
41
+ x: number;
42
+ y: number;
43
+ }, radius: number, arcAngle?: number): Map<string, AccordionLinePoint[]>;
44
+ /**
45
+ * Generate a single continuous accordion line for all categories
46
+ * Creates one connected slinky that spans the entire parliament arc
47
+ *
48
+ * @param categories - Array of categories with their seat counts
49
+ * @param parliamentCenter - Center point of the parliament
50
+ * @param radius - Base radius of the parliament arc
51
+ * @param arcAngle - Total angle of the parliament arc (in radians)
52
+ * @returns Single array of accordion line points with category info
53
+ */
54
+ export declare function generateContinuousAccordionLine(categories: Array<{
55
+ name: string;
56
+ seatCount: number;
57
+ color: string;
58
+ }>, parliamentCenter: {
59
+ x: number;
60
+ y: number;
61
+ }, radius: number, arcAngle?: number): AccordionLinePoint[];
62
+ /**
63
+ * Create SVG path string from accordion line points
64
+ *
65
+ * @param points - Array of accordion line points
66
+ * @param curved - Whether to use curved lines (true) or sharp zig-zags (false)
67
+ * @returns SVG path string
68
+ */
69
+ export declare function createAccordionPath(points: AccordionLinePoint[], curved?: boolean): string;
70
+ /**
71
+ * Calculate intermediate positions for accordion collapse animation with slinky physics
72
+ *
73
+ * @param linePoints - Original accordion line points
74
+ * @param targetX - Target X position (vertical bar location)
75
+ * @param targetY - Target Y position (vertical bar location)
76
+ * @param progress - Animation progress (0-1)
77
+ * @returns Interpolated points for current progress with wave motion
78
+ */
79
+ export declare function interpolateAccordionCollapse(linePoints: AccordionLinePoint[], targetX: number, targetY: number, progress: number): AccordionLinePoint[];
80
+ /**
81
+ * Generate multiple depth layers for slinky 3D effect
82
+ *
83
+ * @param config - Base configuration for accordion line
84
+ * @param numLayers - Number of layers to create (default 3)
85
+ * @returns Array of accordion line configurations with depth properties
86
+ */
87
+ export declare function generateLayeredAccordionLines(config: AccordionLineConfig, numLayers?: number): Array<{
88
+ points: AccordionLinePoint[];
89
+ depth: number;
90
+ opacity: number;
91
+ strokeWidth: number;
92
+ blur: number;
93
+ }>;
94
+ /**
95
+ * Generate a single vertical line path for collapsed state
96
+ *
97
+ * @param x - X position of the vertical line
98
+ * @param topY - Top Y position
99
+ * @param bottomY - Bottom Y position
100
+ * @returns SVG path string for vertical line
101
+ */
102
+ export declare function createVerticalLinePath(x: number, topY: number, bottomY: number): string;
@@ -1,11 +1,13 @@
1
1
  import { Selection } from 'd3-selection';
2
2
  import { MorphChartCategory } from '../morph-chart.types';
3
3
  interface AnimationDurations {
4
- seatsToBar: number;
4
+ seatsToRings: number;
5
+ ringsToBar: number;
5
6
  axesReveal: number;
6
7
  barSlide: number;
7
8
  barsGrow: number;
8
9
  barsToArea: number;
10
+ ringsHold?: number;
9
11
  }
10
12
  interface AnimationCallbacks {
11
13
  onStageComplete?: (stage: string) => void;
@@ -34,39 +36,76 @@ export declare class GSAPOrchestrator {
34
36
  private durations;
35
37
  constructor(durations: AnimationDurations, callbacks?: AnimationCallbacks);
36
38
  /**
37
- * Stage 1: Animate parliament seats collapsing into bar segments
39
+ * Stage 1a: Animate parliament seats transforming into slinky rings
38
40
  *
39
- * Transforms the circular parliament layout into a stacked vertical bar.
40
- * Each seat morphs from its position in the parliament arc into a rectangular
41
- * segment of a bar, maintaining visual continuity through smooth transitions.
41
+ * Transforms the circular parliament layout into a slinky (spring coil) formation.
42
+ * This creates a whimsical intermediate state between the circular parliament
43
+ * and the stacked bar, making the transition more visually engaging.
42
44
  *
43
- * @param seats - D3 selection of parliament seat rectangles to animate
44
- * @param targetPositions - Array of target positions for each seat, where each position defines the final rectangle geometry (x, y, width, height)
45
+ * @param seats - D3 selection of parliament seat elements to animate
46
+ * @param baselineY - Y-coordinate of the chart baseline (reference for positioning)
45
47
  * @returns this - Returns the orchestrator instance for method chaining
46
48
  *
47
49
  * @remarks
48
50
  * **Visual transformation:**
49
- * - Parliament seats (circular arc) → Vertical bar segments (stacked rectangles)
50
- * - All seats animate simultaneously (no stagger)
51
- * - Uses power2.inOut easing for smooth acceleration/deceleration
51
+ * - Parliament seats (circular arc) → Slinky rings (elliptical coils)
52
+ * - Seats morph and fade into overlapping rings
53
+ * - Rings positioned along the parliament arc initially
54
+ * - Uses perspective effects for 3D slinky appearance
52
55
  *
53
56
  * **Data preservation:**
54
57
  * - Original seat positions stored in data-orig-* attributes for potential reversal
55
- * - Target positions must match seat count (indexed by array position)
58
+ * - Current dimensions preserved before transformation
56
59
  *
57
60
  * **Timeline integration:**
58
- * - Added at 'seatsToBar' label
59
- * - Duration: 30% of total animation (STAGE_DURATION_RATIOS.SEATS_TO_BAR)
61
+ * - Added at 'seatsToRings' label (first stage)
62
+ * - Duration: Set by durations.seatsToRings
60
63
  * - Triggers onStageComplete callback when starting
61
64
  *
62
65
  * @example
63
66
  * ```ts
64
67
  * const seats = svg.selectAll('.parliament-seat');
65
- * const targets = calculateBarPositions(seats);
66
- * orchestrator.animateSeatsToBar(seats, targets);
68
+ * const baselineY = height - margin.bottom;
69
+ * orchestrator.animateSeatsToRings(seats, baselineY);
70
+ * ```
71
+ */
72
+ animateSeatsToRings(seats: Selection<SVGRectElement, unknown, null, undefined>, baselineY: number): GSAPOrchestrator;
73
+ /**
74
+ * Stage 1b: Animate slinky rings collapsing into stacked bar
75
+ *
76
+ * Transforms the slinky rings created in Stage 1a into a stacked
77
+ * vertical bar. Rings compress and stack vertically to form rectangular
78
+ * segments of the final bar, maintaining visual continuity.
79
+ *
80
+ * @param seats - D3 selection of ring elements (formerly seats) to animate
81
+ * @param targetPositions - Array of target positions for each segment, where each position defines the final rectangle geometry (x, y, width, height)
82
+ * @returns this - Returns the orchestrator instance for method chaining
83
+ *
84
+ * @remarks
85
+ * **Visual transformation:**
86
+ * - Slinky rings → Stacked bar segments (rectangles)
87
+ * - Rings compress and flatten into bar segments
88
+ * - Reposition to stack vertically in correct order
89
+ * - All segments animate simultaneously (no stagger)
90
+ * - Uses power2.inOut easing for smooth acceleration/deceleration
91
+ *
92
+ * **Data requirements:**
93
+ * - Target positions must match ring count (indexed by array position)
94
+ * - Each position defines final x, y, width, height for the bar segment
95
+ *
96
+ * **Timeline integration:**
97
+ * - Added at 'ringsToBar' label (after seatsToRings)
98
+ * - Duration: Set by durations.ringsToBar
99
+ * - Triggers onStageComplete callback when starting
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * const rings = svg.selectAll('.slinky-ring');
104
+ * const targets = calculateBarPositions(rings);
105
+ * orchestrator.animateRingsToBar(rings, targets);
67
106
  * ```
68
107
  */
69
- animateSeatsToBar(seats: Selection<SVGRectElement, unknown, null, undefined>, targetPositions: Array<{
108
+ animateRingsToBar(seats: Selection<SVGRectElement, unknown, null, undefined>, targetPositions: Array<{
70
109
  x: number;
71
110
  y: number;
72
111
  width: number;