@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,498 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
areaRadial,
|
|
5
|
+
curveBasis,
|
|
6
|
+
curveBasisClosed,
|
|
7
|
+
curveCatmullRom,
|
|
8
|
+
curveCatmullRomClosed,
|
|
9
|
+
curveLinear,
|
|
10
|
+
curveLinearClosed,
|
|
11
|
+
lineRadial
|
|
12
|
+
} from "d3-shape";
|
|
13
|
+
import {
|
|
14
|
+
animate as animateValue,
|
|
15
|
+
useMotionValue
|
|
16
|
+
} from "motion/react";
|
|
17
|
+
import { memo, useEffect, useId, useMemo, useRef } from "react";
|
|
18
|
+
import {
|
|
19
|
+
createRadialEdgeLookup,
|
|
20
|
+
RadialHoverDot,
|
|
21
|
+
radialNumberAt,
|
|
22
|
+
useRadialChart,
|
|
23
|
+
useRadialDotAngle
|
|
24
|
+
} from "./radial-chart";
|
|
25
|
+
import { createRadialScale, radialWedgePath } from "./radial-geometry";
|
|
26
|
+
import { radialSeriesColor } from "./radial-series-color";
|
|
27
|
+
const CURVES = {
|
|
28
|
+
catmullRom: { open: curveCatmullRom, closed: curveCatmullRomClosed },
|
|
29
|
+
basis: { open: curveBasis, closed: curveBasisClosed },
|
|
30
|
+
linear: { open: curveLinear, closed: curveLinearClosed }
|
|
31
|
+
};
|
|
32
|
+
const ENTER_SPREAD_S = 0.75;
|
|
33
|
+
const ENTER_DURATION_S = 0.5;
|
|
34
|
+
const ENTER_TOTAL_S = ENTER_SPREAD_S + ENTER_DURATION_S;
|
|
35
|
+
function easeOutCubic(t) {
|
|
36
|
+
return 1 - (1 - t) ** 3;
|
|
37
|
+
}
|
|
38
|
+
function toRuns(points, binStartAngle, isFullCircle) {
|
|
39
|
+
if (isFullCircle && points.length > 0 && points.every((p) => p !== null)) {
|
|
40
|
+
return [{ points, closed: true }];
|
|
41
|
+
}
|
|
42
|
+
const runs = [];
|
|
43
|
+
let current = [];
|
|
44
|
+
const flush = () => {
|
|
45
|
+
const first = current[0];
|
|
46
|
+
const last = current.at(-1);
|
|
47
|
+
if (first && last) {
|
|
48
|
+
runs.push({
|
|
49
|
+
closed: false,
|
|
50
|
+
points: [
|
|
51
|
+
{ ...first, angle: binStartAngle(first.index) },
|
|
52
|
+
...current,
|
|
53
|
+
{ ...last, angle: binStartAngle(last.index + 1) }
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
current = [];
|
|
58
|
+
};
|
|
59
|
+
for (const p of points) {
|
|
60
|
+
if (p) {
|
|
61
|
+
current.push(p);
|
|
62
|
+
} else {
|
|
63
|
+
flush();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
flush();
|
|
67
|
+
return runs;
|
|
68
|
+
}
|
|
69
|
+
function grow(points, p, base, binCount) {
|
|
70
|
+
if (p >= 1) {
|
|
71
|
+
return points;
|
|
72
|
+
}
|
|
73
|
+
const t = p * ENTER_TOTAL_S;
|
|
74
|
+
return points.map((point) => {
|
|
75
|
+
const delay = point.index / Math.max(1, binCount) * ENTER_SPREAD_S;
|
|
76
|
+
const e = easeOutCubic(
|
|
77
|
+
Math.min(1, Math.max(0, (t - delay) / ENTER_DURATION_S))
|
|
78
|
+
);
|
|
79
|
+
return {
|
|
80
|
+
...point,
|
|
81
|
+
inner: base + (point.inner - base) * e,
|
|
82
|
+
outer: base + (point.outer - base) * e
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function wedgePath(p, r, startAngle, endAngle) {
|
|
87
|
+
const t = Math.min(1, p * ENTER_TOTAL_S / ENTER_SPREAD_S);
|
|
88
|
+
if (t >= 1 - 1e-4) {
|
|
89
|
+
return `M0,${-r}A${r},${r},0,1,1,0,${r}A${r},${r},0,1,1,0,${-r}Z`;
|
|
90
|
+
}
|
|
91
|
+
return radialWedgePath(
|
|
92
|
+
r,
|
|
93
|
+
startAngle,
|
|
94
|
+
startAngle + (endAngle - startAngle) * t
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function useProgressAttribute(progress, attribute, compute) {
|
|
98
|
+
const ref = useRef(null);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const apply = (p) => ref.current?.setAttribute(attribute, compute(p));
|
|
101
|
+
apply(progress.get());
|
|
102
|
+
return progress.on("change", apply);
|
|
103
|
+
}, [progress, attribute, compute]);
|
|
104
|
+
return ref;
|
|
105
|
+
}
|
|
106
|
+
const AreaLayerPaths = memo(function AreaLayerPaths2({
|
|
107
|
+
layer,
|
|
108
|
+
progress,
|
|
109
|
+
curve,
|
|
110
|
+
base,
|
|
111
|
+
binCount,
|
|
112
|
+
gradientId
|
|
113
|
+
}) {
|
|
114
|
+
const paths = useMemo(() => {
|
|
115
|
+
const factories = CURVES[curve];
|
|
116
|
+
const build = (kind, p2) => (kind === "area" ? layer.runs : layer.strokeRuns).map(({ points, closed }) => {
|
|
117
|
+
const factory = closed ? factories.closed : factories.open;
|
|
118
|
+
const grown = grow(points, p2, base, binCount);
|
|
119
|
+
if (kind === "area") {
|
|
120
|
+
return areaRadial().angle((d) => d.angle).innerRadius((d) => d.inner).outerRadius((d) => d.outer).curve(factory)(grown) ?? "";
|
|
121
|
+
}
|
|
122
|
+
return lineRadial().angle((d) => d.angle).radius((d) => kind === "outer" ? d.outer : d.inner).curve(factory)(grown) ?? "";
|
|
123
|
+
}).join("");
|
|
124
|
+
return {
|
|
125
|
+
area: (p2) => build("area", p2),
|
|
126
|
+
outer: (p2) => build("outer", p2),
|
|
127
|
+
inner: (p2) => build("inner", p2)
|
|
128
|
+
};
|
|
129
|
+
}, [layer, curve, base, binCount]);
|
|
130
|
+
const areaRef = useProgressAttribute(
|
|
131
|
+
progress,
|
|
132
|
+
"d",
|
|
133
|
+
paths.area
|
|
134
|
+
);
|
|
135
|
+
const outerRef = useProgressAttribute(
|
|
136
|
+
progress,
|
|
137
|
+
"d",
|
|
138
|
+
paths.outer
|
|
139
|
+
);
|
|
140
|
+
const innerRef = useProgressAttribute(
|
|
141
|
+
progress,
|
|
142
|
+
"d",
|
|
143
|
+
paths.inner
|
|
144
|
+
);
|
|
145
|
+
const p = progress.get();
|
|
146
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
147
|
+
layer.fill ? /* @__PURE__ */ jsx(
|
|
148
|
+
"path",
|
|
149
|
+
{
|
|
150
|
+
d: paths.area(p),
|
|
151
|
+
fill: `url(#${gradientId})`,
|
|
152
|
+
fillRule: "evenodd",
|
|
153
|
+
ref: areaRef
|
|
154
|
+
}
|
|
155
|
+
) : null,
|
|
156
|
+
layer.stroke === "none" ? null : /* @__PURE__ */ jsxs(
|
|
157
|
+
"g",
|
|
158
|
+
{
|
|
159
|
+
fill: "none",
|
|
160
|
+
stroke: layer.color,
|
|
161
|
+
strokeDasharray: layer.strokeDasharray,
|
|
162
|
+
strokeLinecap: "round",
|
|
163
|
+
strokeLinejoin: "round",
|
|
164
|
+
strokeOpacity: layer.strokeOpacity,
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsx("path", { d: paths.outer(p), ref: outerRef }),
|
|
167
|
+
layer.stroke === "both" ? /* @__PURE__ */ jsx("path", { d: paths.inner(p), ref: innerRef }) : null
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
)
|
|
171
|
+
] });
|
|
172
|
+
});
|
|
173
|
+
function EnterClip({
|
|
174
|
+
id,
|
|
175
|
+
progress,
|
|
176
|
+
radius,
|
|
177
|
+
startAngle,
|
|
178
|
+
endAngle
|
|
179
|
+
}) {
|
|
180
|
+
const r = radius * 1.2;
|
|
181
|
+
const compute = useMemo(
|
|
182
|
+
() => (p) => wedgePath(p, r, startAngle, endAngle),
|
|
183
|
+
[r, startAngle, endAngle]
|
|
184
|
+
);
|
|
185
|
+
const ref = useProgressAttribute(progress, "d", compute);
|
|
186
|
+
return /* @__PURE__ */ jsx("clipPath", { id, children: /* @__PURE__ */ jsx("path", { d: compute(progress.get()), ref }) });
|
|
187
|
+
}
|
|
188
|
+
function RadialArea({
|
|
189
|
+
dataKey,
|
|
190
|
+
baseDataKey,
|
|
191
|
+
stacked = true,
|
|
192
|
+
color,
|
|
193
|
+
fill = true,
|
|
194
|
+
fillOpacity = 0.32,
|
|
195
|
+
rampFrom,
|
|
196
|
+
stroke = "outer",
|
|
197
|
+
strokeWidth = 1.5,
|
|
198
|
+
strokeOpacity = 1,
|
|
199
|
+
strokeDasharray,
|
|
200
|
+
curve = "catmullRom",
|
|
201
|
+
ghostDataKey,
|
|
202
|
+
ghostColor = "var(--chart-foreground)",
|
|
203
|
+
ghostOpacity = 0.1,
|
|
204
|
+
maxValue: maxValueProp,
|
|
205
|
+
activeDot = true,
|
|
206
|
+
activeDotMotion = "crosshair",
|
|
207
|
+
activeDotSpring,
|
|
208
|
+
fadedOpacity = 0.2
|
|
209
|
+
}) {
|
|
210
|
+
const {
|
|
211
|
+
data,
|
|
212
|
+
series,
|
|
213
|
+
binCount,
|
|
214
|
+
radius,
|
|
215
|
+
innerRadius,
|
|
216
|
+
outerRadius,
|
|
217
|
+
futureBins,
|
|
218
|
+
hoveredIndex,
|
|
219
|
+
hoveredSeries,
|
|
220
|
+
revealed,
|
|
221
|
+
animate,
|
|
222
|
+
binAngle,
|
|
223
|
+
binStartAngle,
|
|
224
|
+
isFullCircle,
|
|
225
|
+
startAngle,
|
|
226
|
+
endAngle,
|
|
227
|
+
sharedValueScale,
|
|
228
|
+
valueScale
|
|
229
|
+
} = useRadialChart();
|
|
230
|
+
const uid = useId().replace(/:/g, "");
|
|
231
|
+
const clipId = `radial-area-clip-${uid}`;
|
|
232
|
+
const raw = useMemo(() => {
|
|
233
|
+
const layers2 = [];
|
|
234
|
+
if (dataKey) {
|
|
235
|
+
layers2.push({
|
|
236
|
+
key: `area-${dataKey}`,
|
|
237
|
+
seriesIndex: series.findIndex((s) => s.dataKey === dataKey),
|
|
238
|
+
values: data.map((d) => {
|
|
239
|
+
const hi = radialNumberAt(d, dataKey);
|
|
240
|
+
if (hi === null) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
const lo = baseDataKey ? radialNumberAt(d, baseDataKey) ?? 0 : 0;
|
|
244
|
+
return { lo: Math.max(0, lo), hi: Math.max(0, hi) };
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
} else {
|
|
248
|
+
const cumulative = data.map(() => 0);
|
|
249
|
+
series.forEach((s, seriesIndex) => {
|
|
250
|
+
layers2.push({
|
|
251
|
+
key: `series-${s.dataKey}`,
|
|
252
|
+
seriesIndex,
|
|
253
|
+
values: data.map((d, i) => {
|
|
254
|
+
const v = radialNumberAt(d, s.dataKey);
|
|
255
|
+
if (v === null) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
const lo = stacked ? cumulative[i] ?? 0 : 0;
|
|
259
|
+
const hi = lo + Math.max(0, v);
|
|
260
|
+
if (stacked) {
|
|
261
|
+
cumulative[i] = hi;
|
|
262
|
+
}
|
|
263
|
+
return { lo, hi };
|
|
264
|
+
})
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
const ghost = ghostDataKey ? data.map(
|
|
269
|
+
(d, i) => futureBins[i] ? (() => {
|
|
270
|
+
const v = radialNumberAt(d, ghostDataKey);
|
|
271
|
+
return v === null ? null : { lo: 0, hi: Math.max(0, v) };
|
|
272
|
+
})() : null
|
|
273
|
+
) : null;
|
|
274
|
+
return { layers: layers2, ghost };
|
|
275
|
+
}, [dataKey, baseDataKey, stacked, series, data, ghostDataKey, futureBins]);
|
|
276
|
+
const maxValue = useMemo(() => {
|
|
277
|
+
if (maxValueProp !== void 0) {
|
|
278
|
+
return maxValueProp;
|
|
279
|
+
}
|
|
280
|
+
let max = 0;
|
|
281
|
+
for (const layer of raw.layers) {
|
|
282
|
+
for (const v of layer.values) {
|
|
283
|
+
max = Math.max(max, v?.hi ?? 0);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
for (const v of raw.ghost ?? []) {
|
|
287
|
+
max = Math.max(max, v?.hi ?? 0);
|
|
288
|
+
}
|
|
289
|
+
return max;
|
|
290
|
+
}, [maxValueProp, raw]);
|
|
291
|
+
const layers = useMemo(() => {
|
|
292
|
+
if (outerRadius <= innerRadius) {
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
const own = createRadialScale({ maxValue, innerRadius, outerRadius });
|
|
296
|
+
const scale = maxValueProp === void 0 && sharedValueScale ? valueScale : (value) => own(value) ?? innerRadius;
|
|
297
|
+
const toPoints = (values) => values.map(
|
|
298
|
+
(v, index) => v ? {
|
|
299
|
+
index,
|
|
300
|
+
angle: binAngle(index),
|
|
301
|
+
inner: scale(v.lo),
|
|
302
|
+
outer: scale(v.hi)
|
|
303
|
+
} : null
|
|
304
|
+
);
|
|
305
|
+
const result = [];
|
|
306
|
+
if (raw.ghost) {
|
|
307
|
+
const byBin = toPoints(raw.ghost);
|
|
308
|
+
result.push({
|
|
309
|
+
key: "ghost",
|
|
310
|
+
seriesIndex: -2,
|
|
311
|
+
color: ghostColor,
|
|
312
|
+
fill: true,
|
|
313
|
+
fillOpacity: ghostOpacity,
|
|
314
|
+
rampFrom: 0.4,
|
|
315
|
+
stroke: "outer",
|
|
316
|
+
strokeOpacity: Math.min(1, ghostOpacity * 2.5),
|
|
317
|
+
strokeDasharray: "3 4",
|
|
318
|
+
runs: toRuns(byBin, binStartAngle, isFullCircle),
|
|
319
|
+
strokeRuns: toRuns(byBin, binStartAngle, isFullCircle),
|
|
320
|
+
byBin
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
for (const layer of raw.layers) {
|
|
324
|
+
const s = series[layer.seriesIndex];
|
|
325
|
+
const points = toPoints(layer.values);
|
|
326
|
+
const byBin = dataKey || !stacked ? points : points.map((p) => p && p.outer > p.inner ? p : null);
|
|
327
|
+
result.push({
|
|
328
|
+
key: layer.key,
|
|
329
|
+
seriesIndex: layer.seriesIndex,
|
|
330
|
+
color: (dataKey ? color : void 0) ?? radialSeriesColor(s, layer.seriesIndex),
|
|
331
|
+
fill,
|
|
332
|
+
fillOpacity: fillOpacity * (s?.opacity ?? 1),
|
|
333
|
+
rampFrom: rampFrom ?? s?.rampFrom ?? 0.25,
|
|
334
|
+
stroke,
|
|
335
|
+
strokeOpacity: strokeOpacity * (s?.opacity ?? 1),
|
|
336
|
+
strokeDasharray,
|
|
337
|
+
runs: toRuns(points, binStartAngle, isFullCircle),
|
|
338
|
+
strokeRuns: toRuns(byBin, binStartAngle, isFullCircle),
|
|
339
|
+
byBin
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
return result;
|
|
343
|
+
}, [
|
|
344
|
+
raw,
|
|
345
|
+
series,
|
|
346
|
+
maxValue,
|
|
347
|
+
maxValueProp,
|
|
348
|
+
sharedValueScale,
|
|
349
|
+
valueScale,
|
|
350
|
+
innerRadius,
|
|
351
|
+
outerRadius,
|
|
352
|
+
binAngle,
|
|
353
|
+
binStartAngle,
|
|
354
|
+
isFullCircle,
|
|
355
|
+
dataKey,
|
|
356
|
+
stacked,
|
|
357
|
+
color,
|
|
358
|
+
fill,
|
|
359
|
+
fillOpacity,
|
|
360
|
+
rampFrom,
|
|
361
|
+
stroke,
|
|
362
|
+
strokeOpacity,
|
|
363
|
+
strokeDasharray,
|
|
364
|
+
ghostColor,
|
|
365
|
+
ghostOpacity
|
|
366
|
+
]);
|
|
367
|
+
const progress = useMotionValue(animate ? 0 : 1);
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
if (!animate) {
|
|
370
|
+
progress.jump(1);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (!revealed) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const controls = animateValue(progress, 1, {
|
|
377
|
+
duration: ENTER_TOTAL_S,
|
|
378
|
+
ease: "linear"
|
|
379
|
+
});
|
|
380
|
+
return () => controls.stop();
|
|
381
|
+
}, [animate, revealed, progress]);
|
|
382
|
+
const edges = useMemo(() => {
|
|
383
|
+
const result = /* @__PURE__ */ new Map();
|
|
384
|
+
if (!activeDot) {
|
|
385
|
+
return result;
|
|
386
|
+
}
|
|
387
|
+
const factories = CURVES[curve];
|
|
388
|
+
for (const layer of layers) {
|
|
389
|
+
if (layer.stroke === "none") {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
result.set(
|
|
393
|
+
layer.key,
|
|
394
|
+
createRadialEdgeLookup((context) => {
|
|
395
|
+
for (const { points, closed } of layer.strokeRuns) {
|
|
396
|
+
lineRadial().angle((d) => d.angle).radius((d) => d.outer).curve(closed ? factories.closed : factories.open).context(context)(points);
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}, [activeDot, layers, curve]);
|
|
403
|
+
const dotAngle = useRadialDotAngle(activeDotMotion, activeDotSpring);
|
|
404
|
+
const dotR = Math.max(2.5, radius * 9e-3);
|
|
405
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
|
|
406
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
407
|
+
/* @__PURE__ */ jsx(
|
|
408
|
+
EnterClip,
|
|
409
|
+
{
|
|
410
|
+
endAngle,
|
|
411
|
+
id: clipId,
|
|
412
|
+
progress,
|
|
413
|
+
radius,
|
|
414
|
+
startAngle
|
|
415
|
+
}
|
|
416
|
+
),
|
|
417
|
+
layers.map((layer) => /* @__PURE__ */ jsxs(
|
|
418
|
+
"radialGradient",
|
|
419
|
+
{
|
|
420
|
+
cx: 0,
|
|
421
|
+
cy: 0,
|
|
422
|
+
gradientUnits: "userSpaceOnUse",
|
|
423
|
+
id: `radial-area-fill-${uid}-${layer.key}`,
|
|
424
|
+
r: outerRadius,
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ jsx(
|
|
427
|
+
"stop",
|
|
428
|
+
{
|
|
429
|
+
offset: innerRadius / outerRadius,
|
|
430
|
+
stopColor: layer.color,
|
|
431
|
+
stopOpacity: layer.fillOpacity * layer.rampFrom
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
/* @__PURE__ */ jsx(
|
|
435
|
+
"stop",
|
|
436
|
+
{
|
|
437
|
+
offset: 1,
|
|
438
|
+
stopColor: layer.color,
|
|
439
|
+
stopOpacity: layer.fillOpacity
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
]
|
|
443
|
+
},
|
|
444
|
+
layer.key
|
|
445
|
+
))
|
|
446
|
+
] }),
|
|
447
|
+
/* @__PURE__ */ jsx("g", { clipPath: `url(#${clipId})`, strokeWidth, children: layers.map((layer) => {
|
|
448
|
+
const dimmed = hoveredSeries !== null && hoveredSeries !== layer.seriesIndex;
|
|
449
|
+
return /* @__PURE__ */ jsx(
|
|
450
|
+
"g",
|
|
451
|
+
{
|
|
452
|
+
style: {
|
|
453
|
+
opacity: dimmed ? fadedOpacity : 1,
|
|
454
|
+
transition: "opacity 0.15s ease-out"
|
|
455
|
+
},
|
|
456
|
+
children: /* @__PURE__ */ jsx(
|
|
457
|
+
AreaLayerPaths,
|
|
458
|
+
{
|
|
459
|
+
base: innerRadius,
|
|
460
|
+
binCount,
|
|
461
|
+
curve,
|
|
462
|
+
gradientId: `radial-area-fill-${uid}-${layer.key}`,
|
|
463
|
+
layer,
|
|
464
|
+
progress
|
|
465
|
+
}
|
|
466
|
+
)
|
|
467
|
+
},
|
|
468
|
+
layer.key
|
|
469
|
+
);
|
|
470
|
+
}) }),
|
|
471
|
+
activeDot && hoveredIndex !== null ? layers.map((layer) => {
|
|
472
|
+
const lookup = edges.get(layer.key);
|
|
473
|
+
if (!(lookup && layer.byBin[hoveredIndex])) {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
const dimmed = hoveredSeries !== null && hoveredSeries !== layer.seriesIndex;
|
|
477
|
+
return /* @__PURE__ */ jsx(
|
|
478
|
+
RadialHoverDot,
|
|
479
|
+
{
|
|
480
|
+
angle: dotAngle,
|
|
481
|
+
fill: layer.color,
|
|
482
|
+
lookup,
|
|
483
|
+
opacity: dimmed ? fadedOpacity : 1,
|
|
484
|
+
r: dotR,
|
|
485
|
+
stroke: "var(--chart-background)",
|
|
486
|
+
strokeWidth: 1.5
|
|
487
|
+
},
|
|
488
|
+
`dot-${layer.key}`
|
|
489
|
+
);
|
|
490
|
+
}) : null
|
|
491
|
+
] });
|
|
492
|
+
}
|
|
493
|
+
RadialArea.displayName = "RadialArea";
|
|
494
|
+
var radial_area_default = RadialArea;
|
|
495
|
+
export {
|
|
496
|
+
RadialArea,
|
|
497
|
+
radial_area_default as default
|
|
498
|
+
};
|