@aiconstructions/graficos 0.0.0-stage → 0.2.2
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 +57 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +189 -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,773 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { domAnimation, LazyMotion, m, useTransform } from "motion/react";
|
|
4
|
+
import {
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState
|
|
9
|
+
} from "react";
|
|
10
|
+
import { cn } from "../lib/utils";
|
|
11
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
12
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
13
|
+
import { useChartDataOverride } from "./chart-data-override";
|
|
14
|
+
import { intFmt } from "./chart-formatters";
|
|
15
|
+
const fmtPct = (p) => `${Math.round(p)}%`;
|
|
16
|
+
const fmtVal = intFmt;
|
|
17
|
+
function hSegmentPath(normStart, normEnd, segW, H, layerScale, straight = false) {
|
|
18
|
+
const my = H / 2;
|
|
19
|
+
const h0 = normStart * H * 0.44 * layerScale;
|
|
20
|
+
const h1 = normEnd * H * 0.44 * layerScale;
|
|
21
|
+
if (straight) {
|
|
22
|
+
return `M 0 ${my - h0} L ${segW} ${my - h1} L ${segW} ${my + h1} L 0 ${my + h0} Z`;
|
|
23
|
+
}
|
|
24
|
+
const cx = segW * 0.55;
|
|
25
|
+
const top = `M 0 ${my - h0} C ${cx} ${my - h0}, ${segW - cx} ${my - h1}, ${segW} ${my - h1}`;
|
|
26
|
+
const bot = `L ${segW} ${my + h1} C ${segW - cx} ${my + h1}, ${cx} ${my + h0}, 0 ${my + h0}`;
|
|
27
|
+
return `${top} ${bot} Z`;
|
|
28
|
+
}
|
|
29
|
+
function vSegmentPath(normStart, normEnd, segH, W, layerScale, straight = false) {
|
|
30
|
+
const mx = W / 2;
|
|
31
|
+
const w0 = normStart * W * 0.44 * layerScale;
|
|
32
|
+
const w1 = normEnd * W * 0.44 * layerScale;
|
|
33
|
+
if (straight) {
|
|
34
|
+
return `M ${mx - w0} 0 L ${mx - w1} ${segH} L ${mx + w1} ${segH} L ${mx + w0} 0 Z`;
|
|
35
|
+
}
|
|
36
|
+
const cy = segH * 0.55;
|
|
37
|
+
const left = `M ${mx - w0} 0 C ${mx - w0} ${cy}, ${mx - w1} ${segH - cy}, ${mx - w1} ${segH}`;
|
|
38
|
+
const right = `L ${mx + w1} ${segH} C ${mx + w1} ${segH - cy}, ${mx + w0} ${cy}, ${mx + w0} 0`;
|
|
39
|
+
return `${left} ${right} Z`;
|
|
40
|
+
}
|
|
41
|
+
function HRing({
|
|
42
|
+
d,
|
|
43
|
+
color,
|
|
44
|
+
fill,
|
|
45
|
+
opacity,
|
|
46
|
+
hovered,
|
|
47
|
+
ringIndex,
|
|
48
|
+
totalRings
|
|
49
|
+
}) {
|
|
50
|
+
const extraScale = 1 + ringIndex / Math.max(totalRings - 1, 1) * 0.12;
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
m.path,
|
|
53
|
+
{
|
|
54
|
+
animate: { scaleY: hovered ? extraScale : 1 },
|
|
55
|
+
d,
|
|
56
|
+
fill: fill ?? color,
|
|
57
|
+
opacity,
|
|
58
|
+
style: { transformOrigin: "center center" },
|
|
59
|
+
transition: {
|
|
60
|
+
type: "spring",
|
|
61
|
+
stiffness: 300 - ringIndex * 60,
|
|
62
|
+
damping: 24 - ringIndex * 3
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function HSegment({
|
|
68
|
+
index,
|
|
69
|
+
normStart,
|
|
70
|
+
normEnd,
|
|
71
|
+
segW,
|
|
72
|
+
fullH,
|
|
73
|
+
color,
|
|
74
|
+
layers,
|
|
75
|
+
staggerDelay,
|
|
76
|
+
enterTransition,
|
|
77
|
+
hovered,
|
|
78
|
+
dimmed,
|
|
79
|
+
renderPattern,
|
|
80
|
+
straight,
|
|
81
|
+
gradientStops
|
|
82
|
+
}) {
|
|
83
|
+
const patternId = `funnel-h-pattern-${index}`;
|
|
84
|
+
const gradientId = `funnel-h-grad-${index}`;
|
|
85
|
+
const mountProgress = useMountProgress(
|
|
86
|
+
enterTransition,
|
|
87
|
+
index * staggerDelay,
|
|
88
|
+
index
|
|
89
|
+
);
|
|
90
|
+
const enterComplete = useEnterComplete(mountProgress);
|
|
91
|
+
const entranceScaleX = useTransform(mountProgress, [0, 1], [0, 1]);
|
|
92
|
+
const entranceScaleY = useTransform(mountProgress, [0, 1], [0, 1]);
|
|
93
|
+
const rings = Array.from({ length: layers }, (_, l) => {
|
|
94
|
+
const scale = 1 - l / layers * 0.35;
|
|
95
|
+
const opacity = 0.18 + l / (layers - 1 || 1) * 0.65;
|
|
96
|
+
return {
|
|
97
|
+
d: hSegmentPath(normStart, normEnd, segW, fullH, scale, straight),
|
|
98
|
+
opacity
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
m.div,
|
|
103
|
+
{
|
|
104
|
+
animate: { opacity: dimmed ? 0.4 : 1 },
|
|
105
|
+
className: "pointer-events-none relative shrink-0 overflow-visible",
|
|
106
|
+
style: {
|
|
107
|
+
width: segW,
|
|
108
|
+
height: fullH,
|
|
109
|
+
zIndex: hovered ? 10 : 1
|
|
110
|
+
},
|
|
111
|
+
transition: { opacity: { duration: 0.15 } },
|
|
112
|
+
children: enterComplete ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 overflow-visible", children: /* @__PURE__ */ jsxs(
|
|
113
|
+
"svg",
|
|
114
|
+
{
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
className: "absolute inset-0 h-full w-full overflow-visible",
|
|
117
|
+
preserveAspectRatio: "none",
|
|
118
|
+
role: "presentation",
|
|
119
|
+
viewBox: `0 0 ${segW} ${fullH}`,
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
122
|
+
gradientStops && /* @__PURE__ */ jsx("linearGradient", { id: gradientId, x1: "0", x2: "1", y1: "0", y2: "0", children: gradientStops.map((stop) => /* @__PURE__ */ jsx(
|
|
123
|
+
"stop",
|
|
124
|
+
{
|
|
125
|
+
offset: typeof stop.offset === "number" ? `${stop.offset * 100}%` : stop.offset,
|
|
126
|
+
stopColor: stop.color
|
|
127
|
+
},
|
|
128
|
+
`${stop.offset}-${stop.color}`
|
|
129
|
+
)) }),
|
|
130
|
+
renderPattern?.(patternId, color)
|
|
131
|
+
] }),
|
|
132
|
+
rings.map((r, i) => {
|
|
133
|
+
const isInnermost = i === rings.length - 1;
|
|
134
|
+
let ringFill;
|
|
135
|
+
if (isInnermost && renderPattern) {
|
|
136
|
+
ringFill = `url(#${patternId})`;
|
|
137
|
+
} else if (isInnermost && gradientStops) {
|
|
138
|
+
ringFill = `url(#${gradientId})`;
|
|
139
|
+
}
|
|
140
|
+
const ringKey = `h-ring-${r.opacity.toFixed(2)}`;
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
HRing,
|
|
143
|
+
{
|
|
144
|
+
color,
|
|
145
|
+
d: r.d,
|
|
146
|
+
fill: ringFill,
|
|
147
|
+
hovered,
|
|
148
|
+
opacity: r.opacity,
|
|
149
|
+
ringIndex: i,
|
|
150
|
+
totalRings: layers
|
|
151
|
+
},
|
|
152
|
+
ringKey
|
|
153
|
+
);
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
) }) : /* @__PURE__ */ jsx(
|
|
158
|
+
m.div,
|
|
159
|
+
{
|
|
160
|
+
className: "absolute inset-0 overflow-visible",
|
|
161
|
+
style: {
|
|
162
|
+
scaleX: entranceScaleX,
|
|
163
|
+
scaleY: entranceScaleY,
|
|
164
|
+
transformOrigin: "left center"
|
|
165
|
+
},
|
|
166
|
+
children: /* @__PURE__ */ jsxs(
|
|
167
|
+
"svg",
|
|
168
|
+
{
|
|
169
|
+
"aria-hidden": "true",
|
|
170
|
+
className: "absolute inset-0 h-full w-full overflow-visible",
|
|
171
|
+
preserveAspectRatio: "none",
|
|
172
|
+
role: "presentation",
|
|
173
|
+
viewBox: `0 0 ${segW} ${fullH}`,
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
176
|
+
gradientStops && /* @__PURE__ */ jsx("linearGradient", { id: gradientId, x1: "0", x2: "1", y1: "0", y2: "0", children: gradientStops.map((stop) => /* @__PURE__ */ jsx(
|
|
177
|
+
"stop",
|
|
178
|
+
{
|
|
179
|
+
offset: typeof stop.offset === "number" ? `${stop.offset * 100}%` : stop.offset,
|
|
180
|
+
stopColor: stop.color
|
|
181
|
+
},
|
|
182
|
+
`${stop.offset}-${stop.color}`
|
|
183
|
+
)) }),
|
|
184
|
+
renderPattern?.(patternId, color)
|
|
185
|
+
] }),
|
|
186
|
+
rings.map((r, i) => {
|
|
187
|
+
const isInnermost = i === rings.length - 1;
|
|
188
|
+
let ringFill;
|
|
189
|
+
if (isInnermost && renderPattern) {
|
|
190
|
+
ringFill = `url(#${patternId})`;
|
|
191
|
+
} else if (isInnermost && gradientStops) {
|
|
192
|
+
ringFill = `url(#${gradientId})`;
|
|
193
|
+
}
|
|
194
|
+
const ringKey = `h-ring-${r.opacity.toFixed(2)}`;
|
|
195
|
+
return /* @__PURE__ */ jsx(
|
|
196
|
+
HRing,
|
|
197
|
+
{
|
|
198
|
+
color,
|
|
199
|
+
d: r.d,
|
|
200
|
+
fill: ringFill,
|
|
201
|
+
hovered,
|
|
202
|
+
opacity: r.opacity,
|
|
203
|
+
ringIndex: i,
|
|
204
|
+
totalRings: layers
|
|
205
|
+
},
|
|
206
|
+
ringKey
|
|
207
|
+
);
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function VRing({
|
|
218
|
+
d,
|
|
219
|
+
color,
|
|
220
|
+
fill,
|
|
221
|
+
opacity,
|
|
222
|
+
hovered,
|
|
223
|
+
ringIndex,
|
|
224
|
+
totalRings
|
|
225
|
+
}) {
|
|
226
|
+
const extraScale = 1 + ringIndex / Math.max(totalRings - 1, 1) * 0.12;
|
|
227
|
+
return /* @__PURE__ */ jsx(
|
|
228
|
+
m.path,
|
|
229
|
+
{
|
|
230
|
+
animate: { scaleX: hovered ? extraScale : 1 },
|
|
231
|
+
d,
|
|
232
|
+
fill: fill ?? color,
|
|
233
|
+
opacity,
|
|
234
|
+
style: { transformOrigin: "center center" },
|
|
235
|
+
transition: {
|
|
236
|
+
type: "spring",
|
|
237
|
+
stiffness: 300 - ringIndex * 60,
|
|
238
|
+
damping: 24 - ringIndex * 3
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
function VSegment({
|
|
244
|
+
index,
|
|
245
|
+
normStart,
|
|
246
|
+
normEnd,
|
|
247
|
+
segH,
|
|
248
|
+
fullW,
|
|
249
|
+
color,
|
|
250
|
+
layers,
|
|
251
|
+
staggerDelay,
|
|
252
|
+
enterTransition,
|
|
253
|
+
hovered,
|
|
254
|
+
dimmed,
|
|
255
|
+
renderPattern,
|
|
256
|
+
straight,
|
|
257
|
+
gradientStops
|
|
258
|
+
}) {
|
|
259
|
+
const patternId = `funnel-v-pattern-${index}`;
|
|
260
|
+
const gradientId = `funnel-v-grad-${index}`;
|
|
261
|
+
const mountProgress = useMountProgress(
|
|
262
|
+
enterTransition,
|
|
263
|
+
index * staggerDelay,
|
|
264
|
+
index
|
|
265
|
+
);
|
|
266
|
+
const enterComplete = useEnterComplete(mountProgress);
|
|
267
|
+
const entranceScaleY = useTransform(mountProgress, [0, 1], [0, 1]);
|
|
268
|
+
const entranceScaleX = useTransform(mountProgress, [0, 1], [0, 1]);
|
|
269
|
+
const rings = Array.from({ length: layers }, (_, l) => {
|
|
270
|
+
const scale = 1 - l / layers * 0.35;
|
|
271
|
+
const opacity = 0.18 + l / (layers - 1 || 1) * 0.65;
|
|
272
|
+
return {
|
|
273
|
+
d: vSegmentPath(normStart, normEnd, segH, fullW, scale, straight),
|
|
274
|
+
opacity
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
return /* @__PURE__ */ jsx(
|
|
278
|
+
m.div,
|
|
279
|
+
{
|
|
280
|
+
animate: { opacity: dimmed ? 0.4 : 1 },
|
|
281
|
+
className: "pointer-events-none relative shrink-0 overflow-visible",
|
|
282
|
+
style: {
|
|
283
|
+
width: fullW,
|
|
284
|
+
height: segH,
|
|
285
|
+
zIndex: hovered ? 10 : 1
|
|
286
|
+
},
|
|
287
|
+
transition: { opacity: { duration: 0.15 } },
|
|
288
|
+
children: enterComplete ? /* @__PURE__ */ jsx("div", { className: "absolute inset-0 overflow-visible", children: /* @__PURE__ */ jsxs(
|
|
289
|
+
"svg",
|
|
290
|
+
{
|
|
291
|
+
"aria-hidden": "true",
|
|
292
|
+
className: "absolute inset-0 h-full w-full overflow-visible",
|
|
293
|
+
preserveAspectRatio: "none",
|
|
294
|
+
role: "presentation",
|
|
295
|
+
viewBox: `0 0 ${fullW} ${segH}`,
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
298
|
+
gradientStops && /* @__PURE__ */ jsx("linearGradient", { id: gradientId, x1: "0", x2: "0", y1: "0", y2: "1", children: gradientStops.map((stop) => /* @__PURE__ */ jsx(
|
|
299
|
+
"stop",
|
|
300
|
+
{
|
|
301
|
+
offset: typeof stop.offset === "number" ? `${stop.offset * 100}%` : stop.offset,
|
|
302
|
+
stopColor: stop.color
|
|
303
|
+
},
|
|
304
|
+
`${stop.offset}-${stop.color}`
|
|
305
|
+
)) }),
|
|
306
|
+
renderPattern?.(patternId, color)
|
|
307
|
+
] }),
|
|
308
|
+
rings.map((r, i) => {
|
|
309
|
+
const isInnermost = i === rings.length - 1;
|
|
310
|
+
let ringFill;
|
|
311
|
+
if (isInnermost && renderPattern) {
|
|
312
|
+
ringFill = `url(#${patternId})`;
|
|
313
|
+
} else if (isInnermost && gradientStops) {
|
|
314
|
+
ringFill = `url(#${gradientId})`;
|
|
315
|
+
}
|
|
316
|
+
const ringKey = `v-ring-${r.opacity.toFixed(2)}`;
|
|
317
|
+
return /* @__PURE__ */ jsx(
|
|
318
|
+
VRing,
|
|
319
|
+
{
|
|
320
|
+
color,
|
|
321
|
+
d: r.d,
|
|
322
|
+
fill: ringFill,
|
|
323
|
+
hovered,
|
|
324
|
+
opacity: r.opacity,
|
|
325
|
+
ringIndex: i,
|
|
326
|
+
totalRings: layers
|
|
327
|
+
},
|
|
328
|
+
ringKey
|
|
329
|
+
);
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
) }) : /* @__PURE__ */ jsx(
|
|
334
|
+
m.div,
|
|
335
|
+
{
|
|
336
|
+
className: "absolute inset-0 overflow-visible",
|
|
337
|
+
style: {
|
|
338
|
+
scaleY: entranceScaleY,
|
|
339
|
+
scaleX: entranceScaleX,
|
|
340
|
+
transformOrigin: "center top"
|
|
341
|
+
},
|
|
342
|
+
children: /* @__PURE__ */ jsxs(
|
|
343
|
+
"svg",
|
|
344
|
+
{
|
|
345
|
+
"aria-hidden": "true",
|
|
346
|
+
className: "absolute inset-0 h-full w-full overflow-visible",
|
|
347
|
+
preserveAspectRatio: "none",
|
|
348
|
+
role: "presentation",
|
|
349
|
+
viewBox: `0 0 ${fullW} ${segH}`,
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
352
|
+
gradientStops && /* @__PURE__ */ jsx("linearGradient", { id: gradientId, x1: "0", x2: "0", y1: "0", y2: "1", children: gradientStops.map((stop) => /* @__PURE__ */ jsx(
|
|
353
|
+
"stop",
|
|
354
|
+
{
|
|
355
|
+
offset: typeof stop.offset === "number" ? `${stop.offset * 100}%` : stop.offset,
|
|
356
|
+
stopColor: stop.color
|
|
357
|
+
},
|
|
358
|
+
`${stop.offset}-${stop.color}`
|
|
359
|
+
)) }),
|
|
360
|
+
renderPattern?.(patternId, color)
|
|
361
|
+
] }),
|
|
362
|
+
rings.map((r, i) => {
|
|
363
|
+
const isInnermost = i === rings.length - 1;
|
|
364
|
+
let ringFill;
|
|
365
|
+
if (isInnermost && renderPattern) {
|
|
366
|
+
ringFill = `url(#${patternId})`;
|
|
367
|
+
} else if (isInnermost && gradientStops) {
|
|
368
|
+
ringFill = `url(#${gradientId})`;
|
|
369
|
+
}
|
|
370
|
+
const ringKey = `v-ring-${r.opacity.toFixed(2)}`;
|
|
371
|
+
return /* @__PURE__ */ jsx(
|
|
372
|
+
VRing,
|
|
373
|
+
{
|
|
374
|
+
color,
|
|
375
|
+
d: r.d,
|
|
376
|
+
fill: ringFill,
|
|
377
|
+
hovered,
|
|
378
|
+
opacity: r.opacity,
|
|
379
|
+
ringIndex: i,
|
|
380
|
+
totalRings: layers
|
|
381
|
+
},
|
|
382
|
+
ringKey
|
|
383
|
+
);
|
|
384
|
+
})
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
function SegmentLabel({
|
|
394
|
+
stage,
|
|
395
|
+
pct,
|
|
396
|
+
isHorizontal,
|
|
397
|
+
showValues,
|
|
398
|
+
showPercentage,
|
|
399
|
+
showLabels,
|
|
400
|
+
formatPercentage,
|
|
401
|
+
formatValue,
|
|
402
|
+
index,
|
|
403
|
+
staggerDelay,
|
|
404
|
+
layout = "spread",
|
|
405
|
+
orientation,
|
|
406
|
+
align = "center"
|
|
407
|
+
}) {
|
|
408
|
+
const display = stage.displayValue ?? formatValue(stage.value);
|
|
409
|
+
const valueEl = showValues && /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap font-semibold text-chart-foreground text-sm", children: display });
|
|
410
|
+
const pctEl = showPercentage && /* @__PURE__ */ jsx("span", { className: "rounded-full bg-chart-foreground px-3 py-1 font-bold text-chart-background text-xs shadow-sm", children: formatPercentage(pct) });
|
|
411
|
+
const labelEl = showLabels && /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap font-medium text-chart-foreground-muted text-xs", children: stage.label });
|
|
412
|
+
if (layout === "spread") {
|
|
413
|
+
return /* @__PURE__ */ jsx(
|
|
414
|
+
m.div,
|
|
415
|
+
{
|
|
416
|
+
animate: { opacity: 1 },
|
|
417
|
+
className: cn(
|
|
418
|
+
"absolute inset-0 flex",
|
|
419
|
+
isHorizontal ? "flex-col items-center" : "flex-row items-center"
|
|
420
|
+
),
|
|
421
|
+
initial: { opacity: 0 },
|
|
422
|
+
transition: {
|
|
423
|
+
delay: index * staggerDelay + 0.25,
|
|
424
|
+
duration: 0.35,
|
|
425
|
+
ease: "easeOut"
|
|
426
|
+
},
|
|
427
|
+
children: isHorizontal ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
428
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-[16%] items-end justify-center pb-1", children: valueEl }),
|
|
429
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: pctEl }),
|
|
430
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-[16%] items-start justify-center pt-1", children: labelEl })
|
|
431
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
432
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-[16%] items-center justify-end pr-2", children: valueEl }),
|
|
433
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: pctEl }),
|
|
434
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-[16%] items-center justify-start pl-2", children: labelEl })
|
|
435
|
+
] })
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
const resolvedOrientation = orientation ?? (isHorizontal ? "vertical" : "horizontal");
|
|
440
|
+
const isVerticalStack = resolvedOrientation === "vertical";
|
|
441
|
+
const justifyMap = {
|
|
442
|
+
start: "justify-start",
|
|
443
|
+
center: "justify-center",
|
|
444
|
+
end: "justify-end"
|
|
445
|
+
};
|
|
446
|
+
const itemsMap = {
|
|
447
|
+
start: "items-start",
|
|
448
|
+
center: "items-center",
|
|
449
|
+
end: "items-end"
|
|
450
|
+
};
|
|
451
|
+
return /* @__PURE__ */ jsx(
|
|
452
|
+
m.div,
|
|
453
|
+
{
|
|
454
|
+
animate: { opacity: 1 },
|
|
455
|
+
className: cn(
|
|
456
|
+
"absolute inset-0 flex",
|
|
457
|
+
// For horizontal funnel, align controls vertical placement
|
|
458
|
+
// For vertical funnel, align controls horizontal placement
|
|
459
|
+
isHorizontal ? cn("flex-col items-center", justifyMap[align]) : cn("flex-row items-center", justifyMap[align])
|
|
460
|
+
),
|
|
461
|
+
initial: { opacity: 0 },
|
|
462
|
+
style: {
|
|
463
|
+
padding: isHorizontal ? "8% 0" : "0 8%"
|
|
464
|
+
},
|
|
465
|
+
transition: {
|
|
466
|
+
delay: index * staggerDelay + 0.25,
|
|
467
|
+
duration: 0.35,
|
|
468
|
+
ease: "easeOut"
|
|
469
|
+
},
|
|
470
|
+
children: /* @__PURE__ */ jsxs(
|
|
471
|
+
"div",
|
|
472
|
+
{
|
|
473
|
+
className: cn(
|
|
474
|
+
"flex gap-1.5",
|
|
475
|
+
isVerticalStack ? cn("flex-col", itemsMap[isHorizontal ? "center" : align]) : cn("flex-row", itemsMap.center)
|
|
476
|
+
),
|
|
477
|
+
children: [
|
|
478
|
+
valueEl,
|
|
479
|
+
pctEl,
|
|
480
|
+
labelEl
|
|
481
|
+
]
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
function FunnelChart({
|
|
488
|
+
data: dataProp,
|
|
489
|
+
orientation = "horizontal",
|
|
490
|
+
color = "var(--chart-1)",
|
|
491
|
+
layers = 3,
|
|
492
|
+
className,
|
|
493
|
+
style,
|
|
494
|
+
showPercentage = true,
|
|
495
|
+
showValues = true,
|
|
496
|
+
showLabels = true,
|
|
497
|
+
hoveredIndex: hoveredIndexProp,
|
|
498
|
+
onHoverChange,
|
|
499
|
+
formatPercentage = fmtPct,
|
|
500
|
+
formatValue = fmtVal,
|
|
501
|
+
staggerDelay = 0.12,
|
|
502
|
+
enterTransition,
|
|
503
|
+
gap = 4,
|
|
504
|
+
renderPattern,
|
|
505
|
+
edges = "curved",
|
|
506
|
+
labelLayout = "spread",
|
|
507
|
+
labelOrientation,
|
|
508
|
+
labelAlign = "center",
|
|
509
|
+
grid: gridProp = false
|
|
510
|
+
}) {
|
|
511
|
+
const { data } = useChartDataOverride("FunnelChart", {
|
|
512
|
+
data: dataProp
|
|
513
|
+
});
|
|
514
|
+
const ref = useRef(null);
|
|
515
|
+
const [sz, setSz] = useState({ w: 0, h: 0 });
|
|
516
|
+
const [internalHoveredIndex, setInternalHoveredIndex] = useState(null);
|
|
517
|
+
const isControlled = hoveredIndexProp !== void 0;
|
|
518
|
+
const hoveredIndex = isControlled ? hoveredIndexProp : internalHoveredIndex;
|
|
519
|
+
const setHoveredIndex = useCallback(
|
|
520
|
+
(index) => {
|
|
521
|
+
if (isControlled) {
|
|
522
|
+
onHoverChange?.(index);
|
|
523
|
+
} else {
|
|
524
|
+
setInternalHoveredIndex(index);
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
[isControlled, onHoverChange]
|
|
528
|
+
);
|
|
529
|
+
const measure = useCallback(() => {
|
|
530
|
+
if (!ref.current) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const { offsetWidth: w, offsetHeight: h } = ref.current;
|
|
534
|
+
if (w > 0 && h > 0) {
|
|
535
|
+
setSz({ w, h });
|
|
536
|
+
}
|
|
537
|
+
}, []);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
measure();
|
|
540
|
+
const ro = new ResizeObserver(measure);
|
|
541
|
+
if (ref.current) {
|
|
542
|
+
ro.observe(ref.current);
|
|
543
|
+
}
|
|
544
|
+
return () => ro.disconnect();
|
|
545
|
+
}, [measure]);
|
|
546
|
+
if (!data.length) {
|
|
547
|
+
return null;
|
|
548
|
+
}
|
|
549
|
+
const first = data[0];
|
|
550
|
+
if (!first) {
|
|
551
|
+
return null;
|
|
552
|
+
}
|
|
553
|
+
const max = first.value;
|
|
554
|
+
const n = data.length;
|
|
555
|
+
const norms = data.map((d) => d.value / max);
|
|
556
|
+
const horiz = orientation === "horizontal";
|
|
557
|
+
const { w: W, h: H } = sz;
|
|
558
|
+
const totalGap = gap * (n - 1);
|
|
559
|
+
const segW = (W - (horiz ? totalGap : 0)) / n;
|
|
560
|
+
const segH = (H - (horiz ? 0 : totalGap)) / n;
|
|
561
|
+
const gridEnabled = gridProp !== false;
|
|
562
|
+
const gridCfg = typeof gridProp === "object" ? gridProp : {};
|
|
563
|
+
const showBands = gridEnabled && (gridCfg.bands ?? true);
|
|
564
|
+
const bandColor = gridCfg.bandColor ?? "var(--chart-muted)";
|
|
565
|
+
const showGridLines = gridEnabled && (gridCfg.lines ?? true);
|
|
566
|
+
const gridLineColor = gridCfg.lineColor ?? "var(--chart-grid)";
|
|
567
|
+
const gridLineOpacity = gridCfg.lineOpacity ?? 1;
|
|
568
|
+
const gridLineWidth = gridCfg.lineWidth ?? 1;
|
|
569
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
570
|
+
"div",
|
|
571
|
+
{
|
|
572
|
+
className: cn(
|
|
573
|
+
"relative w-full select-none overflow-visible",
|
|
574
|
+
className
|
|
575
|
+
),
|
|
576
|
+
ref,
|
|
577
|
+
style: {
|
|
578
|
+
aspectRatio: horiz ? "2.2 / 1" : "1 / 1.8",
|
|
579
|
+
...style
|
|
580
|
+
},
|
|
581
|
+
children: W > 0 && H > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
582
|
+
gridEnabled && /* @__PURE__ */ jsx(
|
|
583
|
+
"svg",
|
|
584
|
+
{
|
|
585
|
+
"aria-hidden": "true",
|
|
586
|
+
className: "pointer-events-none absolute inset-0 h-full w-full",
|
|
587
|
+
preserveAspectRatio: "none",
|
|
588
|
+
role: "presentation",
|
|
589
|
+
viewBox: `0 0 ${W} ${H}`,
|
|
590
|
+
children: showBands && data.map((stage, i) => {
|
|
591
|
+
if (i % 2 !== 0) {
|
|
592
|
+
return null;
|
|
593
|
+
}
|
|
594
|
+
if (horiz) {
|
|
595
|
+
const x = (segW + gap) * i;
|
|
596
|
+
return /* @__PURE__ */ jsx(
|
|
597
|
+
"rect",
|
|
598
|
+
{
|
|
599
|
+
fill: bandColor,
|
|
600
|
+
height: H,
|
|
601
|
+
width: segW,
|
|
602
|
+
x,
|
|
603
|
+
y: 0
|
|
604
|
+
},
|
|
605
|
+
`band-${stage.label}`
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
const y = (segH + gap) * i;
|
|
609
|
+
return /* @__PURE__ */ jsx(
|
|
610
|
+
"rect",
|
|
611
|
+
{
|
|
612
|
+
fill: bandColor,
|
|
613
|
+
height: segH,
|
|
614
|
+
width: W,
|
|
615
|
+
x: 0,
|
|
616
|
+
y
|
|
617
|
+
},
|
|
618
|
+
`band-${stage.label}`
|
|
619
|
+
);
|
|
620
|
+
})
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ jsx(
|
|
624
|
+
"div",
|
|
625
|
+
{
|
|
626
|
+
className: cn(
|
|
627
|
+
"absolute inset-0 flex overflow-visible",
|
|
628
|
+
horiz ? "flex-row" : "flex-col"
|
|
629
|
+
),
|
|
630
|
+
style: { gap },
|
|
631
|
+
children: data.map((stage, i) => {
|
|
632
|
+
const normStart = norms[i] ?? 0;
|
|
633
|
+
const normEnd = norms[Math.min(i + 1, n - 1)] ?? 0;
|
|
634
|
+
const firstStop = stage.gradient?.[0];
|
|
635
|
+
const segColor = firstStop ? firstStop.color : stage.color ?? color;
|
|
636
|
+
return horiz ? /* @__PURE__ */ jsx(
|
|
637
|
+
HSegment,
|
|
638
|
+
{
|
|
639
|
+
color: segColor,
|
|
640
|
+
dimmed: hoveredIndex !== null && hoveredIndex !== i,
|
|
641
|
+
enterTransition,
|
|
642
|
+
fullH: H,
|
|
643
|
+
gradientStops: stage.gradient,
|
|
644
|
+
hovered: hoveredIndex === i,
|
|
645
|
+
index: i,
|
|
646
|
+
layers,
|
|
647
|
+
normEnd,
|
|
648
|
+
normStart,
|
|
649
|
+
renderPattern,
|
|
650
|
+
segW,
|
|
651
|
+
staggerDelay,
|
|
652
|
+
straight: edges === "straight"
|
|
653
|
+
},
|
|
654
|
+
stage.label
|
|
655
|
+
) : /* @__PURE__ */ jsx(
|
|
656
|
+
VSegment,
|
|
657
|
+
{
|
|
658
|
+
color: segColor,
|
|
659
|
+
dimmed: hoveredIndex !== null && hoveredIndex !== i,
|
|
660
|
+
enterTransition,
|
|
661
|
+
fullW: W,
|
|
662
|
+
gradientStops: stage.gradient,
|
|
663
|
+
hovered: hoveredIndex === i,
|
|
664
|
+
index: i,
|
|
665
|
+
layers,
|
|
666
|
+
normEnd,
|
|
667
|
+
normStart,
|
|
668
|
+
renderPattern,
|
|
669
|
+
segH,
|
|
670
|
+
staggerDelay,
|
|
671
|
+
straight: edges === "straight"
|
|
672
|
+
},
|
|
673
|
+
stage.label
|
|
674
|
+
);
|
|
675
|
+
})
|
|
676
|
+
}
|
|
677
|
+
),
|
|
678
|
+
gridEnabled && showGridLines && /* @__PURE__ */ jsx(
|
|
679
|
+
"svg",
|
|
680
|
+
{
|
|
681
|
+
"aria-hidden": "true",
|
|
682
|
+
className: "pointer-events-none absolute inset-0 h-full w-full",
|
|
683
|
+
preserveAspectRatio: "none",
|
|
684
|
+
role: "presentation",
|
|
685
|
+
viewBox: `0 0 ${W} ${H}`,
|
|
686
|
+
children: Array.from({ length: n - 1 }, (_, i) => {
|
|
687
|
+
const idx = i + 1;
|
|
688
|
+
const gridKey = `grid-${idx}`;
|
|
689
|
+
if (horiz) {
|
|
690
|
+
const x = segW * idx + gap * i + gap / 2;
|
|
691
|
+
return /* @__PURE__ */ jsx(
|
|
692
|
+
"line",
|
|
693
|
+
{
|
|
694
|
+
stroke: gridLineColor,
|
|
695
|
+
strokeOpacity: gridLineOpacity,
|
|
696
|
+
strokeWidth: gridLineWidth,
|
|
697
|
+
x1: x,
|
|
698
|
+
x2: x,
|
|
699
|
+
y1: 0,
|
|
700
|
+
y2: H
|
|
701
|
+
},
|
|
702
|
+
gridKey
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
const y = segH * idx + gap * i + gap / 2;
|
|
706
|
+
return /* @__PURE__ */ jsx(
|
|
707
|
+
"line",
|
|
708
|
+
{
|
|
709
|
+
stroke: gridLineColor,
|
|
710
|
+
strokeOpacity: gridLineOpacity,
|
|
711
|
+
strokeWidth: gridLineWidth,
|
|
712
|
+
x1: 0,
|
|
713
|
+
x2: W,
|
|
714
|
+
y1: y,
|
|
715
|
+
y2: y
|
|
716
|
+
},
|
|
717
|
+
gridKey
|
|
718
|
+
);
|
|
719
|
+
})
|
|
720
|
+
}
|
|
721
|
+
),
|
|
722
|
+
data.map((stage, i) => {
|
|
723
|
+
const pct = stage.value / max * 100;
|
|
724
|
+
const posStyle = horiz ? {
|
|
725
|
+
left: (segW + gap) * i,
|
|
726
|
+
width: segW,
|
|
727
|
+
top: 0,
|
|
728
|
+
height: H
|
|
729
|
+
} : {
|
|
730
|
+
top: (segH + gap) * i,
|
|
731
|
+
height: segH,
|
|
732
|
+
left: 0,
|
|
733
|
+
width: W
|
|
734
|
+
};
|
|
735
|
+
const isDimmed = hoveredIndex !== null && hoveredIndex !== i;
|
|
736
|
+
return /* @__PURE__ */ jsx(
|
|
737
|
+
m.div,
|
|
738
|
+
{
|
|
739
|
+
animate: { opacity: isDimmed ? 0.4 : 1 },
|
|
740
|
+
className: "absolute cursor-pointer",
|
|
741
|
+
onMouseEnter: () => setHoveredIndex(i),
|
|
742
|
+
onMouseLeave: () => setHoveredIndex(null),
|
|
743
|
+
style: { ...posStyle, zIndex: 20 },
|
|
744
|
+
transition: { type: "spring", stiffness: 300, damping: 24 },
|
|
745
|
+
children: /* @__PURE__ */ jsx(
|
|
746
|
+
SegmentLabel,
|
|
747
|
+
{
|
|
748
|
+
align: labelAlign,
|
|
749
|
+
formatPercentage,
|
|
750
|
+
formatValue,
|
|
751
|
+
index: i,
|
|
752
|
+
isHorizontal: horiz,
|
|
753
|
+
layout: labelLayout,
|
|
754
|
+
orientation: labelOrientation,
|
|
755
|
+
pct,
|
|
756
|
+
showLabels,
|
|
757
|
+
showPercentage,
|
|
758
|
+
showValues,
|
|
759
|
+
stage,
|
|
760
|
+
staggerDelay
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
},
|
|
764
|
+
`lbl-${stage.label}`
|
|
765
|
+
);
|
|
766
|
+
})
|
|
767
|
+
] })
|
|
768
|
+
}
|
|
769
|
+
) });
|
|
770
|
+
}
|
|
771
|
+
export {
|
|
772
|
+
FunnelChart
|
|
773
|
+
};
|