@moderneinc/react-charts 1.1.0-next.dcefa6 → 1.2.0-next.27c469
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 +10 -0
- package/dist/components/chrono-chart/chrono-chart.types.d.ts +112 -0
- package/dist/components/chrono-chart/components/category-table.component.d.ts +13 -0
- package/dist/components/chrono-chart/components/category-table.types.d.ts +42 -0
- package/dist/components/chrono-chart/utils/data-transformer.d.ts +41 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.component.d.ts +7 -0
- package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +89 -0
- package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +34 -0
- package/dist/components/morph-chart/hooks/shared/computations.d.ts +29 -0
- package/dist/components/morph-chart/hooks/shared/types.d.ts +24 -0
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +87 -0
- package/dist/components/morph-chart/index.d.ts +2 -0
- package/dist/components/morph-chart/morph-chart.component.d.ts +14 -0
- package/dist/components/morph-chart/morph-chart.types.d.ts +158 -0
- package/dist/components/morph-chart/utils/accordion-generator.d.ts +102 -0
- package/dist/components/morph-chart/utils/animation-constants.d.ts +23 -0
- package/dist/components/morph-chart/utils/animation-utils.d.ts +44 -0
- package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +53 -0
- package/dist/components/morph-chart/utils/area-renderer.d.ts +24 -0
- package/dist/components/morph-chart/utils/bar-renderer.d.ts +19 -0
- package/dist/components/morph-chart/utils/gsap-orchestrator.d.ts +291 -0
- package/dist/components/morph-chart/utils/morph-interpolator.d.ts +96 -0
- package/dist/components/morph-chart/utils/parliament-renderer.d.ts +23 -0
- package/dist/components/morph-chart/utils/parliament-seat-extractor.d.ts +33 -0
- package/dist/components/morph-chart/utils/position-mapper.d.ts +48 -0
- package/dist/components/morph-chart/utils/segment-transformer.d.ts +70 -0
- package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +35 -0
- package/dist/components/morph-chart/utils/svg-patterns.d.ts +19 -0
- package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +25 -0
- package/dist/components/parliament-chart/hooks/{use-parliament-chart.d.ts → use-parliament-chart.hook.d.ts} +5 -1
- package/dist/components/parliament-chart/parliament-chart.types.d.ts +5 -0
- package/dist/components/parliament-chart/utils/parliament-animation.d.ts +13 -0
- 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 +186 -0
- package/dist/components/stacked-area-chart/utils/color.utils.d.ts +4 -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 +156 -0
- package/dist/components/timeline-chart/timeline-selected-events.component.d.ts +9 -0
- package/dist/index.cjs +144 -11
- package/dist/index.d.ts +19 -6
- package/dist/index.js +31142 -4853
- package/dist/theme/default-colors.d.ts +8 -4
- package/dist/theme/timeline-defaults.d.ts +82 -0
- package/package.json +34 -11
- /package/dist/components/parliament-chart/{parliament-chart.d.ts → parliament-chart.component.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ParliamentLayout } from '../morph-chart.types';
|
|
2
|
+
type Party = {
|
|
3
|
+
id: string | number;
|
|
4
|
+
name: string;
|
|
5
|
+
seats: number;
|
|
6
|
+
colour: string;
|
|
7
|
+
};
|
|
8
|
+
type ParliamentOptions = {
|
|
9
|
+
arcAngle: number;
|
|
10
|
+
arcAngleFlexibility?: number;
|
|
11
|
+
radius: number;
|
|
12
|
+
seatSize: number;
|
|
13
|
+
minSeatSize: number;
|
|
14
|
+
maxSeatSize: number;
|
|
15
|
+
spacing: number;
|
|
16
|
+
innerRadiusRatio: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Generate parliament layout with seat positions
|
|
20
|
+
* Based on the logic from parliament-svg-enhanced.ts but returns position data
|
|
21
|
+
* instead of SVG elements
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateParliamentLayout(parties: Party[], options: ParliamentOptions): ParliamentLayout;
|
|
24
|
+
/**
|
|
25
|
+
* Convert category data to parliament party format
|
|
26
|
+
*/
|
|
27
|
+
export declare function categoriesToParties(categories: Array<{
|
|
28
|
+
dataKey: string;
|
|
29
|
+
label: string;
|
|
30
|
+
color: string;
|
|
31
|
+
value: number;
|
|
32
|
+
}>, totalRepositories: number, maxSeats: number): Party[];
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
2
|
+
import { ParliamentLayout, SeatPosition } from '../morph-chart.types';
|
|
3
|
+
/**
|
|
4
|
+
* Map parliament seats to their target positions at the right edge of the stacked area chart
|
|
5
|
+
* Seats can be positioned at the top (y1) or distributed vertically within their category's segment
|
|
6
|
+
*
|
|
7
|
+
* NOTE: stackData uses dataKey, but parliamentLayout.seats use category labels.
|
|
8
|
+
* We need to match by label, so stackData must contain label information.
|
|
9
|
+
*
|
|
10
|
+
* @param distributeVertically - If true, seats are spread between y0 and y1; if false, all seats at y1
|
|
11
|
+
*/
|
|
12
|
+
export declare function mapSeatsToStackEdge(parliamentLayout: ParliamentLayout, stackData: Array<{
|
|
13
|
+
dataKey: string;
|
|
14
|
+
label?: string;
|
|
15
|
+
y0: number;
|
|
16
|
+
y1: number;
|
|
17
|
+
timestamp?: number;
|
|
18
|
+
isSpecialCategory?: boolean;
|
|
19
|
+
}>, xScale: ScaleTime<number, number>, yScale: ScaleLinear<number, number>, chartWidth: number, chartHeight: number, distributeVertically?: boolean): Map<SeatPosition, {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Extract the rightmost slice of stacked area data
|
|
25
|
+
* This represents the same point-in-time as the parliament chart
|
|
26
|
+
*
|
|
27
|
+
* IMPORTANT: The stack is generated using original category order.
|
|
28
|
+
* We build the slice in original order to match the stack generation.
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractRightmostStackSlice(data: Array<{
|
|
31
|
+
timestamp: number;
|
|
32
|
+
[key: string]: number;
|
|
33
|
+
}>, categories: Array<{
|
|
34
|
+
dataKey: string;
|
|
35
|
+
label: string;
|
|
36
|
+
color: string;
|
|
37
|
+
parliamentMapping?: {
|
|
38
|
+
isSpecialCategory?: boolean;
|
|
39
|
+
};
|
|
40
|
+
}>, _yScale: ScaleLinear<number, number>): Array<{
|
|
41
|
+
dataKey: string;
|
|
42
|
+
label: string;
|
|
43
|
+
y0: number;
|
|
44
|
+
y1: number;
|
|
45
|
+
value: number;
|
|
46
|
+
timestamp: number;
|
|
47
|
+
isSpecialCategory?: boolean;
|
|
48
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
export interface Slinky3DConfig {
|
|
3
|
+
categories: Array<{
|
|
4
|
+
name: string;
|
|
5
|
+
color: string;
|
|
6
|
+
seatCount: number;
|
|
7
|
+
}>;
|
|
8
|
+
centerX: number;
|
|
9
|
+
centerY: number;
|
|
10
|
+
radius: number;
|
|
11
|
+
arcAngle: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate HTML content for 3D slinky rings
|
|
15
|
+
*/
|
|
16
|
+
export declare function generate3DSlinkyHTML(categories: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
color: string;
|
|
19
|
+
seatCount: number;
|
|
20
|
+
}>): string;
|
|
21
|
+
/**
|
|
22
|
+
* Generate CSS styles for 3D slinky effect
|
|
23
|
+
*/
|
|
24
|
+
export declare function generate3DSlinkyStyles(instanceId: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Create 3D slinky elements in SVG using foreignObject
|
|
27
|
+
*/
|
|
28
|
+
export declare function create3DSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: Slinky3DConfig, instanceId: string): {
|
|
29
|
+
wrapper: Selection<SVGForeignObjectElement, unknown, null, undefined>;
|
|
30
|
+
cleanup: () => void;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Animate 3D slinky compression using GSAP
|
|
34
|
+
*/
|
|
35
|
+
export declare function animate3DSlinkyCompression(instanceId: string, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
/**
|
|
3
|
+
* Add all hatch pattern definitions to an SVG's <defs> element
|
|
4
|
+
* Call this once when setting up the SVG
|
|
5
|
+
* @param svg - The SVG selection to add patterns to
|
|
6
|
+
* @param instancePrefix - Unique prefix for this instance to avoid ID conflicts
|
|
7
|
+
*/
|
|
8
|
+
export declare function addHatchPatternDefs(svg: Selection<SVGSVGElement, unknown, null, undefined>, instancePrefix: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Transform a color to use instance-specific pattern IDs
|
|
11
|
+
* Converts 'url(#patternName)' to 'url(#prefix-patternName)'
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformColorForInstance(color: string, instancePrefix: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get the display color for a category, handling pattern URLs
|
|
16
|
+
* Returns the line color for patterns (better visibility in hover states)
|
|
17
|
+
* Works with both instance-specific and generic pattern URLs
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDisplayColor(color: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Selection } from 'd3-selection';
|
|
2
|
+
export interface SvgSlinkyConfig {
|
|
3
|
+
categories: Array<{
|
|
4
|
+
name: string;
|
|
5
|
+
color: string;
|
|
6
|
+
seatCount: number;
|
|
7
|
+
}>;
|
|
8
|
+
centerX: number;
|
|
9
|
+
centerY: number;
|
|
10
|
+
radius: number;
|
|
11
|
+
innerRadius: number;
|
|
12
|
+
arcAngle: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create SVG slinky coils
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSvgSlinky(container: Selection<SVGGElement, unknown, null, undefined>, config: SvgSlinkyConfig, instanceId: string): {
|
|
18
|
+
slinkyGroup: Selection<SVGGElement, unknown, null, undefined>;
|
|
19
|
+
cleanup: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Animate SVG slinky closing - stacks rings vertically into a bar on the right
|
|
23
|
+
* Uses staggered animation phases to create realistic slinky walking effect
|
|
24
|
+
*/
|
|
25
|
+
export declare function animateSvgSlinkyCompression(slinkyGroup: Selection<SVGGElement, unknown, null, undefined>, timeline: gsap.core.Timeline, startTime: string, duration: number, targetX: number, targetY: number): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
|
|
3
|
+
import { ArcSweepDirection } from '../utils/parliament-animation';
|
|
3
4
|
type UseParliamentChartProps = {
|
|
4
5
|
containerRef: RefObject<HTMLDivElement>;
|
|
5
6
|
processedData: ProcessedDataItem[];
|
|
@@ -12,11 +13,14 @@ type UseParliamentChartProps = {
|
|
|
12
13
|
setActivePartyName: (name: string | null) => void;
|
|
13
14
|
chartConfig: ChartConfig;
|
|
14
15
|
seatSize: number;
|
|
16
|
+
shouldAnimate?: boolean;
|
|
17
|
+
animationDirection?: ArcSweepDirection;
|
|
18
|
+
onAnimationComplete?: () => void;
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
21
|
* Hook that manages parliament chart rendering and interactivity.
|
|
18
22
|
* Generates SVG visualization with seat circles and handles hover states
|
|
19
23
|
* for displaying repository statistics.
|
|
20
24
|
*/
|
|
21
|
-
export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize }: UseParliamentChartProps) => void;
|
|
25
|
+
export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize, shouldAnimate, animationDirection, onAnimationComplete }: UseParliamentChartProps) => void;
|
|
22
26
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParliamentChartTheme } from '../../theme/default-colors';
|
|
2
|
+
import { ArcSweepDirection } from './utils/parliament-animation';
|
|
2
3
|
type ParliamentDataSeries = {
|
|
3
4
|
value: number;
|
|
4
5
|
label: string;
|
|
@@ -12,6 +13,10 @@ export type ParliamentChartProps = {
|
|
|
12
13
|
arcAngle?: number;
|
|
13
14
|
useEnhanced?: boolean;
|
|
14
15
|
theme?: ParliamentChartTheme;
|
|
16
|
+
showTable?: boolean;
|
|
17
|
+
shouldAnimate?: boolean;
|
|
18
|
+
animationDirection?: ArcSweepDirection;
|
|
19
|
+
onAnimationComplete?: () => void;
|
|
15
20
|
};
|
|
16
21
|
export type ProcessedDataItem = {
|
|
17
22
|
id: string | number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ArcSweepDirection = 'left-to-right' | 'right-to-left';
|
|
2
|
+
/**
|
|
3
|
+
* Animates the parliament chart with an arc sweep reveal effect.
|
|
4
|
+
* Creates a clipPath that progressively reveals or collapses seats.
|
|
5
|
+
*
|
|
6
|
+
* @param svgElement - The SVG element containing the parliament chart
|
|
7
|
+
* @param arcAngle - The arc angle in degrees (e.g., 200)
|
|
8
|
+
* @param radius - The radius of the parliament arc
|
|
9
|
+
* @param direction - Direction of the sweep: 'left-to-right' (expand) or 'right-to-left' (collapse)
|
|
10
|
+
* @param duration - Animation duration in milliseconds (default: 900ms)
|
|
11
|
+
* @param onComplete - Optional callback fired when animation completes
|
|
12
|
+
*/
|
|
13
|
+
export declare function animateArcSweep(svgElement: SVGSVGElement, arcAngle: number, radius: number, direction?: ArcSweepDirection, duration?: number, onComplete?: () => void): void;
|
|
@@ -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,186 @@
|
|
|
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
|
+
};
|
|
@@ -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>;
|