@moderneinc/react-charts 1.2.0-next.fe4657 → 1.3.0-next.2608df
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.types.d.ts +16 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +20 -0
- package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +10 -2
- package/dist/components/d3-stacked-bar-chart/d3-stacked-bar-chart.component.d.ts +7 -0
- package/dist/components/d3-stacked-bar-chart/d3-stacked-bar-chart.types.d.ts +95 -0
- package/dist/components/d3-stacked-bar-chart/hooks/use-d3-stacked-bar.hook.d.ts +36 -0
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +6 -1
- package/dist/components/morph-chart/morph-chart.types.d.ts +16 -0
- package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +4 -3
- package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +3 -11
- package/dist/index.cjs +27 -122
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9160 -24624
- package/dist/{components/stacked-area-chart/stacked-area-chart.constants.d.ts → theme/chart-palettes.d.ts} +4 -60
- package/dist/theme/timeline-defaults.d.ts +0 -8
- package/package.json +6 -16
- package/dist/components/morph-chart/index.d.ts +0 -2
- package/dist/components/morph-chart/utils/accordion-generator.d.ts +0 -102
- package/dist/components/morph-chart/utils/animation-utils.d.ts +0 -44
- package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +0 -53
- package/dist/components/morph-chart/utils/morph-interpolator.d.ts +0 -96
- package/dist/components/morph-chart/utils/segment-transformer.d.ts +0 -70
- package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +0 -35
- package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +0 -25
- package/dist/components/stacked-area-chart/hooks/use-stacked-area-chart.hook.d.ts +0 -6
- package/dist/components/stacked-area-chart/stacked-area-chart.component.d.ts +0 -10
- package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +0 -186
- package/dist/components/stacked-area-chart/utils/color.utils.d.ts +0 -4
- package/dist/components/stacked-area-with-timeline/index.d.ts +0 -4
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates gradient colors for categories, ordered from worst (red) to best (green).
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateMeasureGradient(count: number): string[];
|
|
1
5
|
/**
|
|
2
6
|
* Default colors for stacked area chart categories
|
|
3
7
|
* These colors are designed to work well together and provide good contrast
|
|
@@ -24,66 +28,6 @@ export declare const DEFAULT_STACKED_AREA_COLORS: {
|
|
|
24
28
|
readonly light: "#EDEFEF";
|
|
25
29
|
readonly dark: "#343a40";
|
|
26
30
|
};
|
|
27
|
-
/**
|
|
28
|
-
* Default configuration for stacked area chart
|
|
29
|
-
*/
|
|
30
|
-
export declare const DEFAULT_STACKED_AREA_CONFIG: {
|
|
31
|
-
readonly dimensions: {
|
|
32
|
-
readonly height: 400;
|
|
33
|
-
readonly width: "100%";
|
|
34
|
-
readonly minHeight: 200;
|
|
35
|
-
};
|
|
36
|
-
readonly margin: {
|
|
37
|
-
readonly top: 10;
|
|
38
|
-
readonly right: 30;
|
|
39
|
-
readonly left: 0;
|
|
40
|
-
readonly bottom: 0;
|
|
41
|
-
};
|
|
42
|
-
readonly animation: {
|
|
43
|
-
readonly enabled: true;
|
|
44
|
-
readonly duration: 1500;
|
|
45
|
-
readonly easing: "ease";
|
|
46
|
-
};
|
|
47
|
-
readonly display: {
|
|
48
|
-
readonly showHeader: true;
|
|
49
|
-
readonly showLegend: true;
|
|
50
|
-
readonly showTooltip: true;
|
|
51
|
-
readonly showXAxis: true;
|
|
52
|
-
readonly showYAxis: true;
|
|
53
|
-
readonly showGrid: true;
|
|
54
|
-
};
|
|
55
|
-
readonly curve: {
|
|
56
|
-
readonly type: "monotone";
|
|
57
|
-
};
|
|
58
|
-
readonly stack: {
|
|
59
|
-
readonly offset: "none";
|
|
60
|
-
};
|
|
61
|
-
readonly axis: {
|
|
62
|
-
readonly strokeColor: "#ADB5BD";
|
|
63
|
-
readonly tickColor: "#666";
|
|
64
|
-
readonly labelColor: "#666";
|
|
65
|
-
};
|
|
66
|
-
readonly tooltip: {
|
|
67
|
-
readonly backgroundColor: "rgba(255, 255, 255, 0.95)";
|
|
68
|
-
readonly borderColor: "#ADB5BD";
|
|
69
|
-
readonly borderWidth: 1;
|
|
70
|
-
readonly borderRadius: 4;
|
|
71
|
-
readonly padding: 10;
|
|
72
|
-
};
|
|
73
|
-
readonly legend: {
|
|
74
|
-
readonly iconSize: 14;
|
|
75
|
-
readonly iconType: "square";
|
|
76
|
-
readonly layout: "horizontal";
|
|
77
|
-
readonly align: "center";
|
|
78
|
-
readonly verticalAlign: "bottom";
|
|
79
|
-
};
|
|
80
|
-
readonly marker: {
|
|
81
|
-
readonly strokeColor: "#666";
|
|
82
|
-
readonly strokeWidth: 2;
|
|
83
|
-
readonly strokeDasharray: "5 5";
|
|
84
|
-
readonly labelColor: "#666";
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
31
|
/**
|
|
88
32
|
* Predefined color palettes for common use cases
|
|
89
33
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moderneinc/react-charts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-next.2608df",
|
|
4
4
|
"description": "Parliament chart visualization library for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devEngines": {
|
|
@@ -51,17 +51,14 @@
|
|
|
51
51
|
"@mui/icons-material": ">=7.0.0",
|
|
52
52
|
"@mui/material": ">=7.0.0",
|
|
53
53
|
"react": "^18.0.0 || ^19.0.0",
|
|
54
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
55
|
-
"recharts": ">=2.0.0"
|
|
54
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
56
55
|
},
|
|
57
56
|
"dependencies": {
|
|
58
|
-
"@dnd-kit/core": "^6.3.1",
|
|
59
|
-
"@dnd-kit/utilities": "^3.2.2",
|
|
60
|
-
"d3-array": "^3.2.4",
|
|
61
57
|
"d3-axis": "^3.0.0",
|
|
62
58
|
"d3-brush": "^3.0.0",
|
|
63
|
-
"d3-
|
|
59
|
+
"d3-scale": "^4.0.2",
|
|
64
60
|
"d3-selection": "^3.0.0",
|
|
61
|
+
"d3-shape": "^3.2.0",
|
|
65
62
|
"d3-transition": "^3.0.1",
|
|
66
63
|
"gsap": "^3.13.0",
|
|
67
64
|
"hast-util-to-html": "^9.0.5",
|
|
@@ -81,33 +78,26 @@
|
|
|
81
78
|
"@storybook/addon-interactions": "^8.4.7",
|
|
82
79
|
"@storybook/addon-links": "^8.4.7",
|
|
83
80
|
"@storybook/addon-themes": "^8.4.7",
|
|
84
|
-
"@storybook/blocks": "^8.4.7",
|
|
85
81
|
"@storybook/react": "^8.4.7",
|
|
86
82
|
"@storybook/react-vite": "^8.4.7",
|
|
87
83
|
"@storybook/test": "^8.4.7",
|
|
88
|
-
"@types/d3-array": "^3.2.2",
|
|
89
84
|
"@types/d3-axis": "^3.0.6",
|
|
90
85
|
"@types/d3-brush": "^3.0.6",
|
|
91
86
|
"@types/d3-scale": "^4.0.9",
|
|
92
87
|
"@types/d3-selection": "^3.0.11",
|
|
93
88
|
"@types/d3-shape": "^3.1.7",
|
|
94
89
|
"@types/d3-transition": "^3.0.9",
|
|
90
|
+
"@types/hast": "^3.0.4",
|
|
95
91
|
"@types/react": "^18.3.0",
|
|
96
92
|
"@types/react-dom": "^18.3.0",
|
|
97
|
-
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
98
|
-
"@typescript-eslint/parser": "^8.44.0",
|
|
99
93
|
"@vitejs/plugin-react": "^4.3.4",
|
|
94
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
100
95
|
"@vitest/ui": "^3.2.4",
|
|
101
96
|
"eslint": "^9.36.0",
|
|
102
|
-
"eslint-plugin-react-hooks": "^5.1.0",
|
|
103
|
-
"eslint-plugin-react-refresh": "^0.4.16",
|
|
104
|
-
"eslint-plugin-storybook": "^0.11.1",
|
|
105
97
|
"jsdom": "^27.0.0",
|
|
106
98
|
"knip": "^5.66.4",
|
|
107
|
-
"playwright": "^1.56.1",
|
|
108
99
|
"react": "^19.1.1",
|
|
109
100
|
"react-dom": "^19.1.1",
|
|
110
|
-
"recharts": "^2.15.0",
|
|
111
101
|
"semantic-release": "^25.0.2",
|
|
112
102
|
"storybook": "^8.4.7",
|
|
113
103
|
"typescript": "^5.9.2",
|
|
@@ -1,102 +0,0 @@
|
|
|
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,44 +0,0 @@
|
|
|
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;
|
|
@@ -1,53 +0,0 @@
|
|
|
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[];
|
|
@@ -1,96 +0,0 @@
|
|
|
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[];
|
|
@@ -1,70 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,35 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
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,6 +0,0 @@
|
|
|
1
|
-
import { UseStackedAreaChartProps, UseStackedAreaChartReturn } from '../stacked-area-chart.types';
|
|
2
|
-
/**
|
|
3
|
-
* Manages stacked area chart data validation, processing, and formatting.
|
|
4
|
-
* Handles category validation, timestamp ranges, and max value computation.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useStackedAreaChart(props: UseStackedAreaChartProps): UseStackedAreaChartReturn;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { StackedAreaChartProps } from './stacked-area-chart.types';
|
|
3
|
-
/**
|
|
4
|
-
* Displays time-series data as a stacked area chart with responsive sizing,
|
|
5
|
-
* customizable colors, interactive tooltips, and smooth animations.
|
|
6
|
-
*
|
|
7
|
-
* Designed for ParliamentChart transitions - data structure supports point-in-time
|
|
8
|
-
* views enabling animated morphing between visualizations.
|
|
9
|
-
*/
|
|
10
|
-
export declare const StackedAreaChart: FunctionComponent<StackedAreaChartProps>;
|