@moderneinc/react-charts 1.2.0-next.e6432a → 1.2.0-next.e86ce0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/components/chrono-chart/chrono-chart.types.d.ts +21 -6
  2. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +6 -0
  3. package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +2 -1
  4. package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +6 -1
  5. package/dist/components/morph-chart/morph-chart.types.d.ts +21 -0
  6. package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +53 -0
  7. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.component.d.ts +3 -0
  8. package/dist/components/stacked-area-with-timeline/stacked-area-with-timeline.types.d.ts +97 -0
  9. package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +46 -0
  10. package/dist/components/timeline-chart/timeline-chart.types.d.ts +2 -1
  11. package/dist/index.cjs +27 -122
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +8974 -24455
  14. package/dist/{components/stacked-area-chart/stacked-area-chart.constants.d.ts → theme/chart-palettes.d.ts} +4 -60
  15. package/dist/theme/timeline-defaults.d.ts +0 -8
  16. package/package.json +7 -17
  17. package/dist/components/morph-chart/index.d.ts +0 -2
  18. package/dist/components/morph-chart/utils/accordion-generator.d.ts +0 -102
  19. package/dist/components/morph-chart/utils/animation-utils.d.ts +0 -44
  20. package/dist/components/morph-chart/utils/arc-path-calculator.d.ts +0 -53
  21. package/dist/components/morph-chart/utils/morph-interpolator.d.ts +0 -96
  22. package/dist/components/morph-chart/utils/segment-transformer.d.ts +0 -70
  23. package/dist/components/morph-chart/utils/slinky-3d-generator.d.ts +0 -35
  24. package/dist/components/morph-chart/utils/svg-slinky-generator.d.ts +0 -25
  25. package/dist/components/stacked-area-chart/hooks/use-stacked-area-chart.hook.d.ts +0 -6
  26. package/dist/components/stacked-area-chart/stacked-area-chart.component.d.ts +0 -10
  27. package/dist/components/stacked-area-chart/stacked-area-chart.types.d.ts +0 -186
  28. package/dist/components/stacked-area-chart/utils/color.utils.d.ts +0 -4
@@ -1,10 +1,4 @@
1
1
  import { TimelineEvent } from '../timeline-chart/timeline-chart.types';
2
- /**
3
- * Display mode for the ChronoChart.
4
- * - 'point-in-time': Shows a snapshot at a specific moment
5
- * - 'historical': Shows trends over time
6
- */
7
- export type ChronoMode = 'point-in-time' | 'historical';
8
2
  /**
9
3
  * Represents a data category with visual styling and optional parliament-specific mappings.
10
4
  */
@@ -82,6 +76,10 @@ export type ChronoChartProps = {
82
76
  timeRange?: [number, number];
83
77
  /** Callback when the time range changes (via brush or other interactions) */
84
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;
85
83
  /** Enable brush selection for time range in historical mode */
86
84
  enableBrush?: boolean;
87
85
  /** Show the legend/category table */
@@ -90,6 +88,17 @@ export type ChronoChartProps = {
90
88
  showTooltip?: boolean;
91
89
  /** Show background grid lines */
92
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;
93
102
  /** Enable animations when switching between modes */
94
103
  enableAnimation?: boolean;
95
104
  /** Duration of animations in milliseconds */
@@ -111,4 +120,10 @@ export type ChronoChartProps = {
111
120
  onTimelineReady?: (timeline: unknown) => void;
112
121
  /** Callback for animation progress updates */
113
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;
114
129
  };
@@ -72,6 +72,12 @@ export type D3StackedAreaChartProps = {
72
72
  }>;
73
73
  /** Marker visibility mode: 'hover' shows only nearest marker on hover, 'always' shows all markers */
74
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;
75
81
  /** Mode for morphing animation */
76
82
  morphMode?: 'area' | 'parliament' | 'morphing';
77
83
  /** Parliament layout data (for morphing) */
@@ -29,6 +29,7 @@ type UseD3StackedAreaProps = {
29
29
  }>;
30
30
  markerVisibilityMode?: 'always' | 'hover';
31
31
  onMarkerHoverChange?: (isHovering: boolean) => void;
32
+ brushColor?: string;
32
33
  };
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;
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;
34
35
  export {};
@@ -16,6 +16,8 @@ type UseMorphChartProps = {
16
16
  timeRange?: [number, number];
17
17
  showGrid?: boolean;
18
18
  showAxes?: boolean;
19
+ axisLabelColor?: string;
20
+ axisLabelSize?: number;
19
21
  formatDate?: (timestamp: number) => string;
20
22
  formatValue?: (value: number) => string;
21
23
  markers?: Array<{
@@ -37,6 +39,8 @@ type UseMorphChartProps = {
37
39
  parliamentTimestamp?: number;
38
40
  enableBrush?: boolean;
39
41
  onTimeRangeChange?: (range: [number, number]) => void;
42
+ minAllowedTime?: number;
43
+ maxAllowedTime?: number;
40
44
  showScaleIndicator?: boolean;
41
45
  reposPerSeat?: number;
42
46
  timelineEvents?: Array<{
@@ -47,8 +51,9 @@ type UseMorphChartProps = {
47
51
  showTimeline?: boolean;
48
52
  timelineHeight?: number;
49
53
  timelineOffset?: number;
54
+ brushColor?: string;
50
55
  };
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) => {
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) => {
52
57
  isMorphing: boolean;
53
58
  currentMode: MorphMode;
54
59
  hoveredCategory: string | null;
@@ -43,10 +43,25 @@ export type MorphChartProps = {
43
43
  showGrid?: boolean;
44
44
  /** Show axes */
45
45
  showAxes?: boolean;
46
+ /**
47
+ * Color for axis labels (dates on x-axis, values on y-axis).
48
+ * @default undefined (inherits from SVG default, typically black)
49
+ */
50
+ axisLabelColor?: string;
51
+ /**
52
+ * Font size for axis labels in pixels.
53
+ * Increase this value when displaying charts at smaller sizes (e.g., in dashboards).
54
+ * @default 14
55
+ */
56
+ axisLabelSize?: number;
46
57
  /** Enable brush selection */
47
58
  enableBrush?: boolean;
48
59
  /** Callback when time range changes */
49
60
  onTimeRangeChange?: (range: [number, number]) => void;
61
+ /** Minimum allowed timestamp for time range selection (constrains brush selection) */
62
+ minAllowedTime?: number;
63
+ /** Maximum allowed timestamp for time range selection (constrains brush selection) */
64
+ maxAllowedTime?: number;
50
65
  /** Format date for axis */
51
66
  formatDate?: (timestamp: number) => string;
52
67
  /** Format value for axis */
@@ -106,6 +121,12 @@ export type MorphChartProps = {
106
121
  timelineHeight?: number;
107
122
  /** Space between x-axis and timeline in pixels (default: 35) */
108
123
  timelineOffset?: number;
124
+ /**
125
+ * Color for brush selection overlay.
126
+ * Used for both the selection area and drag handles.
127
+ * @default '#69b3a2'
128
+ */
129
+ brushColor?: string;
109
130
  };
110
131
  /**
111
132
  * Seat position in parliament layout
@@ -0,0 +1,53 @@
1
+ import { RefObject } from 'react';
2
+ import { D3StackedAreaCategory } from '../../d3-stacked-area-chart/d3-stacked-area-chart.types';
3
+ import { HoveredData, HoveredMarker, HoveredTimelineEvent, StackedAreaDataPoint, TimelineEvent } from '../stacked-area-with-timeline.types';
4
+ type UseStackedAreaWithTimelineOptions = {
5
+ containerRef: RefObject<SVGSVGElement | null>;
6
+ data: StackedAreaDataPoint[];
7
+ categories: D3StackedAreaCategory[];
8
+ width: number;
9
+ height: number;
10
+ margin: {
11
+ top: number;
12
+ right: number;
13
+ bottom: number;
14
+ left: number;
15
+ };
16
+ timelineEvents?: TimelineEvent[];
17
+ showTimeline?: boolean;
18
+ timelineHeight?: number;
19
+ timelineOffset?: number;
20
+ timeRange?: [number, number];
21
+ showGrid?: boolean;
22
+ showAxes?: boolean;
23
+ axisLabelColor?: string;
24
+ axisLabelSize?: number;
25
+ enableBrush?: boolean;
26
+ onTimeRangeChange?: (range: [number, number]) => void;
27
+ minAllowedTime?: number;
28
+ maxAllowedTime?: number;
29
+ brushColor?: string;
30
+ formatDate?: (timestamp: number) => string;
31
+ formatValue?: (value: number) => string;
32
+ markers?: Array<{
33
+ timestamp: number;
34
+ label?: string;
35
+ color?: string;
36
+ }>;
37
+ onHoveredDataChange?: (data: HoveredData) => void;
38
+ hoveredCategory?: string | null;
39
+ onTimelineEventHover?: (event: HoveredTimelineEvent) => void;
40
+ };
41
+ type VisibleMarker = {
42
+ timestamp: number;
43
+ label?: string;
44
+ color?: string;
45
+ x: number;
46
+ };
47
+ type UseStackedAreaWithTimelineResult = {
48
+ hoveredTimelineEvent: HoveredTimelineEvent;
49
+ hoveredMarker: HoveredMarker;
50
+ visibleMarkers: VisibleMarker[];
51
+ };
52
+ export declare const useStackedAreaWithTimeline: ({ containerRef, data, categories, width, height, margin, timelineEvents, showTimeline, timelineHeight, timelineOffset, timeRange, showGrid, showAxes, axisLabelColor, axisLabelSize, enableBrush, onTimeRangeChange, minAllowedTime, maxAllowedTime, brushColor, formatDate, formatValue, markers, onHoveredDataChange, hoveredCategory, onTimelineEventHover }: UseStackedAreaWithTimelineOptions) => UseStackedAreaWithTimelineResult;
53
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { StackedAreaWithTimelineProps } from './stacked-area-with-timeline.types';
3
+ export declare const StackedAreaWithTimeline: FunctionComponent<StackedAreaWithTimelineProps>;
@@ -0,0 +1,97 @@
1
+ import { D3StackedAreaCategory } from '../d3-stacked-area-chart/d3-stacked-area-chart.types';
2
+ export type StackedAreaDataPoint = {
3
+ timestamp: number;
4
+ values: Record<string, number>;
5
+ };
6
+ export type TimelineEvent = {
7
+ timestamp: number;
8
+ eventName: string;
9
+ color?: string;
10
+ };
11
+ export type HoveredData = {
12
+ label: string;
13
+ value: number;
14
+ color: string;
15
+ } | null;
16
+ export type HoveredTimelineEvent = {
17
+ timestamp: number;
18
+ eventName: string;
19
+ x: number;
20
+ } | null;
21
+ export type HoveredMarker = {
22
+ timestamp: number;
23
+ label?: string;
24
+ color?: string;
25
+ x: number;
26
+ } | null;
27
+ export type StackedAreaWithTimelineProps = {
28
+ /** Time series data points */
29
+ data: StackedAreaDataPoint[];
30
+ /** Category definitions (colors, labels, data keys) */
31
+ categories: D3StackedAreaCategory[];
32
+ /** Timeline events to display below the chart */
33
+ timelineEvents?: TimelineEvent[];
34
+ /** Show the timeline track (default: true if timelineEvents provided) */
35
+ showTimeline?: boolean;
36
+ /** Height of the timeline track in pixels (default: 40) */
37
+ timelineHeight?: number;
38
+ /** Vertical space between chart and timeline in pixels (default: 35) */
39
+ timelineOffset?: number;
40
+ /** Chart width in pixels (default: 900) */
41
+ width?: number;
42
+ /** Chart height in pixels, not including timeline (default: 400) */
43
+ height?: number;
44
+ /** Chart margins */
45
+ margin?: {
46
+ top: number;
47
+ right: number;
48
+ bottom: number;
49
+ left: number;
50
+ };
51
+ /** Show grid lines (default: true) */
52
+ showGrid?: boolean;
53
+ /** Show axes (default: true) */
54
+ showAxes?: boolean;
55
+ /**
56
+ * Color for axis labels (dates on x-axis, values on y-axis).
57
+ * @default undefined (inherits from SVG default, typically black)
58
+ */
59
+ axisLabelColor?: string;
60
+ /**
61
+ * Font size for axis labels in pixels.
62
+ * Increase for smaller chart displays (e.g., dashboards).
63
+ * @default 14
64
+ */
65
+ axisLabelSize?: number;
66
+ /** Custom date formatter for x-axis */
67
+ formatDate?: (timestamp: number) => string;
68
+ /** Custom value formatter for y-axis */
69
+ formatValue?: (value: number) => string;
70
+ /** Time range to display [start, end] timestamps */
71
+ timeRange?: [number, number];
72
+ /** Enable brush selection for zooming/panning */
73
+ enableBrush?: boolean;
74
+ /** Callback when time range changes via brush */
75
+ onTimeRangeChange?: (range: [number, number]) => void;
76
+ /** Minimum allowed timestamp for brush constraint */
77
+ minAllowedTime?: number;
78
+ /** Maximum allowed timestamp for brush constraint */
79
+ maxAllowedTime?: number;
80
+ /**
81
+ * Color for brush selection overlay.
82
+ * @default '#69b3a2'
83
+ */
84
+ brushColor?: string;
85
+ /** Event markers (vertical lines on the main chart) */
86
+ markers?: Array<{
87
+ timestamp: number;
88
+ label?: string;
89
+ color?: string;
90
+ }>;
91
+ /** Callback when a category is hovered */
92
+ onHoveredDataChange?: (data: HoveredData) => void;
93
+ /** Currently hovered category (for external highlighting control) */
94
+ hoveredCategory?: string | null;
95
+ /** Callback when a timeline event is hovered */
96
+ onTimelineEventHover?: (event: HoveredTimelineEvent) => void;
97
+ };
@@ -0,0 +1,46 @@
1
+ import { ScaleTime } from 'd3-scale';
2
+ import { Selection } from 'd3-selection';
3
+ import { HoveredTimelineEvent, TimelineEvent } from '../stacked-area-with-timeline.types';
4
+ type RenderTimelineTrackOptions = {
5
+ /** D3 SVG selection */
6
+ svg: Selection<SVGSVGElement, unknown, null, undefined>;
7
+ /** Timeline events to display */
8
+ events: TimelineEvent[];
9
+ /** D3 time scale for x-axis */
10
+ xScale: ScaleTime<number, number>;
11
+ /** Height of the main chart area (timeline renders below this) */
12
+ chartHeight: number;
13
+ /** Width of the chart area */
14
+ chartWidth: number;
15
+ /** Height of the timeline track */
16
+ timelineHeight: number;
17
+ /** Vertical offset between chart and timeline */
18
+ timelineOffset: number;
19
+ /** Optional instance ID for unique CSS classes */
20
+ instanceId?: string;
21
+ /** Callback when an event is hovered */
22
+ setHoveredTimelineEvent: (event: HoveredTimelineEvent) => void;
23
+ /** Enable brush selection on timeline */
24
+ enableBrush?: boolean;
25
+ /** Callback when time range changes via brush */
26
+ onTimeRangeChange?: (range: [number, number]) => void;
27
+ /** Minimum allowed timestamp for brush constraint */
28
+ minAllowedTime?: number;
29
+ /** Maximum allowed timestamp for brush constraint */
30
+ maxAllowedTime?: number;
31
+ /** Color for brush selection overlay */
32
+ brushColor?: string;
33
+ /** CSS selector for the main chart group (default: '.main-chart-group') */
34
+ mainGroupSelector?: string;
35
+ };
36
+ /**
37
+ * Renders an interactive timeline track below a chart
38
+ *
39
+ * Features:
40
+ * - Event markers as vertical colored lines
41
+ * - Hover interactions with width expansion
42
+ * - Optional brush selection with constraint bounds
43
+ * - Double-click to reset to full time range
44
+ */
45
+ export declare function renderTimelineTrack({ svg, events, xScale, chartHeight, chartWidth, timelineHeight, timelineOffset, instanceId, setHoveredTimelineEvent, enableBrush, onTimeRangeChange, minAllowedTime, maxAllowedTime, brushColor, mainGroupSelector }: RenderTimelineTrackOptions): void;
46
+ export {};
@@ -16,7 +16,7 @@ export type TimelineSelection = {
16
16
  end: number | null;
17
17
  };
18
18
  export type DragHandleType = 'start' | 'end' | 'body' | null;
19
- export type DragHandleVariant = 'arrow' | 'grip';
19
+ type DragHandleVariant = 'arrow' | 'grip';
20
20
  export type TimelineChartSlotProps = {
21
21
  /** Props for the header container (Stack) */
22
22
  header?: StackProps;
@@ -153,3 +153,4 @@ export type TimelineSelectedEventsProps = {
153
153
  /** Primary color for event items */
154
154
  primaryColor?: string;
155
155
  };
156
+ export {};