@moderneinc/react-charts 1.1.0 → 1.2.0-next.c015c0
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/parliament-chart/hooks/{useParliamentChart.d.ts → use-parliament-chart.hook.d.ts} +1 -1
- package/dist/components/parliament-chart/{ParliamentChart.d.ts → parliament-chart.component.d.ts} +1 -1
- package/dist/components/parliament-chart/{ParliamentChart.types.d.ts → parliament-chart.types.d.ts} +1 -1
- package/dist/components/stacked-area-chart/hooks/use-stacked-area-chart.hook.d.ts +6 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.component.d.ts +10 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.constants.d.ts +115 -0
- package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +163 -0
- package/dist/components/stacked-area-chart/utils/color.utils.d.ts +9 -0
- package/dist/components/timeline-chart/hooks/use-timeline-chart.hook.d.ts +2 -0
- package/dist/components/timeline-chart/timeline-chart.component.d.ts +9 -0
- package/dist/components/timeline-chart/timeline-chart.types.d.ts +112 -0
- package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
- package/dist/index.cjs +106 -11
- package/dist/index.d.ts +14 -8
- package/dist/index.js +21301 -3005
- package/dist/theme/{defaultColors.d.ts → default-colors.d.ts} +8 -0
- package/dist/theme/timeline-defaults.d.ts +50 -0
- package/package.json +8 -5
- /package/dist/components/parliament-chart/{ParliamentChart.constants.d.ts → parliament-chart.constants.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentArcCalculator.d.ts → parliament-arc-calculator.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentChartData.utils.d.ts → parliament-chart-data.utils.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvgEnhanced.d.ts → parliament-svg-enhanced.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvgPatterns.d.ts → parliament-svg-patterns.d.ts} +0 -0
- /package/dist/components/parliament-chart/utils/{parliamentSvg.d.ts → parliament-svg.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { ChartConfig, HoveredData, ProcessedDataItem } from '../
|
|
2
|
+
import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
|
|
3
3
|
type UseParliamentChartProps = {
|
|
4
4
|
containerRef: RefObject<HTMLDivElement>;
|
|
5
5
|
processedData: ProcessedDataItem[];
|
package/dist/components/parliament-chart/{ParliamentChart.d.ts → parliament-chart.component.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
|
-
import { ParliamentChartProps } from './
|
|
2
|
+
import { ParliamentChartProps } from './parliament-chart.types';
|
|
3
3
|
/**
|
|
4
4
|
* Renders an interactive parliament-style chart visualization for repository statistics.
|
|
5
5
|
* Displays repository counts as seats in a semi-circular or arc layout, with scaling
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default colors for stacked area chart categories
|
|
3
|
+
* These colors are designed to work well together and provide good contrast
|
|
4
|
+
* Migration colors match the exact gradient used in ParliamentChart for visual consistency
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_STACKED_AREA_COLORS: {
|
|
7
|
+
readonly critical: "#dc3545";
|
|
8
|
+
readonly high: "#fd7e14";
|
|
9
|
+
readonly medium: "#ffc107";
|
|
10
|
+
readonly low: "#17a2b8";
|
|
11
|
+
readonly complete: "#40c048";
|
|
12
|
+
readonly inProgress: "#007bff";
|
|
13
|
+
readonly farthest: string | undefined;
|
|
14
|
+
readonly far: string | undefined;
|
|
15
|
+
readonly close: string | undefined;
|
|
16
|
+
readonly closest: string | undefined;
|
|
17
|
+
readonly completed: string | undefined;
|
|
18
|
+
readonly primary: "#007bff";
|
|
19
|
+
readonly secondary: "#6c757d";
|
|
20
|
+
readonly success: "#40c048";
|
|
21
|
+
readonly danger: "#dc3545";
|
|
22
|
+
readonly warning: "#ffc107";
|
|
23
|
+
readonly info: "#17a2b8";
|
|
24
|
+
readonly light: "#EDEFEF";
|
|
25
|
+
readonly dark: "#343a40";
|
|
26
|
+
};
|
|
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
|
+
/**
|
|
88
|
+
* Predefined color palettes for common use cases
|
|
89
|
+
*/
|
|
90
|
+
export declare const STACKED_AREA_PALETTES: {
|
|
91
|
+
readonly migration: string[];
|
|
92
|
+
readonly severity: readonly ["#dc3545", "#fd7e14", "#ffc107", "#17a2b8", "#17a2b8"];
|
|
93
|
+
readonly status: readonly ["#dc3545", "#ffc107", "#40c048"];
|
|
94
|
+
readonly extended: readonly ["#e74c3c", "#e67e22", "#f39c12", "#2ecc71", "#3498db", "#9b59b6", "#1abc9c", "#95a5a6"];
|
|
95
|
+
readonly colorblindSafe: readonly ["#0173B2", "#DE8F05", "#029E73", "#CC78BC", "#CA9161", "#FBAFE4", "#949494", "#ECE133"];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Category label constants for common use cases
|
|
99
|
+
* These match the categories used in ParliamentChart for transition compatibility
|
|
100
|
+
*/
|
|
101
|
+
export declare const CATEGORY_LABELS: {
|
|
102
|
+
readonly FARTHEST: "Farthest";
|
|
103
|
+
readonly FAR: "Far";
|
|
104
|
+
readonly CLOSE: "Close";
|
|
105
|
+
readonly CLOSEST: "Closest";
|
|
106
|
+
readonly COMPLETE: "Complete";
|
|
107
|
+
readonly CRITICAL: "Critical";
|
|
108
|
+
readonly HIGH: "High";
|
|
109
|
+
readonly MEDIUM: "Medium";
|
|
110
|
+
readonly LOW: "Low";
|
|
111
|
+
readonly INFO: "Info";
|
|
112
|
+
readonly NOT_APPLICABLE: "N/A";
|
|
113
|
+
readonly NO_LST: "No LST";
|
|
114
|
+
readonly DATA_MISSING: "Data Missing";
|
|
115
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
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
|
+
/**
|
|
137
|
+
* Props for the custom hook
|
|
138
|
+
*/
|
|
139
|
+
export type UseStackedAreaChartProps = {
|
|
140
|
+
data: StackedAreaDataPoint[];
|
|
141
|
+
categories: StackedAreaCategory[];
|
|
142
|
+
formatDate?: (timestamp: number) => string;
|
|
143
|
+
formatValue?: (value: number) => string;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Return type for the custom hook
|
|
147
|
+
*/
|
|
148
|
+
export type UseStackedAreaChartReturn = {
|
|
149
|
+
/** Validated and processed data */
|
|
150
|
+
processedData: StackedAreaDataPoint[];
|
|
151
|
+
/** Validated categories */
|
|
152
|
+
processedCategories: StackedAreaCategory[];
|
|
153
|
+
/** Minimum timestamp in data */
|
|
154
|
+
minTimestamp: number;
|
|
155
|
+
/** Maximum timestamp in data */
|
|
156
|
+
maxTimestamp: number;
|
|
157
|
+
/** Total value at each timestamp (sum of all categories) */
|
|
158
|
+
maxTotalValue: number;
|
|
159
|
+
/** Default date formatter */
|
|
160
|
+
dateFormatter: (timestamp: number) => string;
|
|
161
|
+
/** Default value formatter */
|
|
162
|
+
valueFormatter: (value: number) => string;
|
|
163
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps category index to a color from the measure gradient.
|
|
3
|
+
* Mirrors ParliamentChart logic - first category gets worst color (red), last gets best (green).
|
|
4
|
+
*/
|
|
5
|
+
export declare function getMeasureGradientColor(index: number, totalCategories: number): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generates gradient colors for categories, ordered from worst (red) to best (green).
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateMeasureGradient(count: number): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { UseTimelineChartProps, UseTimelineChartReturn } from '../timeline-chart.types';
|
|
2
|
+
export declare const useTimelineChart: ({ events, selectedRange, onSelectionChange, enableZoom, zoomToSelection, visibleRange, onVisibleRangeChange }: UseTimelineChartProps) => UseTimelineChartReturn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { TimelineChartProps } from './timeline-chart.types';
|
|
3
|
+
/**
|
|
4
|
+
* TimelineChart component - Interactive timeline with drag selection and zoom
|
|
5
|
+
*
|
|
6
|
+
* Displays events on a timeline with interactive selection capabilities.
|
|
7
|
+
* Users can click and drag to select date ranges, and use mouse wheel to zoom.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TimelineChart: FunctionComponent<TimelineChartProps>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BoxProps, StackProps, TypographyProps } from '@mui/material';
|
|
2
|
+
export type TimelineEvent = {
|
|
3
|
+
date: Date;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
eventName: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
export type TimelineSelection = {
|
|
9
|
+
start: number | null;
|
|
10
|
+
end: number | null;
|
|
11
|
+
};
|
|
12
|
+
export type TimelineChartSlotProps = {
|
|
13
|
+
/** Props for the header container (Stack) */
|
|
14
|
+
header?: StackProps;
|
|
15
|
+
/** Props for the title Typography component */
|
|
16
|
+
title?: TypographyProps;
|
|
17
|
+
/** Props for the instructions Typography component */
|
|
18
|
+
instructions?: TypographyProps;
|
|
19
|
+
/** Props for the month labels container (Stack) */
|
|
20
|
+
monthLabelsContainer?: StackProps;
|
|
21
|
+
/** Props for individual month label Typography components */
|
|
22
|
+
monthLabel?: TypographyProps;
|
|
23
|
+
/** Props for the timeline container (Box) */
|
|
24
|
+
timeline?: BoxProps;
|
|
25
|
+
/** Props for individual event markers (Box) */
|
|
26
|
+
event?: BoxProps;
|
|
27
|
+
/** Props for the selection highlight overlay (Box) */
|
|
28
|
+
selection?: BoxProps;
|
|
29
|
+
/** Props for the hover tooltip container (Box) */
|
|
30
|
+
tooltip?: BoxProps;
|
|
31
|
+
/** Props for the tooltip event name Typography component */
|
|
32
|
+
tooltipEventName?: TypographyProps;
|
|
33
|
+
/** Props for the tooltip date Typography component */
|
|
34
|
+
tooltipDate?: TypographyProps;
|
|
35
|
+
};
|
|
36
|
+
export type TimelineChartProps = {
|
|
37
|
+
/** Array of events to display on the timeline (must be sorted by timestamp) */
|
|
38
|
+
events: TimelineEvent[];
|
|
39
|
+
/** Callback when selection changes */
|
|
40
|
+
onSelectionChange?: (selection: TimelineSelection) => void;
|
|
41
|
+
/** Controlled selection state (optional) */
|
|
42
|
+
selectedRange?: TimelineSelection;
|
|
43
|
+
/** Height of the timeline container in pixels (default: 32) */
|
|
44
|
+
height?: number;
|
|
45
|
+
/** Custom date formatter */
|
|
46
|
+
formatDate?: (timestamp: number) => string;
|
|
47
|
+
/** Custom month/year formatter */
|
|
48
|
+
formatMonthYear?: (timestamp: number) => string;
|
|
49
|
+
/** Show month labels at top */
|
|
50
|
+
showMonthLabels?: boolean;
|
|
51
|
+
/** Number of month labels to display (default: 6) */
|
|
52
|
+
monthLabelCount?: number;
|
|
53
|
+
/** Enable zoom with mouse wheel */
|
|
54
|
+
enableZoom?: boolean;
|
|
55
|
+
/** Show header title and instructions (default: true) */
|
|
56
|
+
showHeader?: boolean;
|
|
57
|
+
/** Custom title for the header */
|
|
58
|
+
title?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Zoom to selection mode - When enabled, dragging to select a range
|
|
61
|
+
* will automatically rescale the timeline to show only that range.
|
|
62
|
+
* Selection highlight only shows during drag.
|
|
63
|
+
*/
|
|
64
|
+
zoomToSelection?: boolean;
|
|
65
|
+
/** Callback when the visible range changes (for zoom to selection mode) */
|
|
66
|
+
onVisibleRangeChange?: (range: TimelineSelection) => void;
|
|
67
|
+
/** Controlled visible range (for zoom to selection mode) */
|
|
68
|
+
visibleRange?: TimelineSelection;
|
|
69
|
+
/** Props for individual component slots */
|
|
70
|
+
slotProps?: TimelineChartSlotProps;
|
|
71
|
+
};
|
|
72
|
+
export type UseTimelineChartProps = {
|
|
73
|
+
events: TimelineEvent[];
|
|
74
|
+
selectedRange?: TimelineSelection;
|
|
75
|
+
onSelectionChange?: (selection: TimelineSelection) => void;
|
|
76
|
+
enableZoom: boolean;
|
|
77
|
+
zoomToSelection: boolean;
|
|
78
|
+
visibleRange?: TimelineSelection;
|
|
79
|
+
onVisibleRangeChange?: (range: TimelineSelection) => void;
|
|
80
|
+
};
|
|
81
|
+
export type UseTimelineChartReturn = {
|
|
82
|
+
isDragging: boolean;
|
|
83
|
+
dragStart: number | null;
|
|
84
|
+
internalSelectedRange: TimelineSelection;
|
|
85
|
+
internalVisibleRange: TimelineSelection;
|
|
86
|
+
hoveredEvent: TimelineEvent | null;
|
|
87
|
+
minDate: number;
|
|
88
|
+
maxDate: number;
|
|
89
|
+
timeSpan: number;
|
|
90
|
+
getPositionFromTimestamp: (timestamp: number) => number;
|
|
91
|
+
getTimestampFromPosition: (x: number, containerWidth: number) => number;
|
|
92
|
+
handleMouseDown: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
93
|
+
handleMouseMove: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
94
|
+
handleMouseUp: () => void;
|
|
95
|
+
handleWheel: (e: React.WheelEvent<HTMLDivElement>) => void;
|
|
96
|
+
handleDoubleClick: () => void;
|
|
97
|
+
setHoveredEvent: (event: TimelineEvent | null) => void;
|
|
98
|
+
getEventsInRange: () => TimelineEvent[];
|
|
99
|
+
resetZoom: () => void;
|
|
100
|
+
};
|
|
101
|
+
export type TimelineSelectedEventsProps = {
|
|
102
|
+
/** Array of selected events to display */
|
|
103
|
+
events: TimelineEvent[];
|
|
104
|
+
/** Title for the selected events section */
|
|
105
|
+
title?: string;
|
|
106
|
+
/** Maximum height before scrolling */
|
|
107
|
+
maxHeight?: string;
|
|
108
|
+
/** Custom date formatter */
|
|
109
|
+
formatDate?: (timestamp: number) => string;
|
|
110
|
+
/** Primary color for event items */
|
|
111
|
+
primaryColor?: string;
|
|
112
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { TimelineSelectedEventsProps } from './timeline-chart.types';
|
|
3
|
+
/**
|
|
4
|
+
* TimelineSelectedEvents component - Displays selected events from timeline
|
|
5
|
+
*
|
|
6
|
+
* This component observes and displays events that have been selected in a timeline.
|
|
7
|
+
* It can be used independently alongside the TimelineChart component.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TimelineSelectedEvents: FunctionComponent<TimelineSelectedEventsProps>;
|