@moderneinc/react-charts 1.2.0-next.c015c0 → 1.2.0-next.c03472

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.
Files changed (46) hide show
  1. package/dist/components/chrono-chart/chrono-chart.component.d.ts +10 -0
  2. package/dist/components/chrono-chart/chrono-chart.types.d.ts +129 -0
  3. package/dist/components/chrono-chart/components/category-table.component.d.ts +13 -0
  4. package/dist/components/chrono-chart/components/category-table.types.d.ts +42 -0
  5. package/dist/components/chrono-chart/utils/data-transformer.d.ts +41 -0
  6. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.component.d.ts +7 -0
  7. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +95 -0
  8. package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +35 -0
  9. package/dist/components/morph-chart/hooks/shared/computations.d.ts +29 -0
  10. package/dist/components/morph-chart/hooks/shared/types.d.ts +24 -0
  11. package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +90 -0
  12. package/dist/components/morph-chart/index.d.ts +2 -0
  13. package/dist/components/morph-chart/morph-chart.component.d.ts +14 -0
  14. package/dist/components/morph-chart/morph-chart.types.d.ts +175 -0
  15. package/dist/components/morph-chart/utils/accordion-generator.d.ts +102 -0
  16. package/dist/components/morph-chart/utils/animation-constants.d.ts +23 -0
  17. package/dist/components/morph-chart/utils/animation-utils.d.ts +44 -0
  18. package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +53 -0
  19. package/dist/components/morph-chart/utils/area-renderer.d.ts +24 -0
  20. package/dist/components/morph-chart/utils/bar-renderer.d.ts +19 -0
  21. package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +291 -0
  22. package/dist/components/morph-chart/utils/morph-interpolator.d.ts +96 -0
  23. package/dist/components/morph-chart/utils/parliament-renderer.d.ts +23 -0
  24. package/dist/components/morph-chart/utils/parliament-seat-extractor.d.ts +33 -0
  25. package/dist/components/morph-chart/utils/position-mapper.d.ts +48 -0
  26. package/dist/components/morph-chart/utils/segment-transformer.d.ts +70 -0
  27. package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +35 -0
  28. package/dist/components/morph-chart/utils/svg-patterns.d.ts +19 -0
  29. package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +25 -0
  30. package/dist/components/parliament-chart/hooks/use-parliament-chart.hook.d.ts +5 -1
  31. package/dist/components/parliament-chart/parliament-chart.types.d.ts +5 -0
  32. package/dist/components/parliament-chart/utils/parliament-animation.d.ts +13 -0
  33. package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +23 -0
  34. package/dist/components/stacked-area-chart/utils/color.utils.d.ts +0 -5
  35. package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +52 -0
  36. package/dist/components/stacked-area-with-timeline/index.d.ts +4 -0
  37. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.component.d.ts +3 -0
  38. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.types.d.ts +97 -0
  39. package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +54 -0
  40. package/dist/components/timeline-chart/timeline-chart.types.d.ts +44 -0
  41. package/dist/index.cjs +109 -71
  42. package/dist/index.d.ts +9 -0
  43. package/dist/index.js +24923 -16477
  44. package/dist/theme/default-colors.d.ts +0 -4
  45. package/dist/theme/timeline-defaults.d.ts +33 -1
  46. package/package.json +30 -10
@@ -0,0 +1,291 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { MorphChartCategory } from '../morph-chart.types';
3
+ interface AnimationDurations {
4
+ seatsToRings: number;
5
+ ringsToBar: number;
6
+ axesReveal: number;
7
+ barSlide: number;
8
+ barsGrow: number;
9
+ barsToArea: number;
10
+ ringsHold?: number;
11
+ }
12
+ interface AnimationCallbacks {
13
+ onStageComplete?: (stage: string) => void;
14
+ onProgress?: (progress: number) => void;
15
+ onComplete?: () => void;
16
+ }
17
+ interface AnimationControls {
18
+ play: () => void;
19
+ pause: () => void;
20
+ reverse: () => void;
21
+ restart: () => void;
22
+ seek: (progress: number) => void;
23
+ seekToStage: (stageName: string) => void;
24
+ kill: () => void;
25
+ getProgress: () => number;
26
+ getCurrentStage: () => string;
27
+ getTimeline: () => gsap.core.Timeline;
28
+ }
29
+ /**
30
+ * GSAP Orchestrator class that manages the entire animation sequence
31
+ */
32
+ export declare class GSAPOrchestrator {
33
+ private timeline;
34
+ private currentStage;
35
+ private callbacks;
36
+ private durations;
37
+ constructor(durations: AnimationDurations, callbacks?: AnimationCallbacks);
38
+ /**
39
+ * Stage 1a: Animate parliament seats transforming into slinky rings
40
+ *
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.
44
+ *
45
+ * @param seats - D3 selection of parliament seat elements to animate
46
+ * @param baselineY - Y-coordinate of the chart baseline (reference for positioning)
47
+ * @returns this - Returns the orchestrator instance for method chaining
48
+ *
49
+ * @remarks
50
+ * **Visual transformation:**
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
55
+ *
56
+ * **Data preservation:**
57
+ * - Original seat positions stored in data-orig-* attributes for potential reversal
58
+ * - Current dimensions preserved before transformation
59
+ *
60
+ * **Timeline integration:**
61
+ * - Added at 'seatsToRings' label (first stage)
62
+ * - Duration: Set by durations.seatsToRings
63
+ * - Triggers onStageComplete callback when starting
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const seats = svg.selectAll('.parliament-seat');
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);
106
+ * ```
107
+ */
108
+ animateRingsToBar(seats: Selection<SVGRectElement, unknown, null, undefined>, targetPositions: Array<{
109
+ x: number;
110
+ y: number;
111
+ width: number;
112
+ height: number;
113
+ }>): GSAPOrchestrator;
114
+ /**
115
+ * Stage 2a: Reveal X and Y axes to establish timeline context
116
+ *
117
+ * Fades in the chart axes (x-axis with dates, y-axis with values) to provide
118
+ * spatial context before the bar slides to its position. This stage establishes
119
+ * the timeline framework that gives meaning to the bar's position.
120
+ *
121
+ * @param xAxisGroup - D3 selection of the x-axis group element (must have opacity: 0)
122
+ * @param yAxisGroup - D3 selection of the y-axis group element (must have opacity: 0)
123
+ * @returns this - Returns the orchestrator instance for method chaining
124
+ *
125
+ * @remarks
126
+ * **Visual transformation:**
127
+ * - Axes fade in from opacity 0 → 1
128
+ * - Uses full stage duration for smooth, gradual reveal
129
+ * - Both axes animate simultaneously
130
+ * - Uses power2.inOut easing for professional motion
131
+ *
132
+ * **Data requirements:**
133
+ * - Axes must already exist in the DOM with opacity: 0
134
+ * - xAxisGroup should contain tick marks and labels for dates
135
+ * - yAxisGroup should contain tick marks and labels for values
136
+ *
137
+ * **Timeline integration:**
138
+ * - Added at 'axesReveal' label (after seats→bar transformation)
139
+ * - Duration: 12.5% of total animation (STAGE_DURATION_RATIOS.AXES_REVEAL)
140
+ * - Happens **before** bar slide to establish context first
141
+ * - Triggers onStageComplete callback when starting
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * const xAxis = svg.select('.x-axis').style('opacity', 0);
146
+ * const yAxis = svg.select('.y-axis').style('opacity', 0);
147
+ * orchestrator.animateAxesReveal(xAxis, yAxis);
148
+ * ```
149
+ */
150
+ animateAxesReveal(xAxisGroup: Selection<SVGGElement, unknown, null, undefined>, yAxisGroup: Selection<SVGGElement, unknown, null, undefined>): GSAPOrchestrator;
151
+ /**
152
+ * Stage 2b: Slide the collapsed bar horizontally to its timeline position
153
+ *
154
+ * Moves the vertical bar created in Stage 1 to its correct x-position on the timeline.
155
+ * This stage establishes spatial context by positioning the bar relative to the time axis.
156
+ *
157
+ * @param barSegments - D3 selection of bar segment rectangles to slide
158
+ * @param targetX - Final x-coordinate where the bar should be positioned on the timeline
159
+ * @returns this - Returns the orchestrator instance for method chaining
160
+ *
161
+ * @remarks
162
+ * **Visual transformation:**
163
+ * - Horizontal slide only (y-position and height remain constant)
164
+ * - All bar segments move together as a unified column
165
+ * - Uses power2.out easing for smooth deceleration (settling into place)
166
+ *
167
+ * **Timeline integration:**
168
+ * - Added at 'barSlide' label (after seats→bar transformation)
169
+ * - Duration: 25% of total animation (STAGE_DURATION_RATIOS.BAR_SLIDE)
170
+ * - Triggers onStageComplete callback when starting
171
+ *
172
+ * **Positioning:**
173
+ * - targetX typically corresponds to a specific timestamp on the x-axis
174
+ * - For "rightmost edge" positioning: targetX = width - margin.right
175
+ * - For "middle date" positioning: targetX = xScale(middleTimestamp)
176
+ *
177
+ * @example
178
+ * ```ts
179
+ * const barSegments = svg.selectAll('.bar-segment');
180
+ * const rightEdgeX = width - margin.right;
181
+ * orchestrator.animateBarSlide(barSegments, rightEdgeX);
182
+ * ```
183
+ */
184
+ animateBarSlide(barSegments: Selection<SVGRectElement, unknown, null, undefined>, targetX: number): GSAPOrchestrator;
185
+ /**
186
+ * Stage 3: Grow other bars with ripple effect from parliament position
187
+ *
188
+ * Animates the historical bars growing from the baseline, creating a wave-like
189
+ * ripple effect radiating outward from the parliament bar's position. Bars closer
190
+ * to the parliament position appear first, with increasing delay for distant bars.
191
+ *
192
+ * @param otherBars - D3 selection of bars at other timestamps (excluding parliament bar)
193
+ * @param parliamentIndex - Timeline index of the parliament bar (center of ripple)
194
+ * @param staggerDelay - Delay multiplier per distance unit (default: TIMING.RIPPLE_STAGGER_DELAY = 0.05)
195
+ * @returns this - Returns the orchestrator instance for method chaining
196
+ *
197
+ * @remarks
198
+ * **Visual transformation:**
199
+ * - Bars grow vertically from height=0 (baseline) to final stacked height
200
+ * - Ripple effect: delay = |barIndex - parliamentIndex| × staggerDelay
201
+ * - Bars furthest from parliament bar appear last (e.g., delay of 0.50s for 10 bars away)
202
+ * - Uses power2.out easing for smooth upward growth
203
+ *
204
+ * **Data requirements:**
205
+ * Each bar element must have these data attributes:
206
+ * - `data-final-y`: Target y-coordinate (top of bar)
207
+ * - `data-final-height`: Target height
208
+ * - `data-timestamp-index`: Position in timeline array
209
+ * - `data-baseline-y`: Y-coordinate of chart baseline (for fromTo animation)
210
+ *
211
+ * **Timeline integration:**
212
+ * - Added at 'barsGrow' label (after bar slide)
213
+ * - Duration: 25% of total animation (STAGE_DURATION_RATIOS.BARS_GROW)
214
+ * - Individual bars have additional stagger delays
215
+ * - Triggers onStageComplete callback when starting
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const otherBars = svg.selectAll('.bar:not(.parliament-bar)');
220
+ * const parliamentIndex = 15; // Parliament bar is at index 15
221
+ * orchestrator.animateBarsGrow(otherBars, parliamentIndex, 0.05);
222
+ * // Bars will appear with 50ms delay per timeline distance
223
+ * ```
224
+ */
225
+ animateBarsGrow(otherBars: Selection<SVGRectElement, unknown, null, undefined>, parliamentIndex: number, staggerDelay?: number): GSAPOrchestrator;
226
+ /**
227
+ * Stage 4: Morph bars into curved areas using path interpolation
228
+ *
229
+ * Transforms rectangular stacked bars into smooth, curved area paths. This is
230
+ * the final stage that creates the traditional stacked area chart appearance.
231
+ * Uses GSAP's path morphing to interpolate from bar rectangles to bezier curves.
232
+ *
233
+ * @param allBars - D3 selection of all bar rectangles (will be hidden during morph)
234
+ * @param morphPaths - D3 selection of SVG paths used for morphing (one per category)
235
+ * @param targetAreaPaths - Map of category IDs to target SVG path strings (curved areas)
236
+ * @param categories - Array of category definitions (used for grouping)
237
+ * @returns this - Returns the orchestrator instance for method chaining
238
+ *
239
+ * @remarks
240
+ * **Visual transformation:**
241
+ * - Rectangular bars (straight edges) → Curved area paths (smooth curves)
242
+ * - Bars fade out (opacity: 0), morphing paths fade in (opacity: 1)
243
+ * - GSAP interpolates path data attribute from bar shape to curve shape
244
+ * - Uses power2.inOut easing for smooth shape morphing
245
+ *
246
+ * **Path morphing technique:**
247
+ * 1. Each category has a morphPath element that starts as combined bar outline
248
+ * 2. morphPath's `d` attribute animates from bar path → area path
249
+ * 3. GSAP handles point interpolation automatically
250
+ * 4. Original bars hidden to avoid visual duplication
251
+ *
252
+ * **Data requirements:**
253
+ * - morphPaths must have `data-category` attribute matching category ID
254
+ * - allBars must have CSS class `category-{categoryKey}` for grouping
255
+ * - targetAreaPaths keys must match category IDs
256
+ *
257
+ * **Timeline integration:**
258
+ * - Added at 'barsToArea' label (after bars grow)
259
+ * - Duration: 20% of total animation (STAGE_DURATION_RATIOS.BARS_TO_AREA)
260
+ * - Triggers onStageComplete callback when starting
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * const allBars = svg.selectAll('.stacked-bar rect');
265
+ * const morphPaths = svg.selectAll('.morph-path');
266
+ * const targetPaths = new Map([
267
+ * ['java', 'M 100 300 C 150 280, 200 270, 250 260 L 250 300 Z'],
268
+ * ['python', 'M 100 260 C 150 240, 200 230, 250 220 L 250 260 Z']
269
+ * ]);
270
+ * orchestrator.animateBarsToArea(allBars, morphPaths, targetPaths, categories);
271
+ * ```
272
+ */
273
+ animateBarsToArea(allBars: Selection<SVGRectElement, unknown, null, undefined>, morphPaths: Selection<SVGPathElement, unknown, null, undefined>, targetAreaPaths: Map<string, string>, _categories: MorphChartCategory[]): GSAPOrchestrator;
274
+ /**
275
+ * Handle timeline progress updates
276
+ */
277
+ private handleProgress;
278
+ /**
279
+ * Get animation control interface
280
+ */
281
+ getControls(): AnimationControls;
282
+ /**
283
+ * Start the animation
284
+ */
285
+ play(): void;
286
+ /**
287
+ * Clean up and destroy the timeline
288
+ */
289
+ destroy(): void;
290
+ }
291
+ export {};
@@ -0,0 +1,96 @@
1
+ import { AreaPoint, SeatPosition } from '../morph-chart.types';
2
+ /**
3
+ * Interpolate between two numbers
4
+ */
5
+ export declare function lerp(start: number, end: number, progress: number): number;
6
+ /**
7
+ * Easing function for smooth morphing (ease-in-out cubic)
8
+ */
9
+ export declare function easeInOutCubic(t: number): number;
10
+ /**
11
+ * Easing function for elastic effect (optional, for more dramatic animation)
12
+ */
13
+ export declare function easeOutElastic(t: number): number;
14
+ /**
15
+ * Map parliament seats to their corresponding positions at the rightmost edge of the area chart
16
+ * Seats should map to the vertical position in the stacked area based on their category
17
+ *
18
+ * @param seats - Parliament seat positions
19
+ * @param areaSlice - Area chart data points at the rightmost time slice
20
+ * @param chartWidth - Width of the area chart
21
+ * @param chartHeight - Height of the area chart
22
+ * @param margin - Chart margins
23
+ */
24
+ export declare function mapSeatsToRightEdge(seats: SeatPosition[], areaSlice: AreaPoint[], chartWidth: number, chartHeight: number): Map<SeatPosition, {
25
+ x: number;
26
+ y: number;
27
+ }>;
28
+ /**
29
+ * Calculate interpolated seat position during parliament → area morphing
30
+ *
31
+ * Phase 1 (0.0 - 0.5): Seats move from parliament positions to right edge of area chart
32
+ * Phase 2 (0.5 - 1.0): Seats stay at right edge while areas expand
33
+ *
34
+ * @param seat - Original parliament seat position
35
+ * @param targetPosition - Target position at right edge
36
+ * @param progress - Overall morph progress (0 = parliament, 1 = area)
37
+ */
38
+ export declare function interpolateSeatToEdge(seat: SeatPosition, targetPosition: {
39
+ x: number;
40
+ y: number;
41
+ }, progress: number): {
42
+ x: number;
43
+ y: number;
44
+ opacity: number;
45
+ radius: number;
46
+ };
47
+ /**
48
+ * Calculate interpolated area expansion during parliament → area morphing
49
+ *
50
+ * Phase 1 (0.0 - 0.5): Areas are compressed to right edge (not visible)
51
+ * Phase 2 (0.5 - 1.0): Areas expand leftward from right edge
52
+ *
53
+ * @param progress - Overall morph progress (0 = parliament, 1 = area)
54
+ * @param chartWidth - Full width of area chart
55
+ */
56
+ export declare function interpolateAreaExpansion(progress: number, chartWidth: number): {
57
+ visibleWidth: number;
58
+ opacity: number;
59
+ clipX: number;
60
+ };
61
+ /**
62
+ * Calculate interpolated positions for area → parliament morphing (reverse)
63
+ *
64
+ * Phase 1 (0.0 - 0.5): Areas compress to right edge
65
+ * Phase 2 (0.5 - 1.0): Seats expand from right edge to parliament layout
66
+ */
67
+ export declare function interpolateAreaToParliament(progress: number, chartWidth: number, seat: SeatPosition, edgePosition: {
68
+ x: number;
69
+ y: number;
70
+ }): {
71
+ areaClipX: number;
72
+ areaOpacity: number;
73
+ seatX: number;
74
+ seatY: number;
75
+ seatOpacity: number;
76
+ seatRadius: number;
77
+ };
78
+ /**
79
+ * Calculate the vertical stacking position for area points
80
+ * Used to determine where seats should map to at the right edge
81
+ */
82
+ export declare function calculateStackedPosition(value: number, previousSum: number, maxValue: number, chartHeight: number): {
83
+ y0: number;
84
+ y1: number;
85
+ };
86
+ /**
87
+ * Extract the rightmost time slice from area chart data
88
+ * This represents the same point-in-time as the parliament chart
89
+ */
90
+ export declare function extractRightmostSlice(data: Array<{
91
+ timestamp: number;
92
+ [key: string]: number;
93
+ }>, categories: Array<{
94
+ dataKey: string;
95
+ label: string;
96
+ }>, chartHeight: number): AreaPoint[];
@@ -0,0 +1,23 @@
1
+ import { Selection } from 'd3-selection';
2
+ import { MorphChartCategory, ParliamentLayout } from '../morph-chart.types';
3
+ /**
4
+ * Sanitize category name for use in CSS class names
5
+ * Replaces spaces, slashes, and other special characters with hyphens
6
+ */
7
+ export declare function sanitizeCategoryForClass(category: string): string;
8
+ interface ParliamentRenderOptions {
9
+ centerX: number;
10
+ centerY: number;
11
+ addClasses?: boolean;
12
+ instanceId?: string;
13
+ parliamentRadius?: number;
14
+ }
15
+ /**
16
+ * Render parliament seats into an SVG container
17
+ * @param container - D3 selection of the container (typically a <g> element)
18
+ * @param layout - Parliament layout with seat positions
19
+ * @param categories - Category definitions with colors
20
+ * @param options - Rendering options (positioning, styling)
21
+ */
22
+ export declare function renderParliamentSeats(container: Selection<SVGGElement, unknown, null, undefined>, layout: ParliamentLayout, categories: MorphChartCategory[], options: ParliamentRenderOptions): void;
23
+ export {};
@@ -0,0 +1,33 @@
1
+ import { ParliamentLayout } from '../morph-chart.types';
2
+ type Party = {
3
+ id: string | number;
4
+ name: string;
5
+ seats: number;
6
+ colour: string;
7
+ };
8
+ type ParliamentOptions = {
9
+ arcAngle: number;
10
+ arcAngleFlexibility?: number;
11
+ radius: number;
12
+ seatSize: number;
13
+ minSeatSize: number;
14
+ maxSeatSize: number;
15
+ spacing: number;
16
+ innerRadiusRatio: number;
17
+ };
18
+ /**
19
+ * Generate parliament layout with seat positions
20
+ * Based on the logic from parliament-svg-enhanced.ts but returns position data
21
+ * instead of SVG elements
22
+ */
23
+ export declare function generateParliamentLayout(parties: Party[], options: ParliamentOptions): ParliamentLayout;
24
+ /**
25
+ * Convert category data to parliament party format
26
+ */
27
+ export declare function categoriesToParties(categories: Array<{
28
+ dataKey: string;
29
+ label: string;
30
+ color: string;
31
+ value: number;
32
+ }>, totalRepositories: number, maxSeats: number): Party[];
33
+ export {};
@@ -0,0 +1,48 @@
1
+ import { ScaleLinear, ScaleTime } from 'd3-scale';
2
+ import { ParliamentLayout, SeatPosition } from '../morph-chart.types';
3
+ /**
4
+ * Map parliament seats to their target positions at the right edge of the stacked area chart
5
+ * Seats can be positioned at the top (y1) or distributed vertically within their category's segment
6
+ *
7
+ * NOTE: stackData uses dataKey, but parliamentLayout.seats use category labels.
8
+ * We need to match by label, so stackData must contain label information.
9
+ *
10
+ * @param distributeVertically - If true, seats are spread between y0 and y1; if false, all seats at y1
11
+ */
12
+ export declare function mapSeatsToStackEdge(parliamentLayout: ParliamentLayout, stackData: Array<{
13
+ dataKey: string;
14
+ label?: string;
15
+ y0: number;
16
+ y1: number;
17
+ timestamp?: number;
18
+ isSpecialCategory?: boolean;
19
+ }>, xScale: ScaleTime<number, number>, yScale: ScaleLinear<number, number>, chartWidth: number, chartHeight: number, distributeVertically?: boolean): Map<SeatPosition, {
20
+ x: number;
21
+ y: number;
22
+ }>;
23
+ /**
24
+ * Extract the rightmost slice of stacked area data
25
+ * This represents the same point-in-time as the parliament chart
26
+ *
27
+ * IMPORTANT: The stack is generated using original category order.
28
+ * We build the slice in original order to match the stack generation.
29
+ */
30
+ export declare function extractRightmostStackSlice(data: Array<{
31
+ timestamp: number;
32
+ [key: string]: number;
33
+ }>, categories: Array<{
34
+ dataKey: string;
35
+ label: string;
36
+ color: string;
37
+ parliamentMapping?: {
38
+ isSpecialCategory?: boolean;
39
+ };
40
+ }>, _yScale: ScaleLinear<number, number>): Array<{
41
+ dataKey: string;
42
+ label: string;
43
+ y0: number;
44
+ y1: number;
45
+ value: number;
46
+ timestamp: number;
47
+ isSpecialCategory?: boolean;
48
+ }>;
@@ -0,0 +1,70 @@
1
+ import { ScaleLinear, ScaleTime } from 'd3-scale';
2
+ import { MorphChartCategory } from '../morph-chart.types';
3
+ interface StackedSeriesDataPoint {
4
+ data: {
5
+ timestamp: number;
6
+ };
7
+ 0: number;
8
+ 1: number;
9
+ }
10
+ export type SegmentTransform = {
11
+ segmentId: string;
12
+ dataKey: string;
13
+ timestamp: number;
14
+ x: number;
15
+ y: number;
16
+ rotation: number;
17
+ length: number;
18
+ };
19
+ /**
20
+ * Calculate curve data for stacked area chart
21
+ * Generates the curved path data that segments will transform into
22
+ *
23
+ * @param stackedData - D3 stacked data
24
+ * @param categories - Category definitions
25
+ * @param xScale - X scale (time)
26
+ * @param yScale - Y scale (values)
27
+ * @returns Array of curve data for each category
28
+ */
29
+ export declare function calculateStackedCurveData(stackedData: StackedSeriesDataPoint[][], categories: MorphChartCategory[], xScale: ScaleTime<number, number>, yScale: ScaleLinear<number, number>): Array<{
30
+ dataKey: string;
31
+ category: string;
32
+ points: Array<{
33
+ x: number;
34
+ y: number;
35
+ timestamp: number;
36
+ }>;
37
+ pathData: string;
38
+ }>;
39
+ /**
40
+ * Calculate transformations for horizontal bar top segments to align with curves
41
+ * Each segment gets position, rotation, and length data
42
+ *
43
+ * @param barSegments - Array of bar segments with their positions
44
+ * @param curveData - Calculated curve data for all categories
45
+ * @param segmentLength - Desired length of each segment
46
+ * @returns Array of transformation data for each segment
47
+ */
48
+ export declare function calculateSegmentTransforms(barSegments: Array<{
49
+ dataKey: string;
50
+ timestamp: number;
51
+ x: number;
52
+ y: number;
53
+ width: number;
54
+ }>, curveData: ReturnType<typeof calculateStackedCurveData>, segmentLength: number): SegmentTransform[];
55
+ /**
56
+ * Extract bar top segment positions from rendered bars
57
+ * Identifies the top edge of each bar segment for transformation
58
+ *
59
+ * @param svg - SVG container with bar elements
60
+ * @returns Array of segment position data
61
+ */
62
+ export declare function extractBarTopPositions(svg: SVGSVGElement): Array<{
63
+ dataKey: string;
64
+ timestamp: number;
65
+ x: number;
66
+ y: number;
67
+ width: number;
68
+ element: SVGElement;
69
+ }>;
70
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Selection } from 'd3-selection';
2
+ export interface Slinky3DConfig {
3
+ categories: Array<{
4
+ name: string;
5
+ color: string;
6
+ seatCount: number;
7
+ }>;
8
+ centerX: number;
9
+ centerY: number;
10
+ radius: number;
11
+ arcAngle: number;
12
+ }
13
+ /**
14
+ * Generate HTML content for 3D slinky rings
15
+ */
16
+ export declare function generate3DSlinkyHTML(categories: Array<{
17
+ name: string;
18
+ color: string;
19
+ seatCount: number;
20
+ }>): string;
21
+ /**
22
+ * Generate CSS styles for 3D slinky effect
23
+ */
24
+ export declare function generate3DSlinkyStyles(instanceId: string): string;
25
+ /**
26
+ * Create 3D slinky elements in SVG using foreignObject
27
+ */
28
+ export declare function create3DSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: Slinky3DConfig, instanceId: string): {
29
+ wrapper: Selection<SVGForeignObjectElement, unknown, null, undefined>;
30
+ cleanup: () => void;
31
+ };
32
+ /**
33
+ * Animate 3D slinky compression using GSAP
34
+ */
35
+ export declare function animate3DSlinkyCompression(instanceId: string, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
@@ -0,0 +1,19 @@
1
+ import { Selection } from 'd3-selection';
2
+ /**
3
+ * Add all hatch pattern definitions to an SVG's <defs> element
4
+ * Call this once when setting up the SVG
5
+ * @param svg - The SVG selection to add patterns to
6
+ * @param instancePrefix - Unique prefix for this instance to avoid ID conflicts
7
+ */
8
+ export declare function addHatchPatternDefs(svg: Selection<SVGSVGElement, unknown, null, undefined>, instancePrefix: string): void;
9
+ /**
10
+ * Transform a color to use instance-specific pattern IDs
11
+ * Converts 'url(#patternName)' to 'url(#prefix-patternName)'
12
+ */
13
+ export declare function transformColorForInstance(color: string, instancePrefix: string): string;
14
+ /**
15
+ * Get the display color for a category, handling pattern URLs
16
+ * Returns the line color for patterns (better visibility in hover states)
17
+ * Works with both instance-specific and generic pattern URLs
18
+ */
19
+ export declare function getDisplayColor(color: string): string;
@@ -0,0 +1,25 @@
1
+ import { Selection } from 'd3-selection';
2
+ export interface SvgSlinkyConfig {
3
+ categories: Array<{
4
+ name: string;
5
+ color: string;
6
+ seatCount: number;
7
+ }>;
8
+ centerX: number;
9
+ centerY: number;
10
+ radius: number;
11
+ innerRadius: number;
12
+ arcAngle: number;
13
+ }
14
+ /**
15
+ * Create SVG slinky coils
16
+ */
17
+ export declare function createSvgSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: SvgSlinkyConfig, instanceId: string): {
18
+ slinkyGroup: Selection<SVGGElement, unknown, null, undefined>;
19
+ cleanup: () => void;
20
+ };
21
+ /**
22
+ * Animate SVG slinky closing - stacks rings vertically into a bar on the right
23
+ * Uses staggered animation phases to create realistic slinky walking effect
24
+ */
25
+ export declare function animateSvgSlinkyCompression(slinkyGroup: Selection<SVGGElement, unknown, null, undefined>, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
@@ -1,5 +1,6 @@
1
1
  import { RefObject } from 'react';
2
2
  import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
3
+ import { ArcSweepDirection } from '../utils/parliament-animation';
3
4
  type UseParliamentChartProps = {
4
5
  containerRef: RefObject<HTMLDivElement>;
5
6
  processedData: ProcessedDataItem[];
@@ -12,11 +13,14 @@ type UseParliamentChartProps = {
12
13
  setActivePartyName: (name: string | null) => void;
13
14
  chartConfig: ChartConfig;
14
15
  seatSize: number;
16
+ shouldAnimate?: boolean;
17
+ animationDirection?: ArcSweepDirection;
18
+ onAnimationComplete?: () => void;
15
19
  };
16
20
  /**
17
21
  * Hook that manages parliament chart rendering and interactivity.
18
22
  * Generates SVG visualization with seat circles and handles hover states
19
23
  * for displaying repository statistics.
20
24
  */
21
- export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize }: UseParliamentChartProps) => void;
25
+ export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize, shouldAnimate, animationDirection, onAnimationComplete }: UseParliamentChartProps) => void;
22
26
  export {};