@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,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m, useTransform } from "motion/react";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { DEFAULT_CHART_ENTER_TRANSITION } from "./animation";
|
|
6
|
+
import {
|
|
7
|
+
applyHoverGrow,
|
|
8
|
+
geomCentroidAngle,
|
|
9
|
+
geomCentroidRadius,
|
|
10
|
+
transitionGeometry
|
|
11
|
+
} from "./sunburst";
|
|
12
|
+
import { sunburstCssVars, useSunburstStable } from "./sunburst-context";
|
|
13
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
14
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
15
|
+
const SunburstLabels = memo(function SunburstLabels2({
|
|
16
|
+
fontSize = 11,
|
|
17
|
+
fill = sunburstCssVars.label,
|
|
18
|
+
stroke = sunburstCssVars.background,
|
|
19
|
+
strokeWidth = 2.5,
|
|
20
|
+
className
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
arcs,
|
|
24
|
+
focus,
|
|
25
|
+
prevFocus,
|
|
26
|
+
maxDepth,
|
|
27
|
+
radius,
|
|
28
|
+
zoomT,
|
|
29
|
+
enterTiming,
|
|
30
|
+
enterTransition,
|
|
31
|
+
playKey,
|
|
32
|
+
skipEnterAnimation,
|
|
33
|
+
growAmountForArc,
|
|
34
|
+
isRelated,
|
|
35
|
+
maxExpandedThickness
|
|
36
|
+
} = useSunburstStable();
|
|
37
|
+
const enterDuration = typeof enterTransition?.duration === "number" ? enterTransition.duration : DEFAULT_CHART_ENTER_TRANSITION.duration;
|
|
38
|
+
const labelsDelay = enterTiming.maxDelay + enterDuration * 0.85;
|
|
39
|
+
const labelsProgress = useMountProgress(
|
|
40
|
+
enterTransition,
|
|
41
|
+
labelsDelay,
|
|
42
|
+
`${playKey}-labels`
|
|
43
|
+
);
|
|
44
|
+
const labelsComplete = useEnterComplete(labelsProgress);
|
|
45
|
+
const labelOpacity = useTransform(labelsProgress, [0, 1], [0, 1]);
|
|
46
|
+
const showLabels = skipEnterAnimation || labelsComplete;
|
|
47
|
+
return /* @__PURE__ */ jsx("g", { className, children: arcs.map((arc) => {
|
|
48
|
+
const base = transitionGeometry(
|
|
49
|
+
arc,
|
|
50
|
+
prevFocus,
|
|
51
|
+
focus,
|
|
52
|
+
maxDepth,
|
|
53
|
+
radius,
|
|
54
|
+
zoomT
|
|
55
|
+
);
|
|
56
|
+
if (!base) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const g = applyHoverGrow(
|
|
60
|
+
base,
|
|
61
|
+
arc.id,
|
|
62
|
+
growAmountForArc,
|
|
63
|
+
maxExpandedThickness
|
|
64
|
+
);
|
|
65
|
+
const angleSpan = g.a1 - g.a0;
|
|
66
|
+
const r = geomCentroidRadius(g);
|
|
67
|
+
if (angleSpan * r < 26 || g.outerR - g.innerR < 16) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (!isRelated(arc)) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const mid = geomCentroidAngle(g);
|
|
74
|
+
const x = Math.sin(mid) * r;
|
|
75
|
+
const y = -Math.cos(mid) * r;
|
|
76
|
+
let deg = mid * 180 / Math.PI - 90;
|
|
77
|
+
if (deg > 90) {
|
|
78
|
+
deg -= 180;
|
|
79
|
+
}
|
|
80
|
+
if (deg < -90) {
|
|
81
|
+
deg += 180;
|
|
82
|
+
}
|
|
83
|
+
const labelStyle = {
|
|
84
|
+
fill,
|
|
85
|
+
fontFamily: "inherit",
|
|
86
|
+
fontSize,
|
|
87
|
+
fontWeight: 600
|
|
88
|
+
};
|
|
89
|
+
if (strokeWidth > 0) {
|
|
90
|
+
labelStyle.paintOrder = "stroke";
|
|
91
|
+
labelStyle.stroke = stroke;
|
|
92
|
+
labelStyle.strokeLinejoin = "round";
|
|
93
|
+
labelStyle.strokeWidth = strokeWidth;
|
|
94
|
+
}
|
|
95
|
+
if (showLabels) {
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
"text",
|
|
98
|
+
{
|
|
99
|
+
dominantBaseline: "middle",
|
|
100
|
+
pointerEvents: "none",
|
|
101
|
+
style: { ...labelStyle, opacity: 1 },
|
|
102
|
+
textAnchor: "middle",
|
|
103
|
+
transform: `rotate(${deg} ${x} ${y})`,
|
|
104
|
+
x,
|
|
105
|
+
y,
|
|
106
|
+
children: arc.name
|
|
107
|
+
},
|
|
108
|
+
`label-${arc.id}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return /* @__PURE__ */ jsx(
|
|
112
|
+
m.text,
|
|
113
|
+
{
|
|
114
|
+
dominantBaseline: "middle",
|
|
115
|
+
pointerEvents: "none",
|
|
116
|
+
style: { ...labelStyle, opacity: labelOpacity },
|
|
117
|
+
textAnchor: "middle",
|
|
118
|
+
transform: `rotate(${deg} ${x} ${y})`,
|
|
119
|
+
x,
|
|
120
|
+
y,
|
|
121
|
+
children: arc.name
|
|
122
|
+
},
|
|
123
|
+
`label-${arc.id}`
|
|
124
|
+
);
|
|
125
|
+
}) });
|
|
126
|
+
});
|
|
127
|
+
SunburstLabels.displayName = "SunburstLabels";
|
|
128
|
+
export {
|
|
129
|
+
SunburstLabels
|
|
130
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m, useTransform } from "motion/react";
|
|
4
|
+
import { memo, useMemo } from "react";
|
|
5
|
+
import { applyHoverGrow, arcPath, transitionGeometry } from "./sunburst";
|
|
6
|
+
import {
|
|
7
|
+
sunburstCssVars,
|
|
8
|
+
useSunburstHover,
|
|
9
|
+
useSunburstStable
|
|
10
|
+
} from "./sunburst-context";
|
|
11
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
12
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
13
|
+
const HOVER_DIM_TRANSITION = { duration: 0.16, ease: "easeOut" };
|
|
14
|
+
const SunburstSegment = memo(function SunburstSegment2({
|
|
15
|
+
index,
|
|
16
|
+
color: colorProp,
|
|
17
|
+
fill: fillProp,
|
|
18
|
+
fillOpacity: fillOpacityProp
|
|
19
|
+
}) {
|
|
20
|
+
const {
|
|
21
|
+
arcs,
|
|
22
|
+
focus,
|
|
23
|
+
prevFocus,
|
|
24
|
+
maxDepth,
|
|
25
|
+
radius,
|
|
26
|
+
zoomT,
|
|
27
|
+
enterTiming,
|
|
28
|
+
enterTransition,
|
|
29
|
+
playKey,
|
|
30
|
+
skipEnterAnimation,
|
|
31
|
+
growAmountForArc,
|
|
32
|
+
getFill,
|
|
33
|
+
getFillOpacity,
|
|
34
|
+
isRelated,
|
|
35
|
+
maxExpandedThickness,
|
|
36
|
+
zoomTo
|
|
37
|
+
} = useSunburstStable();
|
|
38
|
+
const { setHoveredArc, setHoveredArcIndex } = useSunburstHover();
|
|
39
|
+
const arc = arcs[index];
|
|
40
|
+
const segmentDelay = (arc ? enterTiming.segmentDelays.get(arc.id)?.delay : void 0) ?? 0;
|
|
41
|
+
const replayId = arc?.id ?? `missing-${index}`;
|
|
42
|
+
const base = useMemo(() => {
|
|
43
|
+
if (!arc) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return transitionGeometry(arc, prevFocus, focus, maxDepth, radius, zoomT);
|
|
47
|
+
}, [arc, prevFocus, focus, maxDepth, radius, zoomT]);
|
|
48
|
+
const visualGeometry = useMemo(() => {
|
|
49
|
+
if (!(arc && base)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return applyHoverGrow(base, arc.id, growAmountForArc, maxExpandedThickness);
|
|
53
|
+
}, [arc, base, growAmountForArc, maxExpandedThickness]);
|
|
54
|
+
const enterProgress = useMountProgress(
|
|
55
|
+
enterTransition,
|
|
56
|
+
segmentDelay,
|
|
57
|
+
`${playKey}-enter-${replayId}`
|
|
58
|
+
);
|
|
59
|
+
const enterComplete = useEnterComplete(enterProgress);
|
|
60
|
+
const enterScale = useTransform(enterProgress, [0, 1], [0, 1]);
|
|
61
|
+
const animatedHitPath = useTransform(
|
|
62
|
+
enterProgress,
|
|
63
|
+
(value) => base ? arcPath(base, value, 1) ?? "" : ""
|
|
64
|
+
);
|
|
65
|
+
const animatedVisualPath = useTransform(
|
|
66
|
+
enterProgress,
|
|
67
|
+
(value) => visualGeometry ? arcPath(visualGeometry, value, 1) ?? "" : ""
|
|
68
|
+
);
|
|
69
|
+
if (!arc) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
if (!base) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const showStatic = skipEnterAnimation || enterComplete;
|
|
76
|
+
const fullHitPath = arcPath(base, 1, 1);
|
|
77
|
+
const fullVisualPath = visualGeometry ? arcPath(visualGeometry, 1, 1) : null;
|
|
78
|
+
if (!(fullHitPath && fullVisualPath)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const relativeDepth = arc.depth - focus.depth;
|
|
82
|
+
const segmentFill = getFill(index, fillProp, colorProp);
|
|
83
|
+
const fillOpacity = fillOpacityProp ?? getFillOpacity(relativeDepth);
|
|
84
|
+
const related = isRelated(arc);
|
|
85
|
+
const layerOpacity = related ? 1 : 0.25;
|
|
86
|
+
const groupStyle = {
|
|
87
|
+
cursor: arc.hasChildren ? "pointer" : "default",
|
|
88
|
+
transformOrigin: "0px 0px"
|
|
89
|
+
};
|
|
90
|
+
const hitHandlers = {
|
|
91
|
+
onClick: () => arc.hasChildren && zoomTo(arc.id),
|
|
92
|
+
onPointerEnter: () => {
|
|
93
|
+
setHoveredArc(arc);
|
|
94
|
+
setHoveredArcIndex(index);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const visualPathProps = {
|
|
98
|
+
fill: segmentFill,
|
|
99
|
+
fillOpacity,
|
|
100
|
+
pointerEvents: "none",
|
|
101
|
+
stroke: sunburstCssVars.ring,
|
|
102
|
+
strokeLinejoin: "round",
|
|
103
|
+
strokeWidth: 1
|
|
104
|
+
};
|
|
105
|
+
if (showStatic) {
|
|
106
|
+
return /* @__PURE__ */ jsxs(
|
|
107
|
+
m.g,
|
|
108
|
+
{
|
|
109
|
+
animate: { opacity: layerOpacity },
|
|
110
|
+
initial: false,
|
|
111
|
+
onClick: hitHandlers.onClick,
|
|
112
|
+
onPointerEnter: hitHandlers.onPointerEnter,
|
|
113
|
+
style: groupStyle,
|
|
114
|
+
transition: { opacity: HOVER_DIM_TRANSITION },
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ jsx("path", { d: fullHitPath, fill: "transparent" }),
|
|
117
|
+
/* @__PURE__ */ jsx("path", { d: fullVisualPath, ...visualPathProps })
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return /* @__PURE__ */ jsxs(
|
|
123
|
+
m.g,
|
|
124
|
+
{
|
|
125
|
+
animate: { opacity: layerOpacity },
|
|
126
|
+
initial: false,
|
|
127
|
+
onClick: hitHandlers.onClick,
|
|
128
|
+
onPointerEnter: hitHandlers.onPointerEnter,
|
|
129
|
+
style: {
|
|
130
|
+
...groupStyle,
|
|
131
|
+
scale: enterScale
|
|
132
|
+
},
|
|
133
|
+
transition: { opacity: HOVER_DIM_TRANSITION },
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(m.path, { d: animatedHitPath, fill: "transparent" }),
|
|
136
|
+
/* @__PURE__ */ jsx(m.path, { d: animatedVisualPath, ...visualPathProps })
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
SunburstSegment.displayName = "SunburstSegment";
|
|
142
|
+
export {
|
|
143
|
+
SunburstSegment
|
|
144
|
+
};
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
const TOP = -Math.PI / 2;
|
|
2
|
+
const TWO_PI = 2 * Math.PI;
|
|
3
|
+
const ID_SEP = " / ";
|
|
4
|
+
const DRILL_CENTER_SCALE = 0.65;
|
|
5
|
+
const DRILL_CENTER_DEPTH_SHRINK = 0.08;
|
|
6
|
+
const HOVER_GROW_RING_BUDGET = 0.28;
|
|
7
|
+
const HOVER_GROW_SEGMENT_CAP = 0.1;
|
|
8
|
+
function nodeId(parentId, name) {
|
|
9
|
+
return parentId ? `${parentId}${ID_SEP}${name}` : name;
|
|
10
|
+
}
|
|
11
|
+
function sumValues(node) {
|
|
12
|
+
if (node.children?.length) {
|
|
13
|
+
return node.children.reduce((sum, child) => sum + sumValues(child), 0);
|
|
14
|
+
}
|
|
15
|
+
return node.value ?? 0;
|
|
16
|
+
}
|
|
17
|
+
function layoutNode(node, id, depth, a0, a1, parentId, categoryIndex, trail, ctx) {
|
|
18
|
+
const value = sumValues(node);
|
|
19
|
+
const hasChildren = Boolean(node.children?.length);
|
|
20
|
+
if (depth > 0) {
|
|
21
|
+
ctx.arcs.push({
|
|
22
|
+
id,
|
|
23
|
+
name: node.name,
|
|
24
|
+
depth,
|
|
25
|
+
value,
|
|
26
|
+
categoryIndex,
|
|
27
|
+
hasChildren,
|
|
28
|
+
trail: [...trail, node.name],
|
|
29
|
+
parentId,
|
|
30
|
+
a0,
|
|
31
|
+
a1,
|
|
32
|
+
arcIndex: ctx.arcIndex,
|
|
33
|
+
color: node.color,
|
|
34
|
+
fill: node.fill
|
|
35
|
+
});
|
|
36
|
+
ctx.arcIndex += 1;
|
|
37
|
+
}
|
|
38
|
+
ctx.focusById.set(id, {
|
|
39
|
+
id,
|
|
40
|
+
name: node.name,
|
|
41
|
+
depth,
|
|
42
|
+
parentId,
|
|
43
|
+
categoryIndex,
|
|
44
|
+
a0,
|
|
45
|
+
a1
|
|
46
|
+
});
|
|
47
|
+
ctx.maxDepth = Math.max(ctx.maxDepth, depth);
|
|
48
|
+
if (!(hasChildren && node.children?.length)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const span = a1 - a0;
|
|
52
|
+
let cursor = a0;
|
|
53
|
+
for (const [index, child] of node.children.entries()) {
|
|
54
|
+
const childValue = sumValues(child);
|
|
55
|
+
const childSpan = value > 0 ? childValue / value * span : 0;
|
|
56
|
+
const childId = nodeId(id, child.name);
|
|
57
|
+
const childCategory = depth === 0 ? index : categoryIndex;
|
|
58
|
+
layoutNode(
|
|
59
|
+
child,
|
|
60
|
+
childId,
|
|
61
|
+
depth + 1,
|
|
62
|
+
cursor,
|
|
63
|
+
cursor + childSpan,
|
|
64
|
+
id,
|
|
65
|
+
childCategory,
|
|
66
|
+
depth === 0 ? [node.name] : trail,
|
|
67
|
+
ctx
|
|
68
|
+
);
|
|
69
|
+
cursor += childSpan;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function toRadians(normalized) {
|
|
73
|
+
return TOP + normalized * TWO_PI;
|
|
74
|
+
}
|
|
75
|
+
function buildArcs(data) {
|
|
76
|
+
const rootId = data.name;
|
|
77
|
+
const ctx = {
|
|
78
|
+
arcs: [],
|
|
79
|
+
focusById: /* @__PURE__ */ new Map(),
|
|
80
|
+
maxDepth: 0,
|
|
81
|
+
rootId,
|
|
82
|
+
arcIndex: 0
|
|
83
|
+
};
|
|
84
|
+
layoutNode(data, rootId, 0, 0, 1, null, 0, [], ctx);
|
|
85
|
+
for (const arc of ctx.arcs) {
|
|
86
|
+
arc.a0 = toRadians(arc.a0);
|
|
87
|
+
arc.a1 = toRadians(arc.a1);
|
|
88
|
+
}
|
|
89
|
+
for (const focus of ctx.focusById.values()) {
|
|
90
|
+
focus.a0 = toRadians(focus.a0);
|
|
91
|
+
focus.a1 = toRadians(focus.a1);
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
arcs: ctx.arcs,
|
|
95
|
+
maxDepth: ctx.maxDepth,
|
|
96
|
+
total: sumValues(data),
|
|
97
|
+
focusById: ctx.focusById,
|
|
98
|
+
rootId
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function ringOptions(focusDepth, maxDepth, radius) {
|
|
102
|
+
const oneLevelCenterR = radius / maxDepth;
|
|
103
|
+
if (focusDepth === 0) {
|
|
104
|
+
return { centerR: 0, ringWidth: oneLevelCenterR };
|
|
105
|
+
}
|
|
106
|
+
const depthPastFirstDrill = Math.max(0, focusDepth - 1);
|
|
107
|
+
const centerScale = Math.max(
|
|
108
|
+
0.45,
|
|
109
|
+
DRILL_CENTER_SCALE - depthPastFirstDrill * DRILL_CENTER_DEPTH_SHRINK
|
|
110
|
+
);
|
|
111
|
+
const centerR = oneLevelCenterR * centerScale;
|
|
112
|
+
const visibleRings = Math.max(1, maxDepth - focusDepth);
|
|
113
|
+
const ringWidth = (radius - centerR) / visibleRings;
|
|
114
|
+
return { centerR, ringWidth };
|
|
115
|
+
}
|
|
116
|
+
function geometryFor(arc, focus, maxDepth, radius) {
|
|
117
|
+
if (arc.depth <= focus.depth) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
if (arc.id !== focus.id && !arc.id.startsWith(`${focus.id}${ID_SEP}`)) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
const { centerR, ringWidth } = ringOptions(focus.depth, maxDepth, radius);
|
|
124
|
+
const relativeDepth = arc.depth - focus.depth;
|
|
125
|
+
const focusSpan = focus.a1 - focus.a0;
|
|
126
|
+
const mapAngle = (angle) => {
|
|
127
|
+
if (focusSpan <= 1e-9) {
|
|
128
|
+
return TOP;
|
|
129
|
+
}
|
|
130
|
+
return TOP + (angle - focus.a0) / focusSpan * TWO_PI;
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
a0: mapAngle(arc.a0),
|
|
134
|
+
a1: mapAngle(arc.a1),
|
|
135
|
+
innerR: centerR + (relativeDepth - 1) * ringWidth,
|
|
136
|
+
outerR: centerR + relativeDepth * ringWidth
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function lerpGeometry(from, to, progress) {
|
|
140
|
+
const t = Math.min(1, Math.max(0, progress));
|
|
141
|
+
const fromMid = (from.a0 + from.a1) / 2;
|
|
142
|
+
const toMid = (to.a0 + to.a1) / 2;
|
|
143
|
+
const fromHalf = (from.a1 - from.a0) / 2;
|
|
144
|
+
const toHalf = (to.a1 - to.a0) / 2;
|
|
145
|
+
const mid = lerpAngle(fromMid, toMid, t);
|
|
146
|
+
const half = fromHalf + (toHalf - fromHalf) * t;
|
|
147
|
+
return {
|
|
148
|
+
a0: mid - half,
|
|
149
|
+
a1: mid + half,
|
|
150
|
+
innerR: from.innerR + (to.innerR - from.innerR) * t,
|
|
151
|
+
outerR: from.outerR + (to.outerR - from.outerR) * t
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function lerpAngle(from, to, progress) {
|
|
155
|
+
let delta = to - from;
|
|
156
|
+
while (delta > Math.PI) {
|
|
157
|
+
delta -= TWO_PI;
|
|
158
|
+
}
|
|
159
|
+
while (delta < -Math.PI) {
|
|
160
|
+
delta += TWO_PI;
|
|
161
|
+
}
|
|
162
|
+
return from + delta * progress;
|
|
163
|
+
}
|
|
164
|
+
function pointGeometry(source) {
|
|
165
|
+
const mid = (source.a0 + source.a1) / 2;
|
|
166
|
+
const radius = (source.innerR + source.outerR) / 2;
|
|
167
|
+
const pin = Math.max(0, Math.min(radius * 0.12, source.innerR));
|
|
168
|
+
return { a0: mid, a1: mid, innerR: pin, outerR: pin };
|
|
169
|
+
}
|
|
170
|
+
function transitionGeometry(arc, fromFocus, toFocus, maxDepth, radius, progress) {
|
|
171
|
+
const from = geometryFor(arc, fromFocus, maxDepth, radius);
|
|
172
|
+
const to = geometryFor(arc, toFocus, maxDepth, radius);
|
|
173
|
+
if (!(from || to)) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
if (from && to) {
|
|
177
|
+
return lerpGeometry(from, to, progress);
|
|
178
|
+
}
|
|
179
|
+
if (from) {
|
|
180
|
+
return lerpGeometry(from, pointGeometry(from), progress);
|
|
181
|
+
}
|
|
182
|
+
if (to) {
|
|
183
|
+
return lerpGeometry(pointGeometry(to), to, progress);
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
function clockwiseFraction(angle) {
|
|
188
|
+
let normalized = angle - TOP;
|
|
189
|
+
if (normalized < 0) {
|
|
190
|
+
normalized += TWO_PI;
|
|
191
|
+
}
|
|
192
|
+
return normalized / TWO_PI;
|
|
193
|
+
}
|
|
194
|
+
function buildSunburstEnterTiming(arcs, staggerScale = 1) {
|
|
195
|
+
const scale = Math.max(0.25, staggerScale);
|
|
196
|
+
const byDepth = /* @__PURE__ */ new Map();
|
|
197
|
+
for (const arc of arcs) {
|
|
198
|
+
const list = byDepth.get(arc.depth) ?? [];
|
|
199
|
+
list.push(arc);
|
|
200
|
+
byDepth.set(arc.depth, list);
|
|
201
|
+
}
|
|
202
|
+
const segmentDelays = /* @__PURE__ */ new Map();
|
|
203
|
+
let maxDelay = 0;
|
|
204
|
+
for (const [, ringArcs] of byDepth) {
|
|
205
|
+
const sorted = [...ringArcs].sort(
|
|
206
|
+
(a, b) => clockwiseFraction(a.a0) - clockwiseFraction(b.a0)
|
|
207
|
+
);
|
|
208
|
+
const ringIndex = (sorted[0]?.depth ?? 1) - 1;
|
|
209
|
+
for (const [index, arc] of sorted.entries()) {
|
|
210
|
+
const delay = (ringIndex * 0.12 + index * 0.08) * scale;
|
|
211
|
+
segmentDelays.set(arc.id, { delay });
|
|
212
|
+
maxDelay = Math.max(maxDelay, delay);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return { segmentDelays, maxDelay };
|
|
216
|
+
}
|
|
217
|
+
function buildRevealSchedule(arcs, staggerScale = 1) {
|
|
218
|
+
const timing = buildSunburstEnterTiming(arcs, staggerScale);
|
|
219
|
+
const ringStarts = /* @__PURE__ */ new Map();
|
|
220
|
+
for (const arc of arcs) {
|
|
221
|
+
const delays = timing.segmentDelays.get(arc.id);
|
|
222
|
+
if (delays) {
|
|
223
|
+
ringStarts.set(arc.depth, delays.delay);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
ringStarts,
|
|
228
|
+
ringDuration: 0.6,
|
|
229
|
+
segmentsCompleteAt: timing.maxDelay,
|
|
230
|
+
labelsStart: timing.maxDelay + 0.12,
|
|
231
|
+
labelDuration: 0.2
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function segmentRevealFromRingSweep(ringProgress, a0, a1) {
|
|
235
|
+
const radial = Math.min(1, Math.max(0, ringProgress));
|
|
236
|
+
const startF = clockwiseFraction(a0);
|
|
237
|
+
const endF = clockwiseFraction(a1);
|
|
238
|
+
if (ringProgress <= startF) {
|
|
239
|
+
return { angular: 0, radial };
|
|
240
|
+
}
|
|
241
|
+
if (ringProgress >= endF) {
|
|
242
|
+
return { angular: 1, radial };
|
|
243
|
+
}
|
|
244
|
+
const angular = (ringProgress - startF) / Math.max(endF - startF, 1e-9);
|
|
245
|
+
return { angular, radial };
|
|
246
|
+
}
|
|
247
|
+
function buildRevealDelays(arcs) {
|
|
248
|
+
const timing = buildSunburstEnterTiming(arcs);
|
|
249
|
+
const map = /* @__PURE__ */ new Map();
|
|
250
|
+
for (const arc of arcs) {
|
|
251
|
+
map.set(arc.id, timing.segmentDelays.get(arc.id)?.delay ?? 0);
|
|
252
|
+
}
|
|
253
|
+
return map;
|
|
254
|
+
}
|
|
255
|
+
function arcPath(geometry, progress, radialProgress = progress) {
|
|
256
|
+
if (progress <= 0 && radialProgress <= 0) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const p = Math.min(1, Math.max(0, progress));
|
|
260
|
+
const radialP = Math.min(1, Math.max(0, radialProgress));
|
|
261
|
+
const { a0, a1, innerR, outerR } = geometry;
|
|
262
|
+
if (p >= 1 && radialP >= 1) {
|
|
263
|
+
return arcPathFromGeometry(geometry);
|
|
264
|
+
}
|
|
265
|
+
const span = a1 - a0;
|
|
266
|
+
const currentA0 = a0;
|
|
267
|
+
const currentA1 = a0 + span * p;
|
|
268
|
+
const currentInner = innerR < 1 ? 0 : innerR;
|
|
269
|
+
const currentOuter = innerR < 1 ? outerR * radialP : innerR + (outerR - innerR) * radialP;
|
|
270
|
+
return arcPathFromRadii(currentA0, currentA1, currentInner, currentOuter);
|
|
271
|
+
}
|
|
272
|
+
function arcPathFromGeometry(geometry) {
|
|
273
|
+
const { a0, a1, innerR, outerR } = geometry;
|
|
274
|
+
return arcPathFromRadii(a0, a1, innerR, outerR);
|
|
275
|
+
}
|
|
276
|
+
function arcPathFromRadii(currentA0, currentA1, currentInner, currentOuter) {
|
|
277
|
+
if (currentOuter - currentInner < 0.5 || currentA1 - currentA0 < 1e-3) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
const largeArc = currentA1 - currentA0 > Math.PI ? 1 : 0;
|
|
281
|
+
const outerX0 = Math.sin(currentA0) * currentOuter;
|
|
282
|
+
const outerY0 = -Math.cos(currentA0) * currentOuter;
|
|
283
|
+
const outerX1 = Math.sin(currentA1) * currentOuter;
|
|
284
|
+
const outerY1 = -Math.cos(currentA1) * currentOuter;
|
|
285
|
+
if (currentInner < 1) {
|
|
286
|
+
return `M 0 0 L ${outerX0} ${outerY0} A ${currentOuter} ${currentOuter} 0 ${largeArc} 1 ${outerX1} ${outerY1} Z`;
|
|
287
|
+
}
|
|
288
|
+
const innerX1 = Math.sin(currentA1) * currentInner;
|
|
289
|
+
const innerY1 = -Math.cos(currentA1) * currentInner;
|
|
290
|
+
const innerX0 = Math.sin(currentA0) * currentInner;
|
|
291
|
+
const innerY0 = -Math.cos(currentA0) * currentInner;
|
|
292
|
+
return `M ${outerX0} ${outerY0} A ${currentOuter} ${currentOuter} 0 ${largeArc} 1 ${outerX1} ${outerY1} L ${innerX1} ${innerY1} A ${currentInner} ${currentInner} 0 ${largeArc} 0 ${innerX0} ${innerY0} Z`;
|
|
293
|
+
}
|
|
294
|
+
function centroidAngle(arc) {
|
|
295
|
+
return (arc.a0 + arc.a1) / 2;
|
|
296
|
+
}
|
|
297
|
+
function geomCentroidAngle(geometry) {
|
|
298
|
+
return (geometry.a0 + geometry.a1) / 2;
|
|
299
|
+
}
|
|
300
|
+
function geomCentroidRadius(geometry) {
|
|
301
|
+
return (geometry.innerR + geometry.outerR) / 2;
|
|
302
|
+
}
|
|
303
|
+
function visibleHoverPathLength(hoveredDepth, focusDepth) {
|
|
304
|
+
return Math.max(1, hoveredDepth - focusDepth);
|
|
305
|
+
}
|
|
306
|
+
function hoverGrowForPathSegment(hoverPop, ringWidth, pathLength) {
|
|
307
|
+
const maxTotalGrow = ringWidth * HOVER_GROW_RING_BUDGET;
|
|
308
|
+
const budgetPerSegment = maxTotalGrow / pathLength;
|
|
309
|
+
const perSegmentCap = ringWidth * HOVER_GROW_SEGMENT_CAP;
|
|
310
|
+
return Math.min(hoverPop, perSegmentCap, budgetPerSegment);
|
|
311
|
+
}
|
|
312
|
+
function maxHoverSegmentThickness(maxDepth, radius, hoverPop, referenceFocusDepth = 1) {
|
|
313
|
+
const { ringWidth } = ringOptions(referenceFocusDepth, maxDepth, radius);
|
|
314
|
+
const grow = hoverGrowForPathSegment(hoverPop, ringWidth, 1);
|
|
315
|
+
return ringWidth + grow;
|
|
316
|
+
}
|
|
317
|
+
function buildHoverGrowTargets(arcs, hoveredArc, focus, maxDepth, radius, hoverPop, isOnHoverPath) {
|
|
318
|
+
const targets = /* @__PURE__ */ new Map();
|
|
319
|
+
const { ringWidth } = ringOptions(focus.depth, maxDepth, radius);
|
|
320
|
+
const pathLength = visibleHoverPathLength(hoveredArc.depth, focus.depth);
|
|
321
|
+
const segmentGrow = hoverGrowForPathSegment(hoverPop, ringWidth, pathLength);
|
|
322
|
+
const maxExpandedThickness = maxHoverSegmentThickness(
|
|
323
|
+
maxDepth,
|
|
324
|
+
radius,
|
|
325
|
+
hoverPop
|
|
326
|
+
);
|
|
327
|
+
for (const d of arcs) {
|
|
328
|
+
if (!isOnHoverPath(d, hoveredArc.id) || d.depth <= focus.depth) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
const base = geometryFor(d, focus, maxDepth, radius);
|
|
332
|
+
const baseThickness = base ? base.outerR - base.innerR : maxExpandedThickness;
|
|
333
|
+
const allowedGrow = baseThickness >= maxExpandedThickness ? 0 : Math.min(segmentGrow, maxExpandedThickness - baseThickness);
|
|
334
|
+
targets.set(d.id, allowedGrow);
|
|
335
|
+
}
|
|
336
|
+
return targets;
|
|
337
|
+
}
|
|
338
|
+
function defaultSunburstGrowPadding(maxDepth, size, hoverPop) {
|
|
339
|
+
const fullRadius = size / 2;
|
|
340
|
+
const rootRingWidth = fullRadius / Math.max(1, maxDepth);
|
|
341
|
+
const pathLength = Math.max(1, maxDepth - 1);
|
|
342
|
+
const segmentGrow = hoverGrowForPathSegment(
|
|
343
|
+
hoverPop,
|
|
344
|
+
rootRingWidth,
|
|
345
|
+
pathLength
|
|
346
|
+
);
|
|
347
|
+
return Math.ceil(segmentGrow * pathLength + segmentGrow);
|
|
348
|
+
}
|
|
349
|
+
function ancestorGrowOffset(arcId, growAmountForArc) {
|
|
350
|
+
const parts = arcId.split(ID_SEP);
|
|
351
|
+
let push = 0;
|
|
352
|
+
for (let i = 1; i < parts.length; i++) {
|
|
353
|
+
push += growAmountForArc(parts.slice(0, i).join(ID_SEP));
|
|
354
|
+
}
|
|
355
|
+
return push;
|
|
356
|
+
}
|
|
357
|
+
function applyHoverGrow(base, arcId, growAmountForArc, maxExpandedThickness) {
|
|
358
|
+
const push = ancestorGrowOffset(arcId, growAmountForArc);
|
|
359
|
+
const ownGrow = growAmountForArc(arcId);
|
|
360
|
+
if (push <= 0 && ownGrow <= 0) {
|
|
361
|
+
return base;
|
|
362
|
+
}
|
|
363
|
+
const baseThickness = base.outerR - base.innerR;
|
|
364
|
+
if (baseThickness >= maxExpandedThickness) {
|
|
365
|
+
if (push <= 0) {
|
|
366
|
+
return base;
|
|
367
|
+
}
|
|
368
|
+
return {
|
|
369
|
+
...base,
|
|
370
|
+
innerR: base.innerR + push,
|
|
371
|
+
outerR: base.outerR + push
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
const innerR = base.innerR + push;
|
|
375
|
+
let outerR = base.outerR + push + ownGrow;
|
|
376
|
+
const thickness = outerR - innerR;
|
|
377
|
+
if (thickness > maxExpandedThickness) {
|
|
378
|
+
outerR = innerR + maxExpandedThickness;
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
...base,
|
|
382
|
+
innerR,
|
|
383
|
+
outerR
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function localProgress(progress, delay, duration) {
|
|
387
|
+
if (progress <= delay) {
|
|
388
|
+
return 0;
|
|
389
|
+
}
|
|
390
|
+
if (duration <= 0) {
|
|
391
|
+
return 1;
|
|
392
|
+
}
|
|
393
|
+
return Math.min(1, (progress - delay) / duration);
|
|
394
|
+
}
|
|
395
|
+
export {
|
|
396
|
+
ancestorGrowOffset,
|
|
397
|
+
applyHoverGrow,
|
|
398
|
+
arcPath,
|
|
399
|
+
buildArcs,
|
|
400
|
+
buildHoverGrowTargets,
|
|
401
|
+
buildRevealDelays,
|
|
402
|
+
buildRevealSchedule,
|
|
403
|
+
buildSunburstEnterTiming,
|
|
404
|
+
centroidAngle,
|
|
405
|
+
clockwiseFraction,
|
|
406
|
+
defaultSunburstGrowPadding,
|
|
407
|
+
geomCentroidAngle,
|
|
408
|
+
geomCentroidRadius,
|
|
409
|
+
geometryFor,
|
|
410
|
+
hoverGrowForPathSegment,
|
|
411
|
+
lerpGeometry,
|
|
412
|
+
localProgress,
|
|
413
|
+
maxHoverSegmentThickness,
|
|
414
|
+
ringOptions,
|
|
415
|
+
segmentRevealFromRingSweep,
|
|
416
|
+
sumValues,
|
|
417
|
+
transitionGeometry,
|
|
418
|
+
visibleHoverPathLength
|
|
419
|
+
};
|