@moderneinc/react-charts 1.7.0-next.1a5e01 → 1.7.0-next.9d4abe
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.types.d.ts +6 -0
- package/dist/components/morph-chart/hooks/use-morph-chart.hook.d.ts +3 -5
- package/dist/components/morph-chart/morph-chart.types.d.ts +8 -2
- package/dist/components/morph-chart/utils/parliament-renderer.d.ts +8 -1
- package/dist/components/parliament-chart/components/parliament-center-label.component.d.ts +29 -0
- package/dist/components/parliament-chart/hooks/use-parliament-chart.hook.d.ts +3 -1
- package/dist/components/parliament-chart/parliament-chart.constants.d.ts +1 -1
- package/dist/components/parliament-chart/parliament-chart.types.d.ts +6 -0
- package/dist/components/parliament-chart/utils/seat-extents.d.ts +11 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3962 -3893
- package/dist/utils/format-count.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CenterLabelVariant } from '../parliament-chart/parliament-chart.types';
|
|
1
2
|
import { TimelineEvent } from '../timeline-chart/timeline-chart.types';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a data category with visual styling and optional parliament-specific mappings.
|
|
@@ -142,4 +143,9 @@ export type ChronoChartProps = {
|
|
|
142
143
|
* @default '4,4'
|
|
143
144
|
*/
|
|
144
145
|
crosshairDashArray?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Center label's large figure: the hovered category's share, or its count.
|
|
148
|
+
* @default 'percent'
|
|
149
|
+
*/
|
|
150
|
+
centerLabelVariant?: CenterLabelVariant;
|
|
145
151
|
};
|
|
@@ -43,8 +43,6 @@ type UseMorphChartProps = {
|
|
|
43
43
|
onTimeRangeChange?: (range: [number, number]) => void;
|
|
44
44
|
minAllowedTime?: number;
|
|
45
45
|
maxAllowedTime?: number;
|
|
46
|
-
showScaleIndicator?: boolean;
|
|
47
|
-
reposPerSeat?: number;
|
|
48
46
|
timelineEvents?: Array<{
|
|
49
47
|
timestamp: number;
|
|
50
48
|
eventName: string;
|
|
@@ -60,11 +58,11 @@ type UseMorphChartProps = {
|
|
|
60
58
|
y: number;
|
|
61
59
|
} | null) => void;
|
|
62
60
|
};
|
|
63
|
-
export declare const useMorphChart: ({ containerRef, data, categories, mode, paletteMode, 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,
|
|
61
|
+
export declare const useMorphChart: ({ containerRef, data, categories, mode, paletteMode, 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, timelineEvents, showTimeline, timelineHeight, timelineOffset, brushColor, showCrosshair, onCrosshairMove }: UseMorphChartProps) => {
|
|
64
62
|
isMorphing: boolean;
|
|
65
63
|
currentMode: MorphMode;
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
seatExtents: import('../../parliament-chart/utils/seat-extents').SeatExtents | null;
|
|
65
|
+
hoveredData: HoveredData;
|
|
68
66
|
visibleMarkers: {
|
|
69
67
|
timestamp: number;
|
|
70
68
|
label?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PaletteMode } from '@mui/material/styles';
|
|
2
2
|
import { D3StackedAreaCategory } from '../d3-stacked-area-chart/d3-stacked-area-chart.types';
|
|
3
|
+
import { CenterLabelVariant } from '../parliament-chart/parliament-chart.types';
|
|
3
4
|
export type MorphMode = 'area' | 'parliament' | 'morphing';
|
|
4
5
|
export type MorphChartDataPoint = {
|
|
5
6
|
timestamp: number;
|
|
@@ -97,14 +98,19 @@ export type MorphChartProps = {
|
|
|
97
98
|
onHoveredDataChange?: (data: HoveredData) => void;
|
|
98
99
|
/** Currently hovered category (for external control of highlighting) */
|
|
99
100
|
hoveredCategory?: string | null;
|
|
100
|
-
/** Max seats before scaling (default:
|
|
101
|
+
/** Max seats before scaling (default: DEFAULT_CHART_CONFIG.maxSeats) */
|
|
101
102
|
maxSeats?: number;
|
|
102
103
|
/** Show tooltip overlay (default: true) */
|
|
103
104
|
showTooltip?: boolean;
|
|
104
105
|
/** Show category summary table (default: false for MorphChart) */
|
|
105
106
|
showTable?: boolean;
|
|
106
|
-
/** Show
|
|
107
|
+
/** Show "Each dot is …" in the parliament label (default: true) */
|
|
107
108
|
showScaledIndicator?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Center label's large figure: the hovered category's share, or its count.
|
|
111
|
+
* @default 'percent'
|
|
112
|
+
*/
|
|
113
|
+
centerLabelVariant?: CenterLabelVariant;
|
|
108
114
|
/**
|
|
109
115
|
* Explicit timestamp that the parliament represents.
|
|
110
116
|
* If provided, this overrides automatic timestamp detection and ensures
|
|
@@ -6,12 +6,19 @@ import { MorphChartCategory, ParliamentLayout } from '../morph-chart.types';
|
|
|
6
6
|
* Replaces spaces, slashes, and other special characters with hyphens
|
|
7
7
|
*/
|
|
8
8
|
export declare function sanitizeCategoryForClass(category: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Arc center in chart-area coords. Seats and MorphChart's center label both
|
|
11
|
+
* use it so they can't drift apart.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getParliamentCenter(radius: number, chartWidth: number, chartHeight: number): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
9
17
|
interface ParliamentRenderOptions {
|
|
10
18
|
centerX: number;
|
|
11
19
|
centerY: number;
|
|
12
20
|
addClasses?: boolean;
|
|
13
21
|
instanceId?: string;
|
|
14
|
-
parliamentRadius?: number;
|
|
15
22
|
paletteMode?: PaletteMode;
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SxProps, Theme } from '@mui/material';
|
|
2
|
+
import { FunctionComponent } from 'react';
|
|
3
|
+
import { CenterLabelVariant, HoveredData } from '../parliament-chart.types';
|
|
4
|
+
import { SeatExtents } from '../utils/seat-extents';
|
|
5
|
+
export declare const MUTED_TEXT = "var(--rc-muted-text, #6b7280)";
|
|
6
|
+
/**
|
|
7
|
+
* Arc-wide box, arc top to just below center; a ratio, so it fits any radius.
|
|
8
|
+
* Make it the label's `inline-size` container: sizes are `cqw` of 2r.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ARC_LABEL_BOX_ASPECT_RATIO: string;
|
|
11
|
+
export declare const formatPercentage: (value: number, total: number) => string;
|
|
12
|
+
export declare const SeatSwatch: FunctionComponent<{
|
|
13
|
+
color: string;
|
|
14
|
+
label: string;
|
|
15
|
+
size: number | string;
|
|
16
|
+
sx?: SxProps<Theme>;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Hovered category's share; nothing when idle. Its positioned ancestor should
|
|
20
|
+
* be an `ARC_LABEL_BOX_ASPECT_RATIO` box; `seatExtents` lifts it on narrow arcs.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ParliamentCenterLabel: FunctionComponent<{
|
|
23
|
+
hoveredData: HoveredData;
|
|
24
|
+
totalRepositories: number;
|
|
25
|
+
maxSeats: number;
|
|
26
|
+
seatExtents: SeatExtents | null;
|
|
27
|
+
variant?: CenterLabelVariant;
|
|
28
|
+
showScale?: boolean;
|
|
29
|
+
}>;
|
|
@@ -2,6 +2,7 @@ import { PaletteMode } from '@mui/material/styles';
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
import { ChartConfig, HoveredData, ProcessedDataItem } from '../parliament-chart.types';
|
|
4
4
|
import { ArcSweepDirection } from '../utils/parliament-animation';
|
|
5
|
+
import { SeatExtents } from '../utils/seat-extents';
|
|
5
6
|
type UseParliamentChartProps = {
|
|
6
7
|
containerRef: RefObject<HTMLDivElement>;
|
|
7
8
|
processedData: ProcessedDataItem[];
|
|
@@ -10,6 +11,7 @@ type UseParliamentChartProps = {
|
|
|
10
11
|
useEnhanced: boolean;
|
|
11
12
|
maxSeats: number;
|
|
12
13
|
setHoveredData: (data: HoveredData) => void;
|
|
14
|
+
setSeatExtents: (extents: SeatExtents | null) => void;
|
|
13
15
|
activePartyName: string | null;
|
|
14
16
|
setActivePartyName: (name: string | null) => void;
|
|
15
17
|
chartConfig: ChartConfig;
|
|
@@ -24,5 +26,5 @@ type UseParliamentChartProps = {
|
|
|
24
26
|
* Generates SVG visualization with seat circles and handles hover states
|
|
25
27
|
* for displaying repository statistics.
|
|
26
28
|
*/
|
|
27
|
-
export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, activePartyName, setActivePartyName, chartConfig, seatSize, paletteMode, shouldAnimate, animationDirection, onAnimationComplete }: UseParliamentChartProps) => void;
|
|
29
|
+
export declare const useParliamentChart: ({ containerRef, processedData, totalRepositories, arcAngle, useEnhanced, maxSeats, setHoveredData, setSeatExtents, activePartyName, setActivePartyName, chartConfig, seatSize, paletteMode, shouldAnimate, animationDirection, onAnimationComplete }: UseParliamentChartProps) => void;
|
|
28
30
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParliamentChartTheme } from '../../theme/default-colors';
|
|
2
2
|
import { ArcSweepDirection } from './utils/parliament-animation';
|
|
3
|
+
export type CenterLabelVariant = 'percent' | 'count';
|
|
3
4
|
type ParliamentDataSeries = {
|
|
4
5
|
value: number;
|
|
5
6
|
label: string;
|
|
@@ -17,6 +18,11 @@ export type ParliamentChartProps = {
|
|
|
17
18
|
shouldAnimate?: boolean;
|
|
18
19
|
animationDirection?: ArcSweepDirection;
|
|
19
20
|
onAnimationComplete?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Center label's large figure: the hovered category's share, or its count.
|
|
23
|
+
* @default 'percent'
|
|
24
|
+
*/
|
|
25
|
+
centerLabelVariant?: CenterLabelVariant;
|
|
20
26
|
};
|
|
21
27
|
export type ProcessedDataItem = {
|
|
22
28
|
id: string | number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Drawn seat extents from the arc center, in arc radii; negative is above. */
|
|
2
|
+
export type SeatExtents = {
|
|
3
|
+
holeTop: number;
|
|
4
|
+
seatsBottom: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const getSeatExtents: (seats: readonly {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
r: number;
|
|
10
|
+
}[], radius: number) => SeatExtents | null;
|
|
11
|
+
export declare const useSeatExtents: () => readonly [SeatExtents | null, (next: SeatExtents | null) => void];
|