@moderneinc/react-charts 1.2.0-next.fe4657 → 1.3.0-next.2608df

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 (29) hide show
  1. package/dist/components/chrono-chart/chrono-chart.types.d.ts +16 -0
  2. package/dist/components/d3-stacked-area-chart/d3-stacked-area-chart.types.d.ts +20 -0
  3. package/dist/components/d3-stacked-area-chart/hooks/use-d3-stacked-area.hook.d.ts +10 -2
  4. package/dist/components/d3-stacked-bar-chart/d3-stacked-bar-chart.component.d.ts +7 -0
  5. package/dist/components/d3-stacked-bar-chart/d3-stacked-bar-chart.types.d.ts +95 -0
  6. package/dist/components/d3-stacked-bar-chart/hooks/use-d3-stacked-bar.hook.d.ts +36 -0
  7. package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +6 -1
  8. package/dist/components/morph-chart/morph-chart.types.d.ts +16 -0
  9. package/dist/components/stacked-area-with-timeline/hooks/use-stacked-area-with-timeline.hook.d.ts +4 -3
  10. package/dist/components/stacked-area-with-timeline/utils/render-timeline-track.d.ts +3 -11
  11. package/dist/index.cjs +27 -122
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.js +9160 -24624
  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 +6 -16
  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
  29. package/dist/components/stacked-area-with-timeline/index.d.ts +0 -4
@@ -126,4 +126,20 @@ export type ChronoChartProps = {
126
126
  * @default '#69b3a2'
127
127
  */
128
128
  brushColor?: string;
129
+ /**
130
+ * Show crosshair cursor on hover (historical mode only).
131
+ * Crosshairs are hidden during morphing transitions.
132
+ * @default true
133
+ */
134
+ showCrosshair?: boolean;
135
+ /**
136
+ * Color for crosshair lines.
137
+ * @default '#666'
138
+ */
139
+ crosshairColor?: string;
140
+ /**
141
+ * Dash array pattern for crosshair lines.
142
+ * @default '4,4'
143
+ */
144
+ crosshairDashArray?: string;
129
145
  };
@@ -2,6 +2,14 @@
2
2
  * D3-based stacked area chart types
3
3
  * Built for seamless morphing with parliament chart
4
4
  */
5
+ export type HoveredAreaData = {
6
+ timestamp: number;
7
+ category: {
8
+ label: string;
9
+ color: string;
10
+ };
11
+ value: number;
12
+ };
5
13
  export type D3StackedAreaDataPoint = {
6
14
  timestamp: number;
7
15
  [category: string]: number;
@@ -78,6 +86,18 @@ export type D3StackedAreaChartProps = {
78
86
  * @default '#69b3a2'
79
87
  */
80
88
  brushColor?: string;
89
+ /** Show crosshair cursor on hover */
90
+ showCrosshair?: boolean;
91
+ /**
92
+ * Color for crosshair lines
93
+ * @default '#666'
94
+ */
95
+ crosshairColor?: string;
96
+ /**
97
+ * Dash array pattern for crosshair lines
98
+ * @default '4,4'
99
+ */
100
+ crosshairDashArray?: string;
81
101
  /** Mode for morphing animation */
82
102
  morphMode?: 'area' | 'parliament' | 'morphing';
83
103
  /** Parliament layout data (for morphing) */
@@ -1,5 +1,5 @@
1
1
  import { RefObject } from 'react';
2
- import { D3StackedAreaCategory, D3StackedAreaDataPoint } from '../d3-stacked-area-chart.types';
2
+ import { D3StackedAreaCategory, D3StackedAreaDataPoint, HoveredAreaData } from '../d3-stacked-area-chart.types';
3
3
  type UseD3StackedAreaProps = {
4
4
  containerRef: RefObject<SVGSVGElement>;
5
5
  data: D3StackedAreaDataPoint[];
@@ -30,6 +30,14 @@ type UseD3StackedAreaProps = {
30
30
  markerVisibilityMode?: 'always' | 'hover';
31
31
  onMarkerHoverChange?: (isHovering: boolean) => void;
32
32
  brushColor?: string;
33
+ showCrosshair?: boolean;
34
+ crosshairColor?: string;
35
+ crosshairDashArray?: string;
36
+ onHoveredAreaChange?: (data: HoveredAreaData | null) => void;
37
+ onCrosshairMove?: (position: {
38
+ x: number;
39
+ y: number;
40
+ } | null) => void;
33
41
  };
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;
42
+ export declare const useD3StackedArea: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, markers, markerVisibilityMode, onMarkerHoverChange, brushColor, showCrosshair, onHoveredAreaChange, onCrosshairMove }: UseD3StackedAreaProps) => void;
35
43
  export {};
@@ -0,0 +1,7 @@
1
+ import { FunctionComponent } from 'react';
2
+ import { D3StackedBarChartProps } from './d3-stacked-bar-chart.types';
3
+ /**
4
+ * D3-based stacked bar chart component
5
+ * Timeline-based bar chart with crosshair cursor and brush selection
6
+ */
7
+ export declare const D3StackedBarChart: FunctionComponent<D3StackedBarChartProps>;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * D3-based stacked bar chart types
3
+ * Timeline-based bar chart with crosshair cursor and brush selection
4
+ */
5
+ export type D3StackedBarDataPoint = {
6
+ timestamp: number;
7
+ [category: string]: number;
8
+ };
9
+ export type D3StackedBarCategory = {
10
+ dataKey: string;
11
+ label: string;
12
+ color: string;
13
+ fillOpacity?: number;
14
+ };
15
+ export type D3StackedBarChartProps = {
16
+ /** Array of data points sorted by timestamp */
17
+ data: D3StackedBarDataPoint[];
18
+ /** Array of category definitions */
19
+ categories: D3StackedBarCategory[];
20
+ /** Chart title */
21
+ title?: string;
22
+ /** Chart subtitle */
23
+ subtitle?: string;
24
+ /** Show header (title and subtitle) */
25
+ showHeader?: boolean;
26
+ /** Show legend */
27
+ showLegend?: boolean;
28
+ /** Show tooltips on hover */
29
+ showTooltip?: boolean;
30
+ /** Chart dimensions */
31
+ width?: number;
32
+ height?: number;
33
+ /** Margins for axes */
34
+ margin?: {
35
+ top: number;
36
+ right: number;
37
+ bottom: number;
38
+ left: number;
39
+ };
40
+ /** Time range for x-axis */
41
+ timeRange?: [number, number];
42
+ /** Show grid lines */
43
+ showGrid?: boolean;
44
+ /** Show axes (deprecated: use showXAxis and showYAxis instead) */
45
+ showAxes?: boolean;
46
+ /** Show X-axis */
47
+ showXAxis?: boolean;
48
+ /** Show Y-axis */
49
+ showYAxis?: boolean;
50
+ /** Format date for axis and tooltip */
51
+ formatDate?: (timestamp: number) => string;
52
+ /** Format value for axis and tooltip */
53
+ formatValue?: (value: number) => string;
54
+ /** Callback when time range changes */
55
+ onTimeRangeChange?: (range: [number, number]) => void;
56
+ /** Enable brush selection */
57
+ enableBrush?: boolean;
58
+ /** Zoom to selection - when true, brush clears after selection */
59
+ zoomToSelection?: boolean;
60
+ /**
61
+ * Color for brush selection overlay.
62
+ * @default '#69b3a2'
63
+ */
64
+ brushColor?: string;
65
+ /** Show crosshair cursor on hover */
66
+ showCrosshair?: boolean;
67
+ /**
68
+ * Color for crosshair lines
69
+ * @default '#666'
70
+ */
71
+ crosshairColor?: string;
72
+ /**
73
+ * Dash array pattern for crosshair lines
74
+ * @default '4,4'
75
+ */
76
+ crosshairDashArray?: string;
77
+ /**
78
+ * Minimum bar width in pixels. Overrides the automatic minimum width behavior.
79
+ * When not specified, the chart auto-applies a 2px minimum for time ranges > 3 months.
80
+ * Set to 0 to disable minimum width entirely.
81
+ */
82
+ minBarWidth?: number;
83
+ };
84
+ export type TooltipData = {
85
+ visible: boolean;
86
+ x: number;
87
+ y: number;
88
+ category: {
89
+ label: string;
90
+ color: string;
91
+ };
92
+ value: number;
93
+ startTime: number;
94
+ endTime: number;
95
+ };
@@ -0,0 +1,36 @@
1
+ import { RefObject } from 'react';
2
+ import { D3StackedBarCategory, D3StackedBarDataPoint, TooltipData } from '../d3-stacked-bar-chart.types';
3
+ type UseD3StackedBarProps = {
4
+ containerRef: RefObject<SVGSVGElement | null>;
5
+ data: D3StackedBarDataPoint[];
6
+ categories: D3StackedBarCategory[];
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
+ showCrosshair?: boolean;
25
+ crosshairColor?: string;
26
+ crosshairDashArray?: string;
27
+ brushColor?: string;
28
+ onTooltipChange?: (tooltip: TooltipData | null) => void;
29
+ minBarWidth?: number;
30
+ onCrosshairPositionChange?: (position: {
31
+ x: number;
32
+ y: number;
33
+ } | null) => void;
34
+ };
35
+ export declare const useD3StackedBar: ({ containerRef, data, categories, width, height, margin, timeRange, showGrid, showXAxis, showYAxis, enableBrush, zoomToSelection, onTimeRangeChange, formatDate, formatValue, showCrosshair, brushColor, onTooltipChange, minBarWidth, onCrosshairPositionChange }: UseD3StackedBarProps) => void;
36
+ export {};
@@ -52,8 +52,13 @@ type UseMorphChartProps = {
52
52
  timelineHeight?: number;
53
53
  timelineOffset?: number;
54
54
  brushColor?: string;
55
+ showCrosshair?: boolean;
56
+ onCrosshairMove?: (position: {
57
+ x: number;
58
+ y: number;
59
+ } | null) => void;
55
60
  };
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) => {
61
+ 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, showCrosshair, onCrosshairMove }: UseMorphChartProps) => {
57
62
  isMorphing: boolean;
58
63
  currentMode: MorphMode;
59
64
  hoveredCategory: string | null;
@@ -127,6 +127,22 @@ export type MorphChartProps = {
127
127
  * @default '#69b3a2'
128
128
  */
129
129
  brushColor?: string;
130
+ /**
131
+ * Show crosshair cursor on hover (area mode only).
132
+ * Crosshairs are hidden during morphing transitions.
133
+ * @default false
134
+ */
135
+ showCrosshair?: boolean;
136
+ /**
137
+ * Color for crosshair lines.
138
+ * @default '#666'
139
+ */
140
+ crosshairColor?: string;
141
+ /**
142
+ * Dash array pattern for crosshair lines.
143
+ * @default '4,4'
144
+ */
145
+ crosshairDashArray?: string;
130
146
  };
131
147
  /**
132
148
  * Seat position in parliament layout
@@ -1,7 +1,7 @@
1
1
  import { RefObject } from 'react';
2
2
  import { D3StackedAreaCategory } from '../../d3-stacked-area-chart/d3-stacked-area-chart.types';
3
3
  import { HoveredData, HoveredMarker, HoveredTimelineEvent, StackedAreaDataPoint, TimelineEvent } from '../stacked-area-with-timeline.types';
4
- export type UseStackedAreaWithTimelineOptions = {
4
+ type UseStackedAreaWithTimelineOptions = {
5
5
  containerRef: RefObject<SVGSVGElement | null>;
6
6
  data: StackedAreaDataPoint[];
7
7
  categories: D3StackedAreaCategory[];
@@ -38,15 +38,16 @@ export type UseStackedAreaWithTimelineOptions = {
38
38
  hoveredCategory?: string | null;
39
39
  onTimelineEventHover?: (event: HoveredTimelineEvent) => void;
40
40
  };
41
- export type VisibleMarker = {
41
+ type VisibleMarker = {
42
42
  timestamp: number;
43
43
  label?: string;
44
44
  color?: string;
45
45
  x: number;
46
46
  };
47
- export type UseStackedAreaWithTimelineResult = {
47
+ type UseStackedAreaWithTimelineResult = {
48
48
  hoveredTimelineEvent: HoveredTimelineEvent;
49
49
  hoveredMarker: HoveredMarker;
50
50
  visibleMarkers: VisibleMarker[];
51
51
  };
52
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 {};
@@ -1,16 +1,7 @@
1
1
  import { ScaleTime } from 'd3-scale';
2
2
  import { Selection } from 'd3-selection';
3
- export type TimelineEvent = {
4
- timestamp: number;
5
- eventName: string;
6
- color?: string;
7
- };
8
- export type HoveredTimelineEvent = {
9
- timestamp: number;
10
- eventName: string;
11
- x: number;
12
- } | null;
13
- export type RenderTimelineTrackOptions = {
3
+ import { HoveredTimelineEvent, TimelineEvent } from '../stacked-area-with-timeline.types';
4
+ type RenderTimelineTrackOptions = {
14
5
  /** D3 SVG selection */
15
6
  svg: Selection<SVGSVGElement, unknown, null, undefined>;
16
7
  /** Timeline events to display */
@@ -52,3 +43,4 @@ export type RenderTimelineTrackOptions = {
52
43
  * - Double-click to reset to full time range
53
44
  */
54
45
  export declare function renderTimelineTrack({ svg, events, xScale, chartHeight, chartWidth, timelineHeight, timelineOffset, instanceId, setHoveredTimelineEvent, enableBrush, onTimeRangeChange, minAllowedTime, maxAllowedTime, brushColor, mainGroupSelector }: RenderTimelineTrackOptions): void;
46
+ export {};