@moderneinc/react-charts 1.1.0 → 1.2.0-next.27c469
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/components/chrono-chart/chrono-chart.component.d.ts +10 -0
- package/dist/components/chrono-chart/chrono-chart.types.d.ts +112 -0
- package/dist/components/chrono-chart/components/category-table.component.d.ts +13 -0
- package/dist/components/chrono-chart/components/category-table.types.d.ts +42 -0
- package/dist/components/chrono-chart/utils/data-transformer.d.ts +41 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.component.d.ts +7 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +89 -0
- package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +34 -0
- package/dist/components/morph-chart/hooks/shared/computations.d.ts +29 -0
- package/dist/components/morph-chart/hooks/shared/types.d.ts +24 -0
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +87 -0
- package/dist/components/morph-chart/index.d.ts +2 -0
- package/dist/components/morph-chart/morph-chart.component.d.ts +14 -0
- package/dist/components/morph-chart/morph-chart.types.d.ts +158 -0
- package/dist/components/morph-chart/utils/accordion-generator.d.ts +102 -0
- package/dist/components/morph-chart/utils/animation-constants.d.ts +23 -0
- package/dist/components/morph-chart/utils/animation-utils.d.ts +44 -0
- package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +53 -0
- package/dist/components/morph-chart/utils/area-renderer.d.ts +24 -0
- package/dist/components/morph-chart/utils/bar-renderer.d.ts +19 -0
- package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +291 -0
- package/dist/components/morph-chart/utils/morph-interpolator.d.ts +96 -0
- package/dist/components/morph-chart/utils/parliament-renderer.d.ts +23 -0
- package/dist/components/morph-chart/utils/parliament-seat-extractor.d.ts +33 -0
- package/dist/components/morph-chart/utils/position-mapper.d.ts +48 -0
- package/dist/components/morph-chart/utils/segment-transformer.d.ts +70 -0
- package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +35 -0
- package/dist/components/morph-chart/utils/svg-patterns.d.ts +19 -0
- package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +25 -0
- package/dist/components/parliament-chart/hooks/{useParliamentChart.d.ts → use-parliament-chart.hook.d.ts} +6 -2
- package/dist/components/parliament-chart/{ParliamentChart.d.ts → parliament-chart.component.d.ts} +1 -1
- package/dist/components/parliament-chart/{ParliamentChart.types.d.ts → parliament-chart.types.d.ts} +6 -1
- package/dist/components/parliament-chart/utils/parliament-animation.d.ts +13 -0
- package/dist/components/stacked-area-chart/hooks/use-stacked-area-chart.hook.d.ts +6 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.component.d.ts +10 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.constants.d.ts +115 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +186 -0
- package/dist/components/stacked-area-chart/utils/color.utils.d.ts +4 -0
- package/dist/components/timeline-chart/hooks/use-timeline-chart.hook.d.ts +2 -0
- package/dist/components/timeline-chart/timeline-chart.component.d.ts +9 -0
- package/dist/components/timeline-chart/timeline-chart.types.d.ts +156 -0
- package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
- package/dist/index.cjs +144 -11
- package/dist/index.d.ts +21 -8
- package/dist/index.js +31142 -4853
- package/dist/theme/{defaultColors.d.ts → default-colors.d.ts} +8 -4
- package/dist/theme/timeline-defaults.d.ts +82 -0
- package/package.json +36 -13
- /package/dist/components/parliament-chart/{ParliamentChart.constants.d.ts → parliament-chart.constants.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentArcCalculator.d.ts → parliament-arc-calculator.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentChartData.utils.d.ts → parliament-chart-data.utils.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvgEnhanced.d.ts → parliament-svg-enhanced.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvgPatterns.d.ts → parliament-svg-patterns.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvg.d.ts → parliament-svg.d.ts} +0 -0
|
@@ -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;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Animation constants for parliament to stacked area morphing
|
|
3
|
+
* Centralized configuration for timing, easing, and stage proportions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* GSAP easing functions for smooth transitions
|
|
7
|
+
* Uses GSAP's power easing for professional motion
|
|
8
|
+
*/
|
|
9
|
+
export declare const EASING: {
|
|
10
|
+
/** Smooth acceleration and deceleration - used for transformations */
|
|
11
|
+
readonly IN_OUT: "power2.inOut";
|
|
12
|
+
/** Smooth deceleration only - used for sliding and growing */
|
|
13
|
+
readonly OUT: "power2.out";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Timing constants for staggered animations
|
|
17
|
+
*/
|
|
18
|
+
export declare const TIMING: {
|
|
19
|
+
/** No stagger - all elements animate simultaneously */
|
|
20
|
+
readonly NO_STAGGER: 0;
|
|
21
|
+
/** Ripple effect delay - each bar delayed by distance × this value (50ms per unit) */
|
|
22
|
+
readonly RIPPLE_STAGGER_DELAY: 0.05;
|
|
23
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for animation path manipulation
|
|
3
|
+
* Shared helpers for creating SVG paths from bar geometries
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Create a rectangular SVG path from bar dimensions
|
|
7
|
+
* Used as the initial state for path morphing animations
|
|
8
|
+
*
|
|
9
|
+
* @param x - Left edge x-coordinate of the rectangle
|
|
10
|
+
* @param y - Top edge y-coordinate of the rectangle
|
|
11
|
+
* @param width - Width of the rectangle
|
|
12
|
+
* @param height - Height of the rectangle
|
|
13
|
+
* @returns SVG path string representing a closed rectangle
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const path = createRectPath(100, 50, 20, 80);
|
|
18
|
+
* // Returns: "M 100 130 L 100 50 L 120 50 L 120 130 Z"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function createRectPath(x: number, y: number, width: number, height: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Create a combined SVG path from multiple bar segments for a single category
|
|
24
|
+
* Connects all bars into a single continuous path suitable for morphing
|
|
25
|
+
*
|
|
26
|
+
* The path traces along the top edges of all bars (left to right),
|
|
27
|
+
* then closes along the bottom baseline, creating a unified shape.
|
|
28
|
+
*
|
|
29
|
+
* @param bars - Array of SVG rect elements to combine
|
|
30
|
+
* @returns SVG path string representing the combined shape
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const bars = svg.selectAll('.category-java rect').nodes();
|
|
35
|
+
* const combinedPath = createCombinedBarPath(bars);
|
|
36
|
+
* // Returns path that traces outline of all bars
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* - Bars are automatically sorted by x-position (left to right)
|
|
41
|
+
* - Empty array returns empty string
|
|
42
|
+
* - Path draws: bottom-left → tops (left-to-right) → bottom-right → close
|
|
43
|
+
*/
|
|
44
|
+
export declare function createCombinedBarPath(bars: SVGRectElement[]): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arc path calculator for slinky-style seat → bar animations
|
|
3
|
+
* Generates pronounced bezier arc paths for smooth cascading motion
|
|
4
|
+
*/
|
|
5
|
+
export interface Point {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ArcPathData {
|
|
10
|
+
startX: number;
|
|
11
|
+
startY: number;
|
|
12
|
+
controlX: number;
|
|
13
|
+
controlY: number;
|
|
14
|
+
endX: number;
|
|
15
|
+
endY: number;
|
|
16
|
+
distance: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Calculate the control point for a quadratic bezier curve
|
|
20
|
+
* Creates a pronounced arc by offsetting perpendicular to the direct path
|
|
21
|
+
*
|
|
22
|
+
* @param start - Starting point (seat position)
|
|
23
|
+
* @param end - Ending point (bar segment position)
|
|
24
|
+
* @param arcIntensity - How pronounced the arc should be (0-1, default 0.35 for 35% offset)
|
|
25
|
+
* @returns Control point for the bezier curve
|
|
26
|
+
*/
|
|
27
|
+
export declare function calculateArcControlPoint(start: Point, end: Point, arcIntensity?: number): Point;
|
|
28
|
+
/**
|
|
29
|
+
* Generate complete arc path data for animating a seat to a bar position
|
|
30
|
+
*
|
|
31
|
+
* @param seatPosition - Current seat position in parliament
|
|
32
|
+
* @param barPosition - Target bar segment position
|
|
33
|
+
* @param arcIntensity - How pronounced the arc should be (default 0.35)
|
|
34
|
+
* @returns Complete path data for GSAP animation
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateArcPath(seatPosition: Point, barPosition: Point, arcIntensity?: number): ArcPathData;
|
|
37
|
+
/**
|
|
38
|
+
* Generate SVG path string for a quadratic bezier arc
|
|
39
|
+
* Useful for debugging or visual representation
|
|
40
|
+
*
|
|
41
|
+
* @param pathData - Arc path data
|
|
42
|
+
* @returns SVG path string
|
|
43
|
+
*/
|
|
44
|
+
export declare function generateSVGPath(pathData: ArcPathData): string;
|
|
45
|
+
/**
|
|
46
|
+
* Calculate points along a quadratic bezier curve
|
|
47
|
+
* Useful for visualizing or debugging the arc path
|
|
48
|
+
*
|
|
49
|
+
* @param pathData - Arc path data
|
|
50
|
+
* @param numPoints - Number of points to generate along the curve (default 20)
|
|
51
|
+
* @returns Array of points along the curve
|
|
52
|
+
*/
|
|
53
|
+
export declare function getPointsAlongArc(pathData: ArcPathData, numPoints?: number): Point[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
import { MorphChartCategory } from '../morph-chart.types';
|
|
3
|
+
interface AreaRenderOptions {
|
|
4
|
+
xScale: (value: Date) => number;
|
|
5
|
+
yScale: (value: number) => number;
|
|
6
|
+
addClasses?: boolean;
|
|
7
|
+
instanceId?: string;
|
|
8
|
+
}
|
|
9
|
+
interface StackedDataPoint {
|
|
10
|
+
data: {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
};
|
|
13
|
+
0: number;
|
|
14
|
+
1: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Render stacked areas into an SVG container
|
|
18
|
+
* @param container - D3 selection of the container (typically a <g> element)
|
|
19
|
+
* @param stackedData - D3 stacked data (output of d3.stack())
|
|
20
|
+
* @param categories - Category definitions with colors and opacity
|
|
21
|
+
* @param options - Rendering options (scales, styling)
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderStackedAreas(container: Selection<SVGGElement, unknown, null, undefined>, stackedData: StackedDataPoint[][], categories: MorphChartCategory[], options: AreaRenderOptions): void;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MorphChartCategory } from '../morph-chart.types';
|
|
2
|
+
export type StackedBarSegment = {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
category: string;
|
|
5
|
+
dataKey: string;
|
|
6
|
+
y0: number;
|
|
7
|
+
y1: number;
|
|
8
|
+
value: number;
|
|
9
|
+
color: string;
|
|
10
|
+
isSpecialCategory: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Generate stacked bar data from time series
|
|
14
|
+
* Converts raw data into stacked segments for bar rendering
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateStackedBarData(data: Array<{
|
|
17
|
+
timestamp: number;
|
|
18
|
+
[key: string]: number;
|
|
19
|
+
}>, categories: MorphChartCategory[]): StackedBarSegment[];
|
|
@@ -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 {};
|