@aiconstructions/graficos 0.0.0-stage → 0.2.1
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/ALTERACOES.md +53 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +188 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m, useReducedMotion, useTransform } from "motion/react";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { arcStartLabelLayout } from "./arc-geometry";
|
|
6
|
+
import {
|
|
7
|
+
ringCssVars,
|
|
8
|
+
useRingHover,
|
|
9
|
+
useRingStable
|
|
10
|
+
} from "./ring-context";
|
|
11
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
12
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
13
|
+
const RingLabel = memo(function RingLabel2({
|
|
14
|
+
index,
|
|
15
|
+
text,
|
|
16
|
+
color,
|
|
17
|
+
x,
|
|
18
|
+
y,
|
|
19
|
+
transform,
|
|
20
|
+
anchor,
|
|
21
|
+
isStatic
|
|
22
|
+
}) {
|
|
23
|
+
const { enterTransition, enterStaggerScale, animationKey } = useRingStable();
|
|
24
|
+
const { hoveredIndex } = useRingHover();
|
|
25
|
+
const progress = useMountProgress(
|
|
26
|
+
enterTransition,
|
|
27
|
+
(0.6 + index * 0.1) * enterStaggerScale,
|
|
28
|
+
`${animationKey}-label-${index}`
|
|
29
|
+
);
|
|
30
|
+
const done = useEnterComplete(progress);
|
|
31
|
+
const enterOpacity = useTransform(progress, [0, 1], [0, 1]);
|
|
32
|
+
const hoverOpacity = hoveredIndex !== null && hoveredIndex !== index ? 0.35 : 1;
|
|
33
|
+
const node = /* @__PURE__ */ jsx(
|
|
34
|
+
"text",
|
|
35
|
+
{
|
|
36
|
+
dominantBaseline: "central",
|
|
37
|
+
fill: color,
|
|
38
|
+
style: { fill: color },
|
|
39
|
+
textAnchor: anchor,
|
|
40
|
+
transform,
|
|
41
|
+
x,
|
|
42
|
+
y,
|
|
43
|
+
children: text
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
if (isStatic || done) {
|
|
47
|
+
return /* @__PURE__ */ jsx(
|
|
48
|
+
m.g,
|
|
49
|
+
{
|
|
50
|
+
animate: { opacity: hoverOpacity },
|
|
51
|
+
initial: false,
|
|
52
|
+
transition: { duration: 0.15 },
|
|
53
|
+
children: node
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return /* @__PURE__ */ jsx(m.g, { style: { opacity: enterOpacity }, children: node });
|
|
58
|
+
});
|
|
59
|
+
const RingLabels = memo(function RingLabels2({
|
|
60
|
+
format,
|
|
61
|
+
colorByRing = false,
|
|
62
|
+
color = ringCssVars.label,
|
|
63
|
+
fontSize: fontSizeProp,
|
|
64
|
+
offset: offsetProp
|
|
65
|
+
}) {
|
|
66
|
+
const {
|
|
67
|
+
data,
|
|
68
|
+
startAngle,
|
|
69
|
+
endAngle,
|
|
70
|
+
strokeWidth,
|
|
71
|
+
ringGap,
|
|
72
|
+
getRingRadii,
|
|
73
|
+
getColor,
|
|
74
|
+
geometryScrubbing
|
|
75
|
+
} = useRingStable();
|
|
76
|
+
const reducedMotion = useReducedMotion() ?? false;
|
|
77
|
+
const fontSize = fontSizeProp ?? Math.min(12, Math.max(9, (strokeWidth + ringGap) * 0.6));
|
|
78
|
+
const layout = arcStartLabelLayout(
|
|
79
|
+
startAngle,
|
|
80
|
+
endAngle,
|
|
81
|
+
offsetProp ?? fontSize * 0.6
|
|
82
|
+
);
|
|
83
|
+
return /* @__PURE__ */ jsx("g", { className: "font-mono", fontSize, pointerEvents: "none", children: data.map((ring, index) => {
|
|
84
|
+
const { innerRadius, outerRadius } = getRingRadii(index);
|
|
85
|
+
const { x, y, transform } = layout.position(
|
|
86
|
+
(innerRadius + outerRadius) / 2
|
|
87
|
+
);
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
RingLabel,
|
|
90
|
+
{
|
|
91
|
+
anchor: layout.anchor,
|
|
92
|
+
color: colorByRing ? getColor(index) : color,
|
|
93
|
+
index,
|
|
94
|
+
isStatic: reducedMotion || geometryScrubbing,
|
|
95
|
+
text: format ? format(ring, index) : ring.label,
|
|
96
|
+
transform,
|
|
97
|
+
x,
|
|
98
|
+
y
|
|
99
|
+
},
|
|
100
|
+
ring.label
|
|
101
|
+
);
|
|
102
|
+
}) });
|
|
103
|
+
});
|
|
104
|
+
RingLabels.displayName = "RingLabels";
|
|
105
|
+
var ring_labels_default = RingLabels;
|
|
106
|
+
export {
|
|
107
|
+
RingLabels,
|
|
108
|
+
ring_labels_default as default
|
|
109
|
+
};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
m,
|
|
5
|
+
useReducedMotion,
|
|
6
|
+
useTransform
|
|
7
|
+
} from "motion/react";
|
|
8
|
+
import { memo, useCallback } from "react";
|
|
9
|
+
import { arcPath } from "./arc-path";
|
|
10
|
+
import {
|
|
11
|
+
getRingHitRadii,
|
|
12
|
+
ringCssVars,
|
|
13
|
+
useRingHover,
|
|
14
|
+
useRingStable
|
|
15
|
+
} from "./ring-context";
|
|
16
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
17
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
18
|
+
function ringHoverScale(isHovered, isPushedOut) {
|
|
19
|
+
if (isHovered) {
|
|
20
|
+
return 1.03;
|
|
21
|
+
}
|
|
22
|
+
if (isPushedOut) {
|
|
23
|
+
return 1.02;
|
|
24
|
+
}
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
function RingProgressPath({
|
|
28
|
+
progressComplete,
|
|
29
|
+
progressPath,
|
|
30
|
+
animatedProgressPath,
|
|
31
|
+
color
|
|
32
|
+
}) {
|
|
33
|
+
if (progressComplete) {
|
|
34
|
+
if (!progressPath) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return /* @__PURE__ */ jsx("path", { d: progressPath, fill: color });
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(m.path, { d: animatedProgressPath, fill: color });
|
|
40
|
+
}
|
|
41
|
+
const Ring = memo(function Ring2({
|
|
42
|
+
index,
|
|
43
|
+
color: colorProp,
|
|
44
|
+
animate = true,
|
|
45
|
+
showGlow = true,
|
|
46
|
+
lineCap = "round"
|
|
47
|
+
}) {
|
|
48
|
+
const {
|
|
49
|
+
data,
|
|
50
|
+
getColor,
|
|
51
|
+
getRingRadii,
|
|
52
|
+
startAngle,
|
|
53
|
+
endAngle,
|
|
54
|
+
enterTransition,
|
|
55
|
+
enterStaggerScale,
|
|
56
|
+
animationKey,
|
|
57
|
+
baseInnerRadius,
|
|
58
|
+
strokeWidth,
|
|
59
|
+
ringGap
|
|
60
|
+
} = useRingStable();
|
|
61
|
+
const { hoveredIndex, setHoveredIndex } = useRingHover();
|
|
62
|
+
const reducedMotion = useReducedMotion() ?? false;
|
|
63
|
+
const expandDelay = index * 0.08 * enterStaggerScale;
|
|
64
|
+
const expandProgress = useMountProgress(
|
|
65
|
+
enterTransition,
|
|
66
|
+
expandDelay,
|
|
67
|
+
`${animationKey}-expand-${index}`
|
|
68
|
+
);
|
|
69
|
+
const expandComplete = useEnterComplete(expandProgress);
|
|
70
|
+
const progressDelay = (0.6 + index * 0.1) * enterStaggerScale;
|
|
71
|
+
const progressMount = useMountProgress(
|
|
72
|
+
enterTransition,
|
|
73
|
+
progressDelay,
|
|
74
|
+
`${animationKey}-progress-${index}`
|
|
75
|
+
);
|
|
76
|
+
const progressComplete = useEnterComplete(progressMount);
|
|
77
|
+
const ringData = data[index];
|
|
78
|
+
const progress = ringData ? ringData.value / ringData.maxValue : 0;
|
|
79
|
+
const arcRange = endAngle - startAngle;
|
|
80
|
+
const animatedProgressPath = useTransform(progressMount, (v) => {
|
|
81
|
+
if (!ringData) {
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
const currentEndAngle = startAngle + arcRange * progress * v;
|
|
85
|
+
if (currentEndAngle <= startAngle + 0.01) {
|
|
86
|
+
return "";
|
|
87
|
+
}
|
|
88
|
+
const radii = getRingRadii(index);
|
|
89
|
+
const corner = lineCap === "round" ? (radii.outerRadius - radii.innerRadius) / 2 : 0;
|
|
90
|
+
return arcPath(
|
|
91
|
+
radii.innerRadius,
|
|
92
|
+
radii.outerRadius,
|
|
93
|
+
startAngle,
|
|
94
|
+
currentEndAngle,
|
|
95
|
+
corner
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
const enterScale = useTransform(expandProgress, [0, 1], [0, 1]);
|
|
99
|
+
const handleMouseEnter = useCallback(
|
|
100
|
+
() => setHoveredIndex(index),
|
|
101
|
+
[index, setHoveredIndex]
|
|
102
|
+
);
|
|
103
|
+
const handleMouseLeave = useCallback(
|
|
104
|
+
() => setHoveredIndex(null),
|
|
105
|
+
[setHoveredIndex]
|
|
106
|
+
);
|
|
107
|
+
if (!ringData) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const { innerRadius, outerRadius } = getRingRadii(index);
|
|
111
|
+
const color = colorProp || getColor(index);
|
|
112
|
+
const isHovered = hoveredIndex === index;
|
|
113
|
+
const isFaded = hoveredIndex !== null && hoveredIndex !== index;
|
|
114
|
+
const isPushedOut = hoveredIndex !== null && hoveredIndex < index;
|
|
115
|
+
const cornerRadius = lineCap === "round" ? (outerRadius - innerRadius) / 2 : 0;
|
|
116
|
+
const bgPath = arcPath(
|
|
117
|
+
innerRadius,
|
|
118
|
+
outerRadius,
|
|
119
|
+
startAngle,
|
|
120
|
+
endAngle,
|
|
121
|
+
cornerRadius
|
|
122
|
+
);
|
|
123
|
+
const progressEndAngle = startAngle + arcRange * progress;
|
|
124
|
+
const progressPath = progressEndAngle <= startAngle + 0.01 ? "" : arcPath(
|
|
125
|
+
innerRadius,
|
|
126
|
+
outerRadius,
|
|
127
|
+
startAngle,
|
|
128
|
+
progressEndAngle,
|
|
129
|
+
cornerRadius
|
|
130
|
+
);
|
|
131
|
+
const hoverScale = ringHoverScale(isHovered, isPushedOut);
|
|
132
|
+
const layerOpacity = isFaded ? 0.35 : 1;
|
|
133
|
+
const enterDone = !animate || reducedMotion || expandComplete && progressComplete;
|
|
134
|
+
const groupStyle = {
|
|
135
|
+
transformOrigin: "0px 0px",
|
|
136
|
+
filter: showGlow && isHovered ? `drop-shadow(0 0 12px ${color})` : "none"
|
|
137
|
+
};
|
|
138
|
+
const hitRadii = getRingHitRadii(
|
|
139
|
+
index,
|
|
140
|
+
baseInnerRadius,
|
|
141
|
+
strokeWidth,
|
|
142
|
+
ringGap
|
|
143
|
+
);
|
|
144
|
+
const hitboxPath = arcPath(
|
|
145
|
+
hitRadii.innerRadius,
|
|
146
|
+
hitRadii.outerRadius,
|
|
147
|
+
startAngle,
|
|
148
|
+
endAngle,
|
|
149
|
+
0
|
|
150
|
+
);
|
|
151
|
+
const hitbox = (
|
|
152
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: SVG path used as hover hitbox for visualization
|
|
153
|
+
/* @__PURE__ */ jsx(
|
|
154
|
+
"path",
|
|
155
|
+
{
|
|
156
|
+
d: hitboxPath,
|
|
157
|
+
fill: "transparent",
|
|
158
|
+
onMouseEnter: handleMouseEnter,
|
|
159
|
+
onMouseLeave: handleMouseLeave,
|
|
160
|
+
style: { cursor: "pointer" }
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
if (enterDone) {
|
|
165
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
166
|
+
hitbox,
|
|
167
|
+
/* @__PURE__ */ jsxs(
|
|
168
|
+
m.g,
|
|
169
|
+
{
|
|
170
|
+
animate: { scale: hoverScale, opacity: layerOpacity },
|
|
171
|
+
initial: false,
|
|
172
|
+
pointerEvents: "none",
|
|
173
|
+
style: groupStyle,
|
|
174
|
+
transition: {
|
|
175
|
+
scale: { type: "spring", stiffness: 400, damping: 25 },
|
|
176
|
+
opacity: { duration: 0.15 }
|
|
177
|
+
},
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
|
|
180
|
+
progressPath ? /* @__PURE__ */ jsx("path", { d: progressPath, fill: color }) : null
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
if (!expandComplete) {
|
|
187
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
188
|
+
hitbox,
|
|
189
|
+
/* @__PURE__ */ jsx(
|
|
190
|
+
m.g,
|
|
191
|
+
{
|
|
192
|
+
pointerEvents: "none",
|
|
193
|
+
style: {
|
|
194
|
+
...groupStyle,
|
|
195
|
+
scale: enterScale,
|
|
196
|
+
opacity: layerOpacity
|
|
197
|
+
},
|
|
198
|
+
children: /* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground })
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
204
|
+
hitbox,
|
|
205
|
+
/* @__PURE__ */ jsxs(
|
|
206
|
+
m.g,
|
|
207
|
+
{
|
|
208
|
+
animate: { scale: hoverScale, opacity: layerOpacity },
|
|
209
|
+
initial: false,
|
|
210
|
+
pointerEvents: "none",
|
|
211
|
+
style: groupStyle,
|
|
212
|
+
transition: {
|
|
213
|
+
scale: { type: "spring", stiffness: 400, damping: 25 },
|
|
214
|
+
opacity: { duration: 0.15 }
|
|
215
|
+
},
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsx("path", { d: bgPath, fill: ringCssVars.ringBackground }),
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
RingProgressPath,
|
|
220
|
+
{
|
|
221
|
+
animatedProgressPath,
|
|
222
|
+
color,
|
|
223
|
+
progressComplete,
|
|
224
|
+
progressPath
|
|
225
|
+
}
|
|
226
|
+
)
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] });
|
|
231
|
+
});
|
|
232
|
+
Ring.displayName = "Ring";
|
|
233
|
+
var ring_default = Ring;
|
|
234
|
+
export {
|
|
235
|
+
Ring,
|
|
236
|
+
ring_default as default
|
|
237
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SankeyChart
|
|
3
|
+
} from "./sankey-chart";
|
|
4
|
+
import {
|
|
5
|
+
SankeyProvider,
|
|
6
|
+
sankeyCssVars,
|
|
7
|
+
useSankey
|
|
8
|
+
} from "./sankey-context";
|
|
9
|
+
import { SankeyLink } from "./sankey-link";
|
|
10
|
+
import {
|
|
11
|
+
SankeyNode
|
|
12
|
+
} from "./sankey-node";
|
|
13
|
+
import { SankeyTooltip } from "./sankey-tooltip";
|
|
14
|
+
export {
|
|
15
|
+
SankeyChart,
|
|
16
|
+
SankeyLink,
|
|
17
|
+
SankeyNode,
|
|
18
|
+
SankeyProvider,
|
|
19
|
+
SankeyTooltip,
|
|
20
|
+
sankeyCssVars,
|
|
21
|
+
useSankey
|
|
22
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
sankey,
|
|
5
|
+
sankeyCenter,
|
|
6
|
+
sankeyLinkHorizontal
|
|
7
|
+
} from "d3-sankey";
|
|
8
|
+
import { domAnimation, LazyMotion } from "motion/react";
|
|
9
|
+
import {
|
|
10
|
+
memo,
|
|
11
|
+
useCallback,
|
|
12
|
+
useEffect,
|
|
13
|
+
useMemo,
|
|
14
|
+
useRef,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { cn } from "../../lib/utils";
|
|
18
|
+
import { useChartDataOverride } from "../chart-data-override";
|
|
19
|
+
import { ParentSize } from "../chart-parent-size";
|
|
20
|
+
import { localPoint } from "../local-point";
|
|
21
|
+
import {
|
|
22
|
+
SankeyProvider
|
|
23
|
+
} from "./sankey-context";
|
|
24
|
+
const DEFAULT_MARGIN = { top: 40, right: 180, bottom: 40, left: 180 };
|
|
25
|
+
function SankeyChartInner(props) {
|
|
26
|
+
const { width, height } = props;
|
|
27
|
+
if (width < 10 || height < 10) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ jsx(SankeyChartCore, { ...props });
|
|
31
|
+
}
|
|
32
|
+
const SankeyChartCore = memo(function SankeyChartCore2({
|
|
33
|
+
data,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
margin,
|
|
37
|
+
animationDuration,
|
|
38
|
+
enterTransition,
|
|
39
|
+
revealSignature = "",
|
|
40
|
+
nodeWidth,
|
|
41
|
+
nodePadding,
|
|
42
|
+
children,
|
|
43
|
+
hoveredNodeIndexProp,
|
|
44
|
+
onNodeHoverChange
|
|
45
|
+
}) {
|
|
46
|
+
const containerRef = useRef(null);
|
|
47
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
48
|
+
const [revealEpoch, setRevealEpoch] = useState(1);
|
|
49
|
+
const [internalHoveredNodeIndex, setInternalHoveredNodeIndex] = useState(null);
|
|
50
|
+
const isNodeHoverControlled = hoveredNodeIndexProp !== void 0;
|
|
51
|
+
const hoveredNodeIndex = isNodeHoverControlled ? hoveredNodeIndexProp : internalHoveredNodeIndex;
|
|
52
|
+
const setHoveredNodeIndex = useCallback(
|
|
53
|
+
(index) => {
|
|
54
|
+
if (isNodeHoverControlled) {
|
|
55
|
+
onNodeHoverChange?.(index);
|
|
56
|
+
} else {
|
|
57
|
+
setInternalHoveredNodeIndex(index);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[isNodeHoverControlled, onNodeHoverChange]
|
|
61
|
+
);
|
|
62
|
+
const [hoveredLinkIndex, setHoveredLinkIndex] = useState(null);
|
|
63
|
+
const [tooltipData, setTooltipData] = useState(
|
|
64
|
+
null
|
|
65
|
+
);
|
|
66
|
+
const [mousePos, setMousePos] = useState(
|
|
67
|
+
null
|
|
68
|
+
);
|
|
69
|
+
const innerWidth = width - margin.left - margin.right;
|
|
70
|
+
const innerHeight = height - margin.top - margin.bottom;
|
|
71
|
+
const [revealKey, setRevealKey] = useState({
|
|
72
|
+
animationDuration,
|
|
73
|
+
revealSignature
|
|
74
|
+
});
|
|
75
|
+
if (revealKey.animationDuration !== animationDuration || revealKey.revealSignature !== revealSignature) {
|
|
76
|
+
setRevealKey({ animationDuration, revealSignature });
|
|
77
|
+
setRevealEpoch((n) => n + 1);
|
|
78
|
+
setIsLoaded(false);
|
|
79
|
+
}
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const timeout = setTimeout(() => {
|
|
82
|
+
setIsLoaded(true);
|
|
83
|
+
}, animationDuration);
|
|
84
|
+
return () => clearTimeout(timeout);
|
|
85
|
+
}, [animationDuration, revealSignature]);
|
|
86
|
+
const sankeyGenerator = useMemo(() => {
|
|
87
|
+
return sankey().nodeWidth(nodeWidth).nodePadding(nodePadding).nodeAlign(sankeyCenter).extent([
|
|
88
|
+
[0, 0],
|
|
89
|
+
[innerWidth, innerHeight]
|
|
90
|
+
]);
|
|
91
|
+
}, [innerWidth, innerHeight, nodeWidth, nodePadding]);
|
|
92
|
+
const graph = useMemo(() => {
|
|
93
|
+
const clonedData = {
|
|
94
|
+
nodes: data.nodes.map((node) => ({ ...node })),
|
|
95
|
+
links: data.links.map((link) => ({ ...link }))
|
|
96
|
+
};
|
|
97
|
+
return sankeyGenerator(clonedData);
|
|
98
|
+
}, [data, sankeyGenerator]);
|
|
99
|
+
const createPath = useCallback(
|
|
100
|
+
(link) => {
|
|
101
|
+
try {
|
|
102
|
+
const pathGenerator = sankeyLinkHorizontal();
|
|
103
|
+
return pathGenerator(link) || "";
|
|
104
|
+
} catch {
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
[]
|
|
109
|
+
);
|
|
110
|
+
const handleMouseMove = useCallback((event) => {
|
|
111
|
+
const point = localPoint(event);
|
|
112
|
+
if (point) {
|
|
113
|
+
setMousePos({ x: point.x, y: point.y });
|
|
114
|
+
}
|
|
115
|
+
}, []);
|
|
116
|
+
const handleMouseLeave = useCallback(() => {
|
|
117
|
+
setHoveredNodeIndex(null);
|
|
118
|
+
setHoveredLinkIndex(null);
|
|
119
|
+
setTooltipData(null);
|
|
120
|
+
setMousePos(null);
|
|
121
|
+
}, [setHoveredNodeIndex]);
|
|
122
|
+
const contextValue = {
|
|
123
|
+
graph,
|
|
124
|
+
nodes: graph.nodes,
|
|
125
|
+
links: graph.links,
|
|
126
|
+
width,
|
|
127
|
+
height,
|
|
128
|
+
innerWidth,
|
|
129
|
+
innerHeight,
|
|
130
|
+
margin,
|
|
131
|
+
hoveredNodeIndex,
|
|
132
|
+
hoveredLinkIndex,
|
|
133
|
+
setHoveredNodeIndex,
|
|
134
|
+
setHoveredLinkIndex,
|
|
135
|
+
tooltipData,
|
|
136
|
+
setTooltipData,
|
|
137
|
+
containerRef,
|
|
138
|
+
isLoaded,
|
|
139
|
+
animationDuration,
|
|
140
|
+
enterTransition,
|
|
141
|
+
revealEpoch,
|
|
142
|
+
mousePos,
|
|
143
|
+
createPath
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ jsx(SankeyProvider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: "relative h-full w-full", ref: containerRef, children: /* @__PURE__ */ jsx(
|
|
146
|
+
"svg",
|
|
147
|
+
{
|
|
148
|
+
"aria-hidden": "true",
|
|
149
|
+
className: "overflow-visible",
|
|
150
|
+
height,
|
|
151
|
+
onMouseLeave: handleMouseLeave,
|
|
152
|
+
onMouseMove: handleMouseMove,
|
|
153
|
+
width,
|
|
154
|
+
children: /* @__PURE__ */ jsx("g", { transform: `translate(${margin.left},${margin.top})`, children })
|
|
155
|
+
}
|
|
156
|
+
) }) });
|
|
157
|
+
});
|
|
158
|
+
function SankeyChart({
|
|
159
|
+
data: dataProp,
|
|
160
|
+
margin: marginProp,
|
|
161
|
+
animationDuration = 1100,
|
|
162
|
+
enterTransition,
|
|
163
|
+
revealSignature,
|
|
164
|
+
aspectRatio = "2 / 1",
|
|
165
|
+
nodeWidth = 16,
|
|
166
|
+
nodePadding = 24,
|
|
167
|
+
className = "",
|
|
168
|
+
children,
|
|
169
|
+
hoveredNodeIndex,
|
|
170
|
+
onNodeHoverChange
|
|
171
|
+
}) {
|
|
172
|
+
const { data } = useChartDataOverride("SankeyChart", {
|
|
173
|
+
data: dataProp
|
|
174
|
+
});
|
|
175
|
+
const margin = { ...DEFAULT_MARGIN, ...marginProp };
|
|
176
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx("div", { className: cn("relative w-full", className), style: { aspectRatio }, children: /* @__PURE__ */ jsx(ParentSize, { children: ({ width, height }) => /* @__PURE__ */ jsx(
|
|
177
|
+
SankeyChartInner,
|
|
178
|
+
{
|
|
179
|
+
animationDuration,
|
|
180
|
+
data,
|
|
181
|
+
enterTransition,
|
|
182
|
+
height,
|
|
183
|
+
hoveredNodeIndexProp: hoveredNodeIndex,
|
|
184
|
+
margin,
|
|
185
|
+
nodePadding,
|
|
186
|
+
nodeWidth,
|
|
187
|
+
onNodeHoverChange,
|
|
188
|
+
revealSignature,
|
|
189
|
+
width,
|
|
190
|
+
children
|
|
191
|
+
}
|
|
192
|
+
) }) }) });
|
|
193
|
+
}
|
|
194
|
+
SankeyChart.displayName = "SankeyChart";
|
|
195
|
+
var sankey_chart_default = SankeyChart;
|
|
196
|
+
export {
|
|
197
|
+
SankeyChart,
|
|
198
|
+
sankey_chart_default as default
|
|
199
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext
|
|
6
|
+
} from "react";
|
|
7
|
+
const SankeyContext = createContext(null);
|
|
8
|
+
function SankeyProvider({
|
|
9
|
+
children,
|
|
10
|
+
value
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsx(SankeyContext.Provider, { value, children });
|
|
13
|
+
}
|
|
14
|
+
function useSankey() {
|
|
15
|
+
const context = useContext(SankeyContext);
|
|
16
|
+
if (!context) {
|
|
17
|
+
throw new Error("useSankey must be used within a SankeyProvider");
|
|
18
|
+
}
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
21
|
+
const sankeyCssVars = {
|
|
22
|
+
background: "var(--chart-background)",
|
|
23
|
+
foreground: "var(--chart-foreground)",
|
|
24
|
+
nodePrimary: "var(--chart-line-primary)",
|
|
25
|
+
nodeSecondary: "var(--chart-line-secondary)",
|
|
26
|
+
linkColor: "var(--chart-foreground-muted, hsl(0, 0%, 50%))"
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
SankeyProvider,
|
|
30
|
+
sankeyCssVars,
|
|
31
|
+
useSankey
|
|
32
|
+
};
|