@moderneinc/react-charts 1.2.0-next.e5d8ee → 1.2.0-next.e86ce0
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 +7 -0
- package/dist/components/chrono-chart/chrono-chart.types.d.ts +64 -2
- package/dist/components/chrono-chart/components/category-table.component.d.ts +10 -0
- package/dist/components/chrono-chart/components/category-table.types.d.ts +25 -0
- package/dist/components/chrono-chart/utils/data-transformer.d.ts +32 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +6 -0
- package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +2 -1
- package/dist/components/morph-chart/hooks/shared/computations.d.ts +12 -10
- package/dist/components/morph-chart/hooks/shared/types.d.ts +7 -5
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +6 -1
- package/dist/components/morph-chart/morph-chart.types.d.ts +21 -0
- package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +55 -16
- package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +53 -0
- package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.component.d.ts +3 -0
- package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.types.d.ts +97 -0
- package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +46 -0
- package/dist/components/timeline-chart/timeline-chart.types.d.ts +17 -0
- package/dist/index.cjs +27 -122
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9586 -24416
- 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 +25 -1
- package/package.json +7 -14
- package/dist/components/morph-chart/index.d.ts +0 -2
- 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/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
|
@@ -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
|
*/
|
|
@@ -4,7 +4,7 @@ export declare const TIMELINE_DEFAULTS: {
|
|
|
4
4
|
readonly primary: "#992FB9";
|
|
5
5
|
readonly background: "#FFFFFF";
|
|
6
6
|
readonly border: "#9CA3AF";
|
|
7
|
-
readonly highlightBackground: "rgba(
|
|
7
|
+
readonly highlightBackground: "rgba(31, 41, 55, 0.14)";
|
|
8
8
|
readonly monthLabel: "#9ca3af";
|
|
9
9
|
readonly tooltipText: "#6b7280";
|
|
10
10
|
};
|
|
@@ -13,6 +13,17 @@ export declare const TIMELINE_DEFAULTS: {
|
|
|
13
13
|
readonly eventWidth: 2;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Get default slot props with arrow handle styling
|
|
18
|
+
*/
|
|
19
|
+
export declare const getArrowHandleSlotProps: (color?: string) => {
|
|
20
|
+
startHandle: {
|
|
21
|
+
sx: SxProps<Theme>;
|
|
22
|
+
};
|
|
23
|
+
endHandle: {
|
|
24
|
+
sx: SxProps<Theme>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
16
27
|
export declare const defaultSlotProps: {
|
|
17
28
|
header: {
|
|
18
29
|
sx: SxProps<Theme>;
|
|
@@ -38,6 +49,8 @@ export declare const defaultSlotProps: {
|
|
|
38
49
|
selection: {
|
|
39
50
|
sx: SxProps<Theme>;
|
|
40
51
|
};
|
|
52
|
+
startHandle: {};
|
|
53
|
+
endHandle: {};
|
|
41
54
|
tooltip: {
|
|
42
55
|
sx: SxProps<Theme>;
|
|
43
56
|
};
|
|
@@ -48,3 +61,14 @@ export declare const defaultSlotProps: {
|
|
|
48
61
|
sx: SxProps<Theme>;
|
|
49
62
|
};
|
|
50
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Get grip handle slot props with custom color
|
|
66
|
+
*/
|
|
67
|
+
export declare const getGripHandleSlotProps: (color?: string) => {
|
|
68
|
+
startHandle: {
|
|
69
|
+
sx: SxProps<Theme>;
|
|
70
|
+
};
|
|
71
|
+
endHandle: {
|
|
72
|
+
sx: SxProps<Theme>;
|
|
73
|
+
};
|
|
74
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moderneinc/react-charts",
|
|
3
|
-
"version": "1.2.0-next.
|
|
3
|
+
"version": "1.2.0-next.e86ce0",
|
|
4
4
|
"description": "Parliament chart visualization library for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devEngines": {
|
|
@@ -51,14 +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
|
-
"d3-array": "^3.2.4",
|
|
59
57
|
"d3-axis": "^3.0.0",
|
|
60
58
|
"d3-brush": "^3.0.0",
|
|
59
|
+
"d3-scale": "^4.0.2",
|
|
61
60
|
"d3-selection": "^3.0.0",
|
|
61
|
+
"d3-shape": "^3.2.0",
|
|
62
62
|
"d3-transition": "^3.0.1",
|
|
63
63
|
"gsap": "^3.13.0",
|
|
64
64
|
"hast-util-to-html": "^9.0.5",
|
|
@@ -78,34 +78,27 @@
|
|
|
78
78
|
"@storybook/addon-interactions": "^8.4.7",
|
|
79
79
|
"@storybook/addon-links": "^8.4.7",
|
|
80
80
|
"@storybook/addon-themes": "^8.4.7",
|
|
81
|
-
"@storybook/blocks": "^8.4.7",
|
|
82
81
|
"@storybook/react": "^8.4.7",
|
|
83
82
|
"@storybook/react-vite": "^8.4.7",
|
|
84
83
|
"@storybook/test": "^8.4.7",
|
|
85
|
-
"@types/d3-array": "^3.2.2",
|
|
86
84
|
"@types/d3-axis": "^3.0.6",
|
|
87
85
|
"@types/d3-brush": "^3.0.6",
|
|
88
86
|
"@types/d3-scale": "^4.0.9",
|
|
89
87
|
"@types/d3-selection": "^3.0.11",
|
|
90
88
|
"@types/d3-shape": "^3.1.7",
|
|
91
89
|
"@types/d3-transition": "^3.0.9",
|
|
90
|
+
"@types/hast": "^3.0.4",
|
|
92
91
|
"@types/react": "^18.3.0",
|
|
93
92
|
"@types/react-dom": "^18.3.0",
|
|
94
|
-
"@typescript-eslint/eslint-plugin": "^8.44.0",
|
|
95
|
-
"@typescript-eslint/parser": "^8.44.0",
|
|
96
93
|
"@vitejs/plugin-react": "^4.3.4",
|
|
94
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
97
95
|
"@vitest/ui": "^3.2.4",
|
|
98
96
|
"eslint": "^9.36.0",
|
|
99
|
-
"eslint-plugin-react-hooks": "^5.1.0",
|
|
100
|
-
"eslint-plugin-react-refresh": "^0.4.16",
|
|
101
|
-
"eslint-plugin-storybook": "^0.11.1",
|
|
102
97
|
"jsdom": "^27.0.0",
|
|
103
98
|
"knip": "^5.66.4",
|
|
104
|
-
"playwright": "^1.56.1",
|
|
105
99
|
"react": "^19.1.1",
|
|
106
100
|
"react-dom": "^19.1.1",
|
|
107
|
-
"
|
|
108
|
-
"semantic-release": "^24.2.0",
|
|
101
|
+
"semantic-release": "^25.0.2",
|
|
109
102
|
"storybook": "^8.4.7",
|
|
110
103
|
"typescript": "^5.9.2",
|
|
111
104
|
"vite": "^6.0.11",
|
|
@@ -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,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>;
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { BoxProps, StackProps, TypographyProps } from '@mui/material';
|
|
2
|
-
/**
|
|
3
|
-
* Represents a single data point in the stacked area chart.
|
|
4
|
-
* Each property beyond timestamp represents a category value at that point in time.
|
|
5
|
-
*
|
|
6
|
-
* Example:
|
|
7
|
-
* {
|
|
8
|
-
* timestamp: 1704067200000,
|
|
9
|
-
* Complete: 120,
|
|
10
|
-
* Close: 45,
|
|
11
|
-
* Far: 30
|
|
12
|
-
* }
|
|
13
|
-
*/
|
|
14
|
-
export type StackedAreaDataPoint = {
|
|
15
|
-
timestamp: number;
|
|
16
|
-
[category: string]: number;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Defines a category (area) in the stacked area chart.
|
|
20
|
-
* The dataKey must match a property in StackedAreaDataPoint.
|
|
21
|
-
*/
|
|
22
|
-
export type StackedAreaCategory = {
|
|
23
|
-
/** Key matching the property name in data points */
|
|
24
|
-
dataKey: string;
|
|
25
|
-
/** Display label for the category */
|
|
26
|
-
label: string;
|
|
27
|
-
/** Color for this area (hex color or CSS color string) */
|
|
28
|
-
color: string;
|
|
29
|
-
/** Optional stroke width in pixels (default: 2) */
|
|
30
|
-
strokeWidth?: number;
|
|
31
|
-
/** Optional dash pattern for the stroke (e.g., '5 5' for dashed) */
|
|
32
|
-
strokeDasharray?: string;
|
|
33
|
-
/** Optional fill opacity (0-1, default: 0.7) */
|
|
34
|
-
fillOpacity?: number;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Defines a marker (vertical line) at a specific timestamp.
|
|
38
|
-
* Markers are useful for highlighting significant events like releases, deployments, or milestones.
|
|
39
|
-
*/
|
|
40
|
-
export type StackedAreaMarker = {
|
|
41
|
-
/** Timestamp where the marker should be placed on the X-axis */
|
|
42
|
-
timestamp: number;
|
|
43
|
-
/** Optional label to display on the marker */
|
|
44
|
-
label?: string;
|
|
45
|
-
/** Optional color for the marker line (default: from config) */
|
|
46
|
-
color?: string;
|
|
47
|
-
/** Optional stroke width in pixels (default: from config) */
|
|
48
|
-
strokeWidth?: number;
|
|
49
|
-
/** Optional dash pattern for the stroke (e.g., '5 5' for dashed) */
|
|
50
|
-
strokeDasharray?: string;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Slot props for customizing stacked area chart component styles
|
|
54
|
-
*/
|
|
55
|
-
export type StackedAreaChartSlotProps = {
|
|
56
|
-
/** Props for the outer container (Stack) */
|
|
57
|
-
container?: StackProps;
|
|
58
|
-
/** Props for the header container (Stack) */
|
|
59
|
-
header?: StackProps;
|
|
60
|
-
/** Props for the title Typography component */
|
|
61
|
-
title?: TypographyProps;
|
|
62
|
-
/** Props for the subtitle/description Typography component */
|
|
63
|
-
subtitle?: TypographyProps;
|
|
64
|
-
/** Props for the chart container (Box) */
|
|
65
|
-
chartContainer?: BoxProps;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Props for the StackedAreaChart component
|
|
69
|
-
*/
|
|
70
|
-
export type StackedAreaChartProps = {
|
|
71
|
-
/** Array of data points sorted by timestamp (ascending) */
|
|
72
|
-
data: StackedAreaDataPoint[];
|
|
73
|
-
/** Array of category definitions for the areas to display */
|
|
74
|
-
categories: StackedAreaCategory[];
|
|
75
|
-
/** Optional array of markers (vertical lines) to display at specific timestamps */
|
|
76
|
-
markers?: StackedAreaMarker[];
|
|
77
|
-
/** Optional title displayed above the chart */
|
|
78
|
-
title?: string;
|
|
79
|
-
/** Optional subtitle/description displayed below the title */
|
|
80
|
-
subtitle?: string;
|
|
81
|
-
/** Show the chart header (title and subtitle) */
|
|
82
|
-
showHeader?: boolean;
|
|
83
|
-
/** Height of the chart in pixels (default: 400) */
|
|
84
|
-
height?: number;
|
|
85
|
-
/** Width of the chart (default: '100%') */
|
|
86
|
-
width?: string | number;
|
|
87
|
-
/** Show the legend */
|
|
88
|
-
showLegend?: boolean;
|
|
89
|
-
/** Show the tooltip on hover */
|
|
90
|
-
showTooltip?: boolean;
|
|
91
|
-
/** Show X-axis labels */
|
|
92
|
-
showXAxis?: boolean;
|
|
93
|
-
/** Show Y-axis labels */
|
|
94
|
-
showYAxis?: boolean;
|
|
95
|
-
/** Show grid lines */
|
|
96
|
-
showGrid?: boolean;
|
|
97
|
-
/** Enable animations */
|
|
98
|
-
enableAnimation?: boolean;
|
|
99
|
-
/** Animation duration in milliseconds (default: 1500) */
|
|
100
|
-
animationDuration?: number;
|
|
101
|
-
/** Animation easing function (default: 'ease') */
|
|
102
|
-
animationEasing?: 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear';
|
|
103
|
-
/** Custom date formatter for X-axis and tooltip */
|
|
104
|
-
formatDate?: (timestamp: number) => string;
|
|
105
|
-
/** Custom value formatter for Y-axis and tooltip */
|
|
106
|
-
formatValue?: (value: number) => string;
|
|
107
|
-
/** Custom tooltip formatter */
|
|
108
|
-
tooltipFormatter?: (value: number, name: string, props: unknown) => [string, string];
|
|
109
|
-
/** Props for customizing individual component slots */
|
|
110
|
-
slotProps?: StackedAreaChartSlotProps;
|
|
111
|
-
/** Margin around the chart (for axis labels) */
|
|
112
|
-
margin?: {
|
|
113
|
-
top?: number;
|
|
114
|
-
right?: number;
|
|
115
|
-
bottom?: number;
|
|
116
|
-
left?: number;
|
|
117
|
-
};
|
|
118
|
-
/**
|
|
119
|
-
* Curve type for the area paths
|
|
120
|
-
* - 'monotone': Smooth curves that preserve monotonicity
|
|
121
|
-
* - 'linear': Straight lines between points
|
|
122
|
-
* - 'step': Step function
|
|
123
|
-
* - 'stepBefore': Step function with vertical at start
|
|
124
|
-
* - 'stepAfter': Step function with vertical at end
|
|
125
|
-
*/
|
|
126
|
-
curveType?: 'monotone' | 'linear' | 'step' | 'stepBefore' | 'stepAfter';
|
|
127
|
-
/**
|
|
128
|
-
* Stack offset type
|
|
129
|
-
* - 'none': Stack normally
|
|
130
|
-
* - 'expand': Normalize to 0-100%
|
|
131
|
-
* - 'wiggle': Streamgraph layout
|
|
132
|
-
* - 'silhouette': Centered streamgraph
|
|
133
|
-
*/
|
|
134
|
-
stackOffset?: 'none' | 'expand' | 'wiggle' | 'silhouette';
|
|
135
|
-
/**
|
|
136
|
-
* External time domain control [minTimestamp, maxTimestamp]
|
|
137
|
-
* When provided, overrides automatic domain calculation and controls the X-axis range.
|
|
138
|
-
* Useful for synchronizing multiple charts to show the same time range.
|
|
139
|
-
*/
|
|
140
|
-
timeRange?: [number, number] | null;
|
|
141
|
-
/**
|
|
142
|
-
* Callback when user selects a time range via brush or other interaction
|
|
143
|
-
* Returns [startTimestamp, endTimestamp]
|
|
144
|
-
*/
|
|
145
|
-
onTimeRangeChange?: (range: [number, number]) => void;
|
|
146
|
-
/**
|
|
147
|
-
* Enable brush component for time range selection
|
|
148
|
-
* When enabled, displays a brush control below the chart that users can drag to select a time range.
|
|
149
|
-
* Triggers onTimeRangeChange callback when the brush is moved.
|
|
150
|
-
*/
|
|
151
|
-
enableBrush?: boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Zoom to selection mode - When enabled, dragging to select a range
|
|
154
|
-
* will automatically rescale the chart to show only that range via the timeRange prop.
|
|
155
|
-
* Selection highlight only shows during drag.
|
|
156
|
-
*/
|
|
157
|
-
zoomToSelection?: boolean;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* Props for the custom hook
|
|
161
|
-
*/
|
|
162
|
-
export type UseStackedAreaChartProps = {
|
|
163
|
-
data: StackedAreaDataPoint[];
|
|
164
|
-
categories: StackedAreaCategory[];
|
|
165
|
-
formatDate?: (timestamp: number) => string;
|
|
166
|
-
formatValue?: (value: number) => string;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Return type for the custom hook
|
|
170
|
-
*/
|
|
171
|
-
export type UseStackedAreaChartReturn = {
|
|
172
|
-
/** Validated and processed data */
|
|
173
|
-
processedData: StackedAreaDataPoint[];
|
|
174
|
-
/** Validated categories */
|
|
175
|
-
processedCategories: StackedAreaCategory[];
|
|
176
|
-
/** Minimum timestamp in data */
|
|
177
|
-
minTimestamp: number;
|
|
178
|
-
/** Maximum timestamp in data */
|
|
179
|
-
maxTimestamp: number;
|
|
180
|
-
/** Total value at each timestamp (sum of all categories) */
|
|
181
|
-
maxTotalValue: number;
|
|
182
|
-
/** Default date formatter */
|
|
183
|
-
dateFormatter: (timestamp: number) => string;
|
|
184
|
-
/** Default value formatter */
|
|
185
|
-
valueFormatter: (value: number) => string;
|
|
186
|
-
};
|