@moderneinc/react-charts 1.1.0 → 1.2.0-next.0d3f64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/components/chrono-chart/chrono-chart.component.d.ts +10 -0
  2. package/dist/components/chrono-chart/chrono-chart.types.d.ts +129 -0
  3. package/dist/components/chrono-chart/components/category-table.component.d.ts +13 -0
  4. package/dist/components/chrono-chart/components/category-table.types.d.ts +42 -0
  5. package/dist/components/chrono-chart/utils/data-transformer.d.ts +41 -0
  6. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.component.d.ts +7 -0
  7. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +95 -0
  8. package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +35 -0
  9. package/dist/components/morph-chart/hooks/shared/computations.d.ts +29 -0
  10. package/dist/components/morph-chart/hooks/shared/types.d.ts +24 -0
  11. package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +90 -0
  12. package/dist/components/morph-chart/index.d.ts +2 -0
  13. package/dist/components/morph-chart/morph-chart.component.d.ts +14 -0
  14. package/dist/components/morph-chart/morph-chart.types.d.ts +175 -0
  15. package/dist/components/morph-chart/utils/accordion-generator.d.ts +102 -0
  16. package/dist/components/morph-chart/utils/animation-constants.d.ts +23 -0
  17. package/dist/components/morph-chart/utils/animation-utils.d.ts +44 -0
  18. package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +53 -0
  19. package/dist/components/morph-chart/utils/area-renderer.d.ts +24 -0
  20. package/dist/components/morph-chart/utils/bar-renderer.d.ts +19 -0
  21. package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +291 -0
  22. package/dist/components/morph-chart/utils/morph-interpolator.d.ts +96 -0
  23. package/dist/components/morph-chart/utils/parliament-renderer.d.ts +23 -0
  24. package/dist/components/morph-chart/utils/parliament-seat-extractor.d.ts +33 -0
  25. package/dist/components/morph-chart/utils/position-mapper.d.ts +48 -0
  26. package/dist/components/morph-chart/utils/segment-transformer.d.ts +70 -0
  27. package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +35 -0
  28. package/dist/components/morph-chart/utils/svg-patterns.d.ts +19 -0
  29. package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +25 -0
  30. package/dist/components/parliament-chart/hooks/{useParliamentChart.d.ts → use-parliament-chart.hook.d.ts} +6 -2
  31. package/dist/components/parliament-chart/{ParliamentChart.d.ts → parliament-chart.component.d.ts} +1 -1
  32. package/dist/components/parliament-chart/{ParliamentChart.types.d.ts → parliament-chart.types.d.ts} +6 -1
  33. package/dist/components/parliament-chart/utils/parliament-animation.d.ts +13 -0
  34. package/dist/components/stacked-area-chart/hooks/use-stacked-area-chart.hook.d.ts +6 -0
  35. package/dist/components/stacked-area-chart/stacked-area-chart.component.d.ts +10 -0
  36. package/dist/components/stacked-area-chart/stacked-area-chart.constants.d.ts +115 -0
  37. package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +186 -0
  38. package/dist/components/stacked-area-chart/utils/color.utils.d.ts +4 -0
  39. package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +52 -0
  40. package/dist/components/stacked-area-with-timeline/index.d.ts +4 -0
  41. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.component.d.ts +3 -0
  42. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.types.d.ts +97 -0
  43. package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +54 -0
  44. package/dist/components/timeline-chart/hooks/use-timeline-chart.hook.d.ts +2 -0
  45. package/dist/components/timeline-chart/timeline-chart.component.d.ts +9 -0
  46. package/dist/components/timeline-chart/timeline-chart.types.d.ts +156 -0
  47. package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
  48. package/dist/index.cjs +144 -11
  49. package/dist/index.d.ts +23 -8
  50. package/dist/index.js +31597 -4839
  51. package/dist/theme/{defaultColors.d.ts → default-colors.d.ts} +8 -4
  52. package/dist/theme/timeline-defaults.d.ts +82 -0
  53. package/package.json +37 -14
  54. /package/dist/components/parliament-chart/{ParliamentChart.constants.d.ts → parliament-chart.constants.d.ts} +0 -0
  55. /package/dist/components/parliament-chart/utils/{parliamentArcCalculator.d.ts → parliament-arc-calculator.d.ts} +0 -0
  56. /package/dist/components/parliament-chart/utils/{parliamentChartData.utils.d.ts → parliament-chart-data.utils.d.ts} +0 -0
  57. /package/dist/components/parliament-chart/utils/{parliamentSvgEnhanced.d.ts → parliament-svg-enhanced.d.ts} +0 -0
  58. /package/dist/components/parliament-chart/utils/{parliamentSvgPatterns.d.ts → parliament-svg-patterns.d.ts} +0 -0
  59. /package/dist/components/parliament-chart/utils/{parliamentSvg.d.ts → parliament-svg.d.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { ChronoChartProps } from './chrono-chart.types';
3
+ /**
4
+ * ChronoChart: A dual-mode time-series visualization component.
5
+ *
6
+ * Renders either a parliament diagram (point-in-time) or stacked area chart (historical)
7
+ * with smooth animated transitions between modes. Delegates rendering to MorphChart
8
+ * while managing mode logic, data transformation, and user interactions.
9
+ */
10
+ export declare const ChronoChart: FunctionComponent<ChronoChartProps>;
@@ -0,0 +1,129 @@
1
+ import { TimelineEvent } from '../timeline-chart/timeline-chart.types';
2
+ /**
3
+ * Represents a data category with visual styling and optional parliament-specific mappings.
4
+ */
5
+ export type ChronoCategory = {
6
+ /** Unique identifier for the category */
7
+ id: string;
8
+ /** Display label for the category */
9
+ label: string;
10
+ /** Color hex code (e.g., '#FF5733') */
11
+ color: string;
12
+ /** Optional dash pattern for the stroke (e.g., '5 5' for dashed lines) */
13
+ strokeDasharray?: string;
14
+ /** Parliament-specific configuration for special category rendering */
15
+ parliamentMapping?: {
16
+ /** Whether this category receives special visual treatment in parliament view */
17
+ isSpecialCategory: boolean;
18
+ /** Hatch pattern identifier for special categories */
19
+ hatchPattern?: string;
20
+ };
21
+ };
22
+ /**
23
+ * Complete dataset for the ChronoChart including time series, categories, and metadata.
24
+ */
25
+ export type ChronoData = {
26
+ /** Array of time-series data points, each containing a timestamp and category values */
27
+ timeSeries: Array<{
28
+ /** Unix timestamp or date number */
29
+ timestamp: number;
30
+ /** Map of category IDs to their numeric values at this timestamp */
31
+ values: Record<string, number>;
32
+ }>;
33
+ /** Category definitions with styling and metadata */
34
+ categories: ChronoCategory[];
35
+ /** Aggregate information about the dataset */
36
+ metadata: {
37
+ /** Total count across all categories */
38
+ total: number;
39
+ /** Counts for special categories (optional) */
40
+ specialCounts?: {
41
+ notApplicable: number;
42
+ noLst: number;
43
+ unavailable: number;
44
+ };
45
+ };
46
+ /** Optional timeline events to display alongside the historical view */
47
+ events?: TimelineEvent[];
48
+ };
49
+ /**
50
+ * Props for the ChronoChart component.
51
+ */
52
+ export type ChronoChartProps = {
53
+ /** Complete dataset to visualize */
54
+ data: ChronoData;
55
+ /**
56
+ * Index of the time series data point to display in point-in-time mode.
57
+ * - If set: Chart shows point-in-time view for data at this index
58
+ * - If undefined: Chart shows historical view (default)
59
+ * - If data.timeSeries.length === 1: Automatically shows point-in-time mode
60
+ *
61
+ * Note: Changing selectedIndex does NOT trigger animation. Animation only
62
+ * plays when toggling between point-in-time and historical modes.
63
+ */
64
+ selectedIndex?: number;
65
+ /** Chart title displayed at the top */
66
+ title?: string;
67
+ /** Chart subtitle displayed below the title */
68
+ subtitle?: string;
69
+ /** Whether to show the title/subtitle header section */
70
+ showHeader?: boolean;
71
+ /** Chart width in pixels (default: 900) */
72
+ width?: number;
73
+ /** Chart height in pixels (default: 600) */
74
+ height?: number;
75
+ /** Initial time range for the historical view [startTimestamp, endTimestamp] */
76
+ timeRange?: [number, number];
77
+ /** Callback when the time range changes (via brush or other interactions) */
78
+ onTimeRangeChange?: (range: [number, number]) => void;
79
+ /** Minimum allowed timestamp for time range selection (constrains brush selection) */
80
+ minAllowedTime?: number;
81
+ /** Maximum allowed timestamp for time range selection (constrains brush selection) */
82
+ maxAllowedTime?: number;
83
+ /** Enable brush selection for time range in historical mode */
84
+ enableBrush?: boolean;
85
+ /** Show the legend/category table */
86
+ showLegend?: boolean;
87
+ /** Enable tooltips on hover */
88
+ showTooltip?: boolean;
89
+ /** Show background grid lines */
90
+ showGrid?: boolean;
91
+ /**
92
+ * Color for axis labels (dates on x-axis, values on y-axis).
93
+ * @default undefined (inherits from SVG default, typically black)
94
+ */
95
+ axisLabelColor?: string;
96
+ /**
97
+ * Font size for axis labels in pixels.
98
+ * Increase this value when displaying charts at smaller sizes (e.g., in dashboards).
99
+ * @default 14
100
+ */
101
+ axisLabelSize?: number;
102
+ /** Enable animations when switching between modes */
103
+ enableAnimation?: boolean;
104
+ /** Duration of animations in milliseconds */
105
+ animationDuration?: number;
106
+ /**
107
+ * Disable the timeline in historical mode.
108
+ * By default, the timeline is always shown in historical mode, even when there are no events.
109
+ * Set this to true to hide the timeline.
110
+ * @default false
111
+ */
112
+ disableTimeline?: boolean;
113
+ /** Custom function to format timestamps for display */
114
+ formatDate?: (timestamp: number) => string;
115
+ /** Custom function to format numeric values for display */
116
+ formatValue?: (value: number) => string;
117
+ /** Callback when animation state changes (starting/stopping) */
118
+ onAnimationStateChange?: (isAnimating: boolean) => void;
119
+ /** Callback when the GSAP timeline is initialized */
120
+ onTimelineReady?: (timeline: unknown) => void;
121
+ /** Callback for animation progress updates */
122
+ onAnimationProgress?: (progress: number, stage: string) => void;
123
+ /**
124
+ * Color for brush selection overlay in historical mode.
125
+ * Used for both the selection area and drag handles.
126
+ * @default '#69b3a2'
127
+ */
128
+ brushColor?: string;
129
+ };
@@ -0,0 +1,13 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { CategoryTableProps } from './category-table.types';
3
+ /**
4
+ * CategoryTable displays a legend/data table for ChronoChart categories.
5
+ *
6
+ * The table adapts its columns based on the display mode:
7
+ * - Point-in-time: Shows current count and percentage for each category
8
+ * - Historical: Shows last value, maximum, and minimum across the time series
9
+ *
10
+ * Special categories (N/A, Data Missing, No LST) use hatch patterns instead of
11
+ * solid colors to distinguish them from regular data categories.
12
+ */
13
+ export declare const CategoryTable: FunctionComponent<CategoryTableProps>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Type definitions for the CategoryTable component.
3
+ *
4
+ * The CategoryTable displays a legend/data table showing all categories with their
5
+ * values, percentages, and colors. It supports both point-in-time and historical modes.
6
+ */
7
+ /**
8
+ * Represents a single category row in the table.
9
+ */
10
+ export type CategoryTableItem = {
11
+ /** Unique identifier for the category */
12
+ id: string;
13
+ /** Display label for the category */
14
+ label: string;
15
+ /** Current value: "#" column in point-in-time mode OR "Last" column in historical mode */
16
+ value: number;
17
+ /** Percentage of total (displayed in point-in-time mode only) */
18
+ percentage: number;
19
+ /** Color hex code for the category's visual representation */
20
+ color: string;
21
+ /** Optional tooltip text providing additional context */
22
+ tooltip?: string;
23
+ /** Maximum value across time series (historical mode only) */
24
+ max?: number;
25
+ /** Minimum value across time series (historical mode only) */
26
+ min?: number;
27
+ };
28
+ /**
29
+ * Props for the CategoryTable component.
30
+ */
31
+ export type CategoryTableProps = {
32
+ /** Array of category items to display in the table */
33
+ categories: CategoryTableItem[];
34
+ /** Currently hovered category ID for highlighting, or null if none */
35
+ activeCategory: string | null;
36
+ /** Callback when user hovers over or leaves a category row */
37
+ onCategoryHover: (categoryId: string | null) => void;
38
+ /** Display mode affecting which columns are shown */
39
+ mode: 'point-in-time' | 'historical';
40
+ /** Whether the table is visible (affects opacity/display) */
41
+ visible?: boolean;
42
+ };
@@ -0,0 +1,41 @@
1
+ import { MorphChartCategory, MorphChartDataPoint } from '../../morph-chart/morph-chart.types';
2
+ import { ChronoData } from '../chrono-chart.types';
3
+ import { CategoryTableItem } from '../components/category-table.types';
4
+ /**
5
+ * Extracts the latest values from ChronoData and formats them for display in the category table.
6
+ *
7
+ * In point-in-time mode: Returns the latest value for each category
8
+ * In historical mode: Also includes min/max values across the time series
9
+ *
10
+ * @param data - The complete ChronoData dataset
11
+ * @param mode - Display mode affecting which values are included
12
+ * @returns Array of formatted category items with values, percentages, and metadata
13
+ */
14
+ export declare const extractLatestValues: (data: ChronoData, mode?: "point-in-time" | "historical") => CategoryTableItem[];
15
+ /**
16
+ * Transforms ChronoData format to MorphChart format for visualization.
17
+ *
18
+ * This conversion is necessary because ChronoChart uses its own data structure
19
+ * but delegates rendering to the MorphChart component.
20
+ *
21
+ * @param data - The ChronoData to transform
22
+ * @returns Object containing MorphChart-compatible data points and categories
23
+ * @throws Error if no data points are available
24
+ */
25
+ export declare const transformToMorphChart: (data: ChronoData) => {
26
+ data: MorphChartDataPoint[];
27
+ categories: MorphChartCategory[];
28
+ };
29
+ /**
30
+ * Validates the structure and integrity of ChronoData.
31
+ *
32
+ * Checks for:
33
+ * - Non-empty time series and categories
34
+ * - Required metadata fields
35
+ * - Proper timestamp ordering (ascending)
36
+ * - Category presence in data points
37
+ *
38
+ * @param data - The ChronoData to validate
39
+ * @throws Error with descriptive message if validation fails
40
+ */
41
+ export declare const validateChronoData: (data: ChronoData) => void;
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { D3StackedAreaChartProps } from './d3-stacked-area-chart.types';
3
+ /**
4
+ * D3-based stacked area chart component
5
+ * Built for seamless morphing with parliament chart
6
+ */
7
+ export declare const D3StackedAreaChart: FunctionComponent<D3StackedAreaChartProps>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * D3-based stacked area chart types
3
+ * Built for seamless morphing with parliament chart
4
+ */
5
+ export type D3StackedAreaDataPoint = {
6
+ timestamp: number;
7
+ [category: string]: number;
8
+ };
9
+ export type D3StackedAreaCategory = {
10
+ dataKey: string;
11
+ label: string;
12
+ color: string;
13
+ strokeWidth?: number;
14
+ strokeDasharray?: string;
15
+ fillOpacity?: number;
16
+ };
17
+ export type D3StackedAreaChartProps = {
18
+ /** Array of data points sorted by timestamp */
19
+ data: D3StackedAreaDataPoint[];
20
+ /** Array of category definitions */
21
+ categories: D3StackedAreaCategory[];
22
+ /** Chart title */
23
+ title?: string;
24
+ /** Chart subtitle */
25
+ subtitle?: string;
26
+ /** Show header (title and subtitle) */
27
+ showHeader?: boolean;
28
+ /** Show legend */
29
+ showLegend?: boolean;
30
+ /** Show tooltips on hover */
31
+ showTooltip?: boolean;
32
+ /** Chart dimensions */
33
+ width?: number;
34
+ height?: number;
35
+ /** Margins for axes */
36
+ margin?: {
37
+ top: number;
38
+ right: number;
39
+ bottom: number;
40
+ left: number;
41
+ };
42
+ /** Time range for x-axis */
43
+ timeRange?: [number, number];
44
+ /** Show grid lines */
45
+ showGrid?: boolean;
46
+ /** Show axes (deprecated: use showXAxis and showYAxis instead) */
47
+ showAxes?: boolean;
48
+ /** Show X-axis */
49
+ showXAxis?: boolean;
50
+ /** Show Y-axis */
51
+ showYAxis?: boolean;
52
+ /** Enable animations */
53
+ enableAnimation?: boolean;
54
+ /** Animation duration */
55
+ animationDuration?: number;
56
+ /** Format date for axis */
57
+ formatDate?: (timestamp: number) => string;
58
+ /** Format value for axis */
59
+ formatValue?: (value: number) => string;
60
+ /** Callback when time range changes */
61
+ onTimeRangeChange?: (range: [number, number]) => void;
62
+ /** Enable brush selection */
63
+ enableBrush?: boolean;
64
+ /** Zoom to selection - when true, brush clears after selection and expects chart to zoom via timeRange update */
65
+ zoomToSelection?: boolean;
66
+ /** Markers (vertical lines for events) */
67
+ markers?: Array<{
68
+ timestamp: number;
69
+ label?: string;
70
+ color?: string;
71
+ strokeDasharray?: string;
72
+ }>;
73
+ /** Marker visibility mode: 'hover' shows only nearest marker on hover, 'always' shows all markers */
74
+ markerVisibilityMode?: 'always' | 'hover';
75
+ /**
76
+ * Color for brush selection overlay.
77
+ * Used for both the selection area and drag handles.
78
+ * @default '#69b3a2'
79
+ */
80
+ brushColor?: string;
81
+ /** Mode for morphing animation */
82
+ morphMode?: 'area' | 'parliament' | 'morphing';
83
+ /** Parliament layout data (for morphing) */
84
+ parliamentData?: {
85
+ arcAngle: number;
86
+ radius: number;
87
+ seatPositions: Array<{
88
+ x: number;
89
+ y: number;
90
+ category: string;
91
+ }>;
92
+ };
93
+ /** Morph progress (0 = area, 1 = parliament) */
94
+ morphProgress?: number;
95
+ };
@@ -0,0 +1,35 @@
1
+ import { RefObject } from 'react';
2
+ import { D3StackedAreaCategory, D3StackedAreaDataPoint } from '../d3-stacked-area-chart.types';
3
+ type UseD3StackedAreaProps = {
4
+ containerRef: RefObject<SVGSVGElement>;
5
+ data: D3StackedAreaDataPoint[];
6
+ categories: D3StackedAreaCategory[];
7
+ width: number;
8
+ height: number;
9
+ margin: {
10
+ top: number;
11
+ right: number;
12
+ bottom: number;
13
+ left: number;
14
+ };
15
+ timeRange?: [number, number];
16
+ showGrid?: boolean;
17
+ showXAxis?: boolean;
18
+ showYAxis?: boolean;
19
+ enableBrush?: boolean;
20
+ zoomToSelection?: boolean;
21
+ onTimeRangeChange?: (range: [number, number]) => void;
22
+ formatDate?: (timestamp: number) => string;
23
+ formatValue?: (value: number) => string;
24
+ markers?: Array<{
25
+ timestamp: number;
26
+ label?: string;
27
+ color?: string;
28
+ strokeDasharray?: string;
29
+ }>;
30
+ markerVisibilityMode?: 'always' | 'hover';
31
+ onMarkerHoverChange?: (isHovering: boolean) => void;
32
+ brushColor?: string;
33
+ };
34
+ export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, markers, markerVisibilityMode, onMarkerHoverChange, brushColor }: UseD3StackedAreaProps) => void;
35
+ export {};
@@ -0,0 +1,29 @@
1
+ import { StageDurations } from './types';
2
+ /**
3
+ * Calculate stage durations from total animation duration
4
+ *
5
+ * Splits the total duration into proportional stages for smooth timing:
6
+ * - 20% Seats transform to zig-zag lines (accordion shape)
7
+ * - 7% Lines collapse into vertical bar
8
+ * - 0.3% Pause to appreciate seat-to-bar transition
9
+ * - 22% Bar slide to timeline + axes appear
10
+ * - 22% Other bars grow from baseline
11
+ * - 28.7% Bars morph to curved areas
12
+ *
13
+ * @param totalDuration - Total animation duration in milliseconds
14
+ * @returns Object with duration for each stage in milliseconds
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const durations = calculateStageDurations(2000);
19
+ * // {
20
+ * // seatsToLines: 400, // 20%
21
+ * // seatsToBar: 140, // 7%
22
+ * // crossFadePause: 6, // 0.3%
23
+ * // barSlideToTimeline: 440, // 22%
24
+ * // axesAndBarsGrow: 440, // 22%
25
+ * // barsToArea: 574 // 28.7%
26
+ * // }
27
+ * ```
28
+ */
29
+ export declare function calculateStageDurations(totalDuration: number): StageDurations;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared types for morph animation stages
3
+ *
4
+ * These types are used across multiple animation stages for consistent
5
+ * timing and duration calculations.
6
+ */
7
+ /**
8
+ * Animation stage durations for parliament → area morph (5 stages)
9
+ * Calculated as fractions of total duration for smooth timing
10
+ */
11
+ export type StageDurations = {
12
+ /** Frame 0→1: Seats transform to zig-zag lines forming accordion (20% of total) */
13
+ seatsToLines: number;
14
+ /** Frame 1→2: Lines collapse into vertical bar (15% of total) */
15
+ seatsToBar: number;
16
+ /** Pause after cross-fade to appreciate seat-to-bar transition (3% of total) */
17
+ crossFadePause: number;
18
+ /** Frame 2→3: Bar slides to timeline + axes/grid appear (22% of total) */
19
+ barSlideToTimeline: number;
20
+ /** Frame 3→4: Other bars grow from baseline (22% of total) */
21
+ axesAndBarsGrow: number;
22
+ /** Frame 4→5: Bars morph to curved area (18% of total) */
23
+ barsToArea: number;
24
+ };
@@ -0,0 +1,90 @@
1
+ import { RefObject } from 'react';
2
+ import { HoveredData, MorphChartCategory, MorphChartDataPoint, MorphMode } from '../morph-chart.types';
3
+ type UseMorphChartProps = {
4
+ containerRef: RefObject<SVGSVGElement>;
5
+ data: MorphChartDataPoint[];
6
+ categories: MorphChartCategory[];
7
+ mode: 'parliament' | 'stacked-area';
8
+ width: number;
9
+ height: number;
10
+ margin: {
11
+ top: number;
12
+ right: number;
13
+ bottom: number;
14
+ left: number;
15
+ };
16
+ timeRange?: [number, number];
17
+ showGrid?: boolean;
18
+ showAxes?: boolean;
19
+ axisLabelColor?: string;
20
+ axisLabelSize?: number;
21
+ formatDate?: (timestamp: number) => string;
22
+ formatValue?: (value: number) => string;
23
+ markers?: Array<{
24
+ timestamp: number;
25
+ label?: string;
26
+ color?: string;
27
+ }>;
28
+ arcAngle?: number;
29
+ parliamentRadius?: number;
30
+ seatSize?: number;
31
+ animationDuration?: number;
32
+ onMorphComplete?: () => void;
33
+ onAnimationStateChange?: (isAnimating: boolean) => void;
34
+ onTimelineReady?: (timeline: gsap.core.Timeline) => void;
35
+ onAnimationProgress?: (progress: number, stage: string) => void;
36
+ onHoveredDataChange?: (data: HoveredData) => void;
37
+ hoveredCategory?: string | null;
38
+ maxSeats?: number;
39
+ parliamentTimestamp?: number;
40
+ enableBrush?: boolean;
41
+ onTimeRangeChange?: (range: [number, number]) => void;
42
+ minAllowedTime?: number;
43
+ maxAllowedTime?: number;
44
+ showScaleIndicator?: boolean;
45
+ reposPerSeat?: number;
46
+ timelineEvents?: Array<{
47
+ timestamp: number;
48
+ eventName: string;
49
+ color?: string;
50
+ }>;
51
+ showTimeline?: boolean;
52
+ timelineHeight?: number;
53
+ timelineOffset?: number;
54
+ brushColor?: string;
55
+ };
56
+ export declare const useMorphChart: ({ containerRef, data, categories, mode, width, height, margin, timeRange, showGrid, showAxes, axisLabelColor, axisLabelSize, formatDate, formatValue, markers, arcAngle, parliamentRadius, seatSize, animationDuration, onMorphComplete, onAnimationStateChange, onTimelineReady, onAnimationProgress, onHoveredDataChange, hoveredCategory: externalHoveredCategory, maxSeats, parliamentTimestamp, enableBrush, onTimeRangeChange, minAllowedTime: minAllowedTimeConstraint, maxAllowedTime: maxAllowedTimeConstraint, showScaleIndicator, reposPerSeat, timelineEvents, showTimeline, timelineHeight, timelineOffset, brushColor }: UseMorphChartProps) => {
57
+ isMorphing: boolean;
58
+ currentMode: MorphMode;
59
+ hoveredCategory: string | null;
60
+ scaleIndicatorOpacity: number;
61
+ visibleMarkers: {
62
+ timestamp: number;
63
+ label?: string;
64
+ color?: string;
65
+ x: number;
66
+ }[];
67
+ hoveredMarker: {
68
+ timestamp: number;
69
+ label?: string;
70
+ color?: string;
71
+ x: number;
72
+ } | null;
73
+ setHoveredMarker: import('react').Dispatch<import('react').SetStateAction<{
74
+ timestamp: number;
75
+ label?: string;
76
+ color?: string;
77
+ x: number;
78
+ } | null>>;
79
+ hoveredTimelineEvent: {
80
+ timestamp: number;
81
+ eventName: string;
82
+ x: number;
83
+ } | null;
84
+ setHoveredTimelineEvent: import('react').Dispatch<import('react').SetStateAction<{
85
+ timestamp: number;
86
+ eventName: string;
87
+ x: number;
88
+ } | null>>;
89
+ };
90
+ export {};
@@ -0,0 +1,2 @@
1
+ export { MorphChart } from './morph-chart.component';
2
+ export type { AreaLayout, AreaPoint, MorphChartCategory, MorphChartDataPoint, MorphChartProps, MorphMode, ParliamentLayout, SeatPosition } from './morph-chart.types';
@@ -0,0 +1,14 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { MorphChartProps } from './morph-chart.types';
3
+ /**
4
+ * MorphChart - Seamlessly morphs between parliament and stacked area visualizations
5
+ *
6
+ * This component uses D3 to create smooth transitions between a parliament chart
7
+ * (point-in-time view) and a stacked area chart (historical view).
8
+ *
9
+ * Key insight: The parliament chart represents the rightmost edge (latest timestamp)
10
+ * of the stacked area chart. During morphing:
11
+ * - Parliament → Stacked Area: Seats slide to the right edge, then areas expand leftward
12
+ * - Stacked Area → Parliament: Areas collapse to the right edge, then seats expand to parliament layout
13
+ */
14
+ export declare const MorphChart: FunctionComponent<MorphChartProps>;