@moderneinc/react-charts 1.2.0-next.2d0a72 → 1.2.0-next.2f2ee2
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 +3 -0
- package/dist/components/{chrono-perspective-chart/chrono-perspective-chart.types.d.ts → chrono-chart/chrono-chart.types.d.ts} +9 -13
- package/dist/components/{chrono-perspective-chart → chrono-chart}/components/category-table.types.d.ts +4 -0
- package/dist/components/chrono-chart/utils/data-transformer.d.ts +9 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +21 -1
- package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +7 -2
- package/dist/components/morph-chart/hooks/shared/computations.d.ts +5 -3
- package/dist/components/morph-chart/hooks/shared/types.d.ts +3 -1
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +42 -1
- package/dist/components/morph-chart/morph-chart.types.d.ts +12 -0
- package/dist/components/morph-chart/utils/area-renderer.d.ts +1 -0
- package/dist/components/morph-chart/utils/bar-renderer.d.ts +0 -9
- package/dist/components/morph-chart/utils/parliament-renderer.d.ts +2 -0
- package/dist/components/timeline-chart/timeline-chart.types.d.ts +7 -0
- package/dist/index.cjs +79 -73
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16968 -16095
- package/package.json +1 -1
- package/dist/components/chrono-perspective-chart/chrono-perspective-chart.component.d.ts +0 -3
- package/dist/components/chrono-perspective-chart/utils/data-transformer.d.ts +0 -9
- /package/dist/components/{chrono-perspective-chart → chrono-chart}/components/category-table.component.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TimelineEvent } from '../timeline-chart/timeline-chart.types';
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
2
|
+
export type ChronoMode = 'point-in-time' | 'historical';
|
|
3
|
+
export type ChronoCategory = {
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|
|
6
6
|
color: string;
|
|
@@ -9,14 +9,14 @@ export type ChronoPerspectiveCategory = {
|
|
|
9
9
|
hatchPattern?: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export type
|
|
12
|
+
export type ChronoData = {
|
|
13
13
|
timeSeries: Array<{
|
|
14
14
|
timestamp: number;
|
|
15
15
|
values: Record<string, number>;
|
|
16
16
|
}>;
|
|
17
|
-
categories:
|
|
17
|
+
categories: ChronoCategory[];
|
|
18
18
|
metadata: {
|
|
19
|
-
|
|
19
|
+
total: number;
|
|
20
20
|
specialCounts?: {
|
|
21
21
|
notApplicable: number;
|
|
22
22
|
noLst: number;
|
|
@@ -25,17 +25,12 @@ export type ChronoPerspectiveData = {
|
|
|
25
25
|
};
|
|
26
26
|
events?: TimelineEvent[];
|
|
27
27
|
};
|
|
28
|
-
export type
|
|
29
|
-
data:
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated Use selectedIndex instead. Will be removed in next major version.
|
|
32
|
-
* Mode prop kept for backward compatibility only.
|
|
33
|
-
*/
|
|
34
|
-
mode?: ChronoPerspectiveMode;
|
|
28
|
+
export type ChronoChartProps = {
|
|
29
|
+
data: ChronoData;
|
|
35
30
|
/**
|
|
36
31
|
* Index of the time series data point to display in point-in-time mode.
|
|
37
32
|
* - If set: Chart shows point-in-time view for data at this index
|
|
38
|
-
* - If undefined: Chart shows historical view
|
|
33
|
+
* - If undefined: Chart shows historical view (default)
|
|
39
34
|
* - If data.timeSeries.length === 1: Automatically shows point-in-time mode
|
|
40
35
|
*
|
|
41
36
|
* Note: Changing selectedIndex does NOT trigger animation. Animation only
|
|
@@ -45,6 +40,7 @@ export type ChronoPerspectiveChartProps = {
|
|
|
45
40
|
title?: string;
|
|
46
41
|
subtitle?: string;
|
|
47
42
|
showHeader?: boolean;
|
|
43
|
+
width?: number;
|
|
48
44
|
height?: number;
|
|
49
45
|
timeRange?: [number, number];
|
|
50
46
|
onTimeRangeChange?: (range: [number, number]) => void;
|
|
@@ -5,9 +5,13 @@ export type CategoryTableItem = {
|
|
|
5
5
|
percentage: number;
|
|
6
6
|
color: string;
|
|
7
7
|
tooltip?: string;
|
|
8
|
+
max?: number;
|
|
9
|
+
min?: number;
|
|
8
10
|
};
|
|
9
11
|
export type CategoryTableProps = {
|
|
10
12
|
categories: CategoryTableItem[];
|
|
11
13
|
activeCategory: string | null;
|
|
12
14
|
onCategoryHover: (categoryId: string | null) => void;
|
|
15
|
+
mode: 'point-in-time' | 'historical';
|
|
16
|
+
visible?: boolean;
|
|
13
17
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export declare const extractLatestValues: (data: ChronoData, mode?: "point-in-time" | "historical") => CategoryTableItem[];
|
|
5
|
+
export declare const transformToMorphChart: (data: ChronoData) => {
|
|
6
|
+
data: MorphChartDataPoint[];
|
|
7
|
+
categories: MorphChartCategory[];
|
|
8
|
+
};
|
|
9
|
+
export declare const validateChronoData: (data: ChronoData) => void;
|
|
@@ -11,6 +11,7 @@ export type D3StackedAreaCategory = {
|
|
|
11
11
|
label: string;
|
|
12
12
|
color: string;
|
|
13
13
|
strokeWidth?: number;
|
|
14
|
+
strokeDasharray?: string;
|
|
14
15
|
fillOpacity?: number;
|
|
15
16
|
};
|
|
16
17
|
export type D3StackedAreaChartProps = {
|
|
@@ -18,6 +19,16 @@ export type D3StackedAreaChartProps = {
|
|
|
18
19
|
data: D3StackedAreaDataPoint[];
|
|
19
20
|
/** Array of category definitions */
|
|
20
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;
|
|
21
32
|
/** Chart dimensions */
|
|
22
33
|
width?: number;
|
|
23
34
|
height?: number;
|
|
@@ -32,8 +43,12 @@ export type D3StackedAreaChartProps = {
|
|
|
32
43
|
timeRange?: [number, number];
|
|
33
44
|
/** Show grid lines */
|
|
34
45
|
showGrid?: boolean;
|
|
35
|
-
/** Show axes */
|
|
46
|
+
/** Show axes (deprecated: use showXAxis and showYAxis instead) */
|
|
36
47
|
showAxes?: boolean;
|
|
48
|
+
/** Show X-axis */
|
|
49
|
+
showXAxis?: boolean;
|
|
50
|
+
/** Show Y-axis */
|
|
51
|
+
showYAxis?: boolean;
|
|
37
52
|
/** Enable animations */
|
|
38
53
|
enableAnimation?: boolean;
|
|
39
54
|
/** Animation duration */
|
|
@@ -46,12 +61,17 @@ export type D3StackedAreaChartProps = {
|
|
|
46
61
|
onTimeRangeChange?: (range: [number, number]) => void;
|
|
47
62
|
/** Enable brush selection */
|
|
48
63
|
enableBrush?: boolean;
|
|
64
|
+
/** Zoom to selection - when true, brush clears after selection and expects chart to zoom via timeRange update */
|
|
65
|
+
zoomToSelection?: boolean;
|
|
49
66
|
/** Markers (vertical lines for events) */
|
|
50
67
|
markers?: Array<{
|
|
51
68
|
timestamp: number;
|
|
52
69
|
label?: string;
|
|
53
70
|
color?: string;
|
|
71
|
+
strokeDasharray?: string;
|
|
54
72
|
}>;
|
|
73
|
+
/** Marker visibility mode: 'hover' shows only nearest marker on hover, 'always' shows all markers */
|
|
74
|
+
markerVisibilityMode?: 'always' | 'hover';
|
|
55
75
|
/** Mode for morphing animation */
|
|
56
76
|
morphMode?: 'area' | 'parliament' | 'morphing';
|
|
57
77
|
/** Parliament layout data (for morphing) */
|
|
@@ -14,8 +14,10 @@ type UseD3StackedAreaProps = {
|
|
|
14
14
|
};
|
|
15
15
|
timeRange?: [number, number];
|
|
16
16
|
showGrid?: boolean;
|
|
17
|
-
|
|
17
|
+
showXAxis?: boolean;
|
|
18
|
+
showYAxis?: boolean;
|
|
18
19
|
enableBrush?: boolean;
|
|
20
|
+
zoomToSelection?: boolean;
|
|
19
21
|
onTimeRangeChange?: (range: [number, number]) => void;
|
|
20
22
|
formatDate?: (timestamp: number) => string;
|
|
21
23
|
formatValue?: (value: number) => string;
|
|
@@ -23,7 +25,10 @@ type UseD3StackedAreaProps = {
|
|
|
23
25
|
timestamp: number;
|
|
24
26
|
label?: string;
|
|
25
27
|
color?: string;
|
|
28
|
+
strokeDasharray?: string;
|
|
26
29
|
}>;
|
|
30
|
+
markerVisibilityMode?: 'always' | 'hover';
|
|
31
|
+
onMarkerHoverChange?: (isHovering: boolean) => void;
|
|
27
32
|
};
|
|
28
|
-
export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid,
|
|
33
|
+
export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, markers, markerVisibilityMode, onMarkerHoverChange }: UseD3StackedAreaProps) => void;
|
|
29
34
|
export {};
|
|
@@ -3,7 +3,8 @@ import { StageDurations } from './types';
|
|
|
3
3
|
* Calculate stage durations from total animation duration
|
|
4
4
|
*
|
|
5
5
|
* Splits the total duration into proportional stages for smooth timing:
|
|
6
|
-
* -
|
|
6
|
+
* - 27% Seats to bar transformation
|
|
7
|
+
* - 3% Pause to appreciate seat-to-bar transition
|
|
7
8
|
* - 25% Bar slide to timeline + axes appear
|
|
8
9
|
* - 25% Other bars grow from baseline
|
|
9
10
|
* - 20% Bars morph to curved areas
|
|
@@ -15,9 +16,10 @@ import { StageDurations } from './types';
|
|
|
15
16
|
* ```ts
|
|
16
17
|
* const durations = calculateStageDurations(2000);
|
|
17
18
|
* // {
|
|
18
|
-
* // seatsToBar:
|
|
19
|
+
* // seatsToBar: 540, // 27%
|
|
20
|
+
* // crossFadePause: 60, // 3%
|
|
19
21
|
* // barSlideToTimeline: 500, // 25%
|
|
20
|
-
* // axesAndBarsGrow: 500,
|
|
22
|
+
* // axesAndBarsGrow: 500, // 25%
|
|
21
23
|
* // barsToArea: 400 // 20%
|
|
22
24
|
* // }
|
|
23
25
|
* ```
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
* Calculated as fractions of total duration for smooth timing
|
|
10
10
|
*/
|
|
11
11
|
export type StageDurations = {
|
|
12
|
-
/** Frame 1→2: Seats directly transform to vertical bar (
|
|
12
|
+
/** Frame 1→2: Seats directly transform to vertical bar (27% of total) */
|
|
13
13
|
seatsToBar: number;
|
|
14
|
+
/** Pause after cross-fade to appreciate seat-to-bar transition (3% of total) */
|
|
15
|
+
crossFadePause: number;
|
|
14
16
|
/** Frame 2→3: Bar slides to timeline + axes/grid appear (25% of total) */
|
|
15
17
|
barSlideToTimeline: number;
|
|
16
18
|
/** Frame 3→4: Other bars grow from baseline (25% of total) */
|
|
@@ -35,10 +35,51 @@ type UseMorphChartProps = {
|
|
|
35
35
|
hoveredCategory?: string | null;
|
|
36
36
|
maxSeats?: number;
|
|
37
37
|
parliamentTimestamp?: number;
|
|
38
|
+
enableBrush?: boolean;
|
|
39
|
+
onTimeRangeChange?: (range: [number, number]) => void;
|
|
40
|
+
showScaleIndicator?: boolean;
|
|
41
|
+
reposPerSeat?: number;
|
|
42
|
+
timelineEvents?: Array<{
|
|
43
|
+
timestamp: number;
|
|
44
|
+
eventName: string;
|
|
45
|
+
color?: string;
|
|
46
|
+
}>;
|
|
47
|
+
showTimeline?: boolean;
|
|
48
|
+
timelineHeight?: number;
|
|
49
|
+
timelineOffset?: number;
|
|
38
50
|
};
|
|
39
|
-
export declare const useMorphChart: ({ containerRef, data, categories, mode, width, height, margin, timeRange, showGrid, showAxes, formatDate, formatValue, markers
|
|
51
|
+
export declare const useMorphChart: ({ containerRef, data, categories, mode, width, height, margin, timeRange, showGrid, showAxes, formatDate, formatValue, markers, arcAngle, parliamentRadius, seatSize, animationDuration, onMorphComplete, onAnimationStateChange, onTimelineReady, onAnimationProgress, onHoveredDataChange, hoveredCategory: externalHoveredCategory, maxSeats, parliamentTimestamp, enableBrush, onTimeRangeChange, showScaleIndicator, reposPerSeat, timelineEvents, showTimeline, timelineHeight, timelineOffset }: UseMorphChartProps) => {
|
|
40
52
|
isMorphing: boolean;
|
|
41
53
|
currentMode: MorphMode;
|
|
42
54
|
hoveredCategory: string | null;
|
|
55
|
+
scaleIndicatorOpacity: number;
|
|
56
|
+
visibleMarkers: {
|
|
57
|
+
timestamp: number;
|
|
58
|
+
label?: string;
|
|
59
|
+
color?: string;
|
|
60
|
+
x: number;
|
|
61
|
+
}[];
|
|
62
|
+
hoveredMarker: {
|
|
63
|
+
timestamp: number;
|
|
64
|
+
label?: string;
|
|
65
|
+
color?: string;
|
|
66
|
+
x: number;
|
|
67
|
+
} | null;
|
|
68
|
+
setHoveredMarker: import('react').Dispatch<import('react').SetStateAction<{
|
|
69
|
+
timestamp: number;
|
|
70
|
+
label?: string;
|
|
71
|
+
color?: string;
|
|
72
|
+
x: number;
|
|
73
|
+
} | null>>;
|
|
74
|
+
hoveredTimelineEvent: {
|
|
75
|
+
timestamp: number;
|
|
76
|
+
eventName: string;
|
|
77
|
+
x: number;
|
|
78
|
+
} | null;
|
|
79
|
+
setHoveredTimelineEvent: import('react').Dispatch<import('react').SetStateAction<{
|
|
80
|
+
timestamp: number;
|
|
81
|
+
eventName: string;
|
|
82
|
+
x: number;
|
|
83
|
+
} | null>>;
|
|
43
84
|
};
|
|
44
85
|
export {};
|
|
@@ -94,6 +94,18 @@ export type MorphChartProps = {
|
|
|
94
94
|
* If not provided, defaults to the rightmost (most recent) timestamp.
|
|
95
95
|
*/
|
|
96
96
|
parliamentTimestamp?: number;
|
|
97
|
+
/** Timeline events to display below the x-axis (area mode only) */
|
|
98
|
+
timelineEvents?: Array<{
|
|
99
|
+
timestamp: number;
|
|
100
|
+
eventName: string;
|
|
101
|
+
color?: string;
|
|
102
|
+
}>;
|
|
103
|
+
/** Show timeline track (default: false) */
|
|
104
|
+
showTimeline?: boolean;
|
|
105
|
+
/** Timeline track height in pixels (default: 40) */
|
|
106
|
+
timelineHeight?: number;
|
|
107
|
+
/** Space between x-axis and timeline in pixels (default: 35) */
|
|
108
|
+
timelineOffset?: number;
|
|
97
109
|
};
|
|
98
110
|
/**
|
|
99
111
|
* Seat position in parliament layout
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
2
|
-
import { Selection } from 'd3-selection';
|
|
3
1
|
import { MorphChartCategory } from '../morph-chart.types';
|
|
4
2
|
export type StackedBarSegment = {
|
|
5
3
|
timestamp: number;
|
|
@@ -11,13 +9,6 @@ export type StackedBarSegment = {
|
|
|
11
9
|
color: string;
|
|
12
10
|
isSpecialCategory: boolean;
|
|
13
11
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Render stacked bars for all timestamps
|
|
16
|
-
* Creates rect elements that can be animated in height and width
|
|
17
|
-
* Bars are rendered as a Riemann sum (touching each other with no gaps)
|
|
18
|
-
*/
|
|
19
|
-
export declare function renderStackedBars(svg: Selection<SVGGElement, unknown, null, undefined>, stackedData: StackedBarSegment[], xScale: ScaleTime<number, number>, yScale: ScaleLinear<number, number>, _unusedBarWidth: number, // Keep for API compatibility but calculate dynamically
|
|
20
|
-
_instanceId: string): void;
|
|
21
12
|
/**
|
|
22
13
|
* Generate stacked bar data from time series
|
|
23
14
|
* Converts raw data into stacked segments for bar rendering
|
|
@@ -42,6 +42,13 @@ export type TimelineChartProps = {
|
|
|
42
42
|
selectedRange?: TimelineSelection;
|
|
43
43
|
/** Height of the timeline container in pixels (default: 32) */
|
|
44
44
|
height?: number;
|
|
45
|
+
/** Margin around the timeline drawable area (for alignment with other charts) */
|
|
46
|
+
margin?: {
|
|
47
|
+
top: number;
|
|
48
|
+
right: number;
|
|
49
|
+
bottom: number;
|
|
50
|
+
left: number;
|
|
51
|
+
};
|
|
45
52
|
/** Custom date formatter */
|
|
46
53
|
formatDate?: (timestamp: number) => string;
|
|
47
54
|
/** Custom month/year formatter */
|