@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,280 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
curveCatmullRom,
|
|
5
|
+
curveCatmullRomClosed,
|
|
6
|
+
lineRadial
|
|
7
|
+
} from "d3-shape";
|
|
8
|
+
import { m } from "motion/react";
|
|
9
|
+
import { memo, useId, useMemo } from "react";
|
|
10
|
+
import {
|
|
11
|
+
createRadialEdgeLookup,
|
|
12
|
+
RadialHoverDot,
|
|
13
|
+
radialNumberAt,
|
|
14
|
+
useRadialChart,
|
|
15
|
+
useRadialDotAngle
|
|
16
|
+
} from "./radial-chart";
|
|
17
|
+
import { createRadialScale, polarToCartesian } from "./radial-geometry";
|
|
18
|
+
import { radialSeriesColor } from "./radial-series-color";
|
|
19
|
+
const DRAW_DURATION_S = 1.2;
|
|
20
|
+
const DRAW_EASE = "cubic-bezier(0.65, 0, 0.35, 1)";
|
|
21
|
+
const NowMarker = memo(function NowMarker2({
|
|
22
|
+
point,
|
|
23
|
+
color,
|
|
24
|
+
r,
|
|
25
|
+
pulse,
|
|
26
|
+
visible,
|
|
27
|
+
animate,
|
|
28
|
+
delay
|
|
29
|
+
}) {
|
|
30
|
+
return /* @__PURE__ */ jsxs(
|
|
31
|
+
"g",
|
|
32
|
+
{
|
|
33
|
+
style: {
|
|
34
|
+
opacity: visible ? 1 : 0,
|
|
35
|
+
transition: animate ? `opacity 0.3s ease-out ${delay}s` : void 0
|
|
36
|
+
},
|
|
37
|
+
transform: `translate(${point.x},${point.y})`,
|
|
38
|
+
children: [
|
|
39
|
+
pulse ? /* @__PURE__ */ jsx(
|
|
40
|
+
m.circle,
|
|
41
|
+
{
|
|
42
|
+
animate: { scale: [1, 2.6], opacity: [0.35, 0] },
|
|
43
|
+
fill: color,
|
|
44
|
+
r,
|
|
45
|
+
style: { transformBox: "fill-box", transformOrigin: "center" },
|
|
46
|
+
transition: {
|
|
47
|
+
duration: 2,
|
|
48
|
+
ease: "easeOut",
|
|
49
|
+
repeat: Number.POSITIVE_INFINITY,
|
|
50
|
+
repeatDelay: 0.4
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
) : null,
|
|
54
|
+
/* @__PURE__ */ jsx("circle", { fill: color, fillOpacity: 0.16, r: r * 2 }),
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
"circle",
|
|
57
|
+
{
|
|
58
|
+
fill: color,
|
|
59
|
+
r,
|
|
60
|
+
stroke: "var(--chart-background)",
|
|
61
|
+
strokeWidth: Math.max(1.5, r * 0.5)
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
function isClosedLoop(isFullCircle, values) {
|
|
69
|
+
return isFullCircle && values.every((v) => v !== null);
|
|
70
|
+
}
|
|
71
|
+
function ownRadialScale(maxValue, innerRadius, outerRadius) {
|
|
72
|
+
const scale = createRadialScale({ maxValue, innerRadius, outerRadius });
|
|
73
|
+
return (value) => scale(value) ?? innerRadius;
|
|
74
|
+
}
|
|
75
|
+
function lineEdgeLookup(values, binAngle, scale, curve) {
|
|
76
|
+
const indices = values.map((_, i) => i);
|
|
77
|
+
return createRadialEdgeLookup(
|
|
78
|
+
(context) => lineRadial().angle((i) => binAngle(i)).radius((i) => scale(values[i] ?? 0)).defined((i) => values[i] !== null).curve(curve).context(context)(indices)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function resolveDashArray(dash, strokeWidth) {
|
|
82
|
+
if (dash === true) {
|
|
83
|
+
return `${strokeWidth} ${strokeWidth * 3}`;
|
|
84
|
+
}
|
|
85
|
+
return typeof dash === "string" ? dash : void 0;
|
|
86
|
+
}
|
|
87
|
+
function RadialLine({
|
|
88
|
+
dataKey,
|
|
89
|
+
stroke: strokeProp,
|
|
90
|
+
strokeWidth = 2,
|
|
91
|
+
strokeOpacity: strokeOpacityProp,
|
|
92
|
+
dash,
|
|
93
|
+
curve: curveProp,
|
|
94
|
+
closed: closedProp,
|
|
95
|
+
maxValue: maxValueProp,
|
|
96
|
+
showMarkers = true,
|
|
97
|
+
markerMotion = "crosshair",
|
|
98
|
+
markerSpring,
|
|
99
|
+
showNowMarker: showNowMarkerProp,
|
|
100
|
+
pulse = true,
|
|
101
|
+
markerRadius: markerRadiusProp,
|
|
102
|
+
fadedOpacity = 0.2,
|
|
103
|
+
enterDelay = 0
|
|
104
|
+
}) {
|
|
105
|
+
const {
|
|
106
|
+
data,
|
|
107
|
+
series,
|
|
108
|
+
binCount,
|
|
109
|
+
radius,
|
|
110
|
+
innerRadius,
|
|
111
|
+
outerRadius,
|
|
112
|
+
hoveredIndex,
|
|
113
|
+
hoveredSeries,
|
|
114
|
+
revealed,
|
|
115
|
+
animate,
|
|
116
|
+
reducedMotion,
|
|
117
|
+
binAngle,
|
|
118
|
+
isFullCircle,
|
|
119
|
+
sharedValueScale,
|
|
120
|
+
valueScale
|
|
121
|
+
} = useRadialChart();
|
|
122
|
+
const maskId = `radial-line-mask-${useId().replace(/:/g, "")}`;
|
|
123
|
+
const seriesIndex = series.findIndex((s) => s.dataKey === dataKey);
|
|
124
|
+
const seriesConfig = seriesIndex >= 0 ? series[seriesIndex] : void 0;
|
|
125
|
+
const stroke = strokeProp ?? radialSeriesColor(seriesConfig, seriesIndex);
|
|
126
|
+
const strokeOpacity = strokeOpacityProp ?? seriesConfig?.opacity ?? 1;
|
|
127
|
+
const values = useMemo(
|
|
128
|
+
() => data.map((d) => radialNumberAt(d, dataKey)),
|
|
129
|
+
[data, dataKey]
|
|
130
|
+
);
|
|
131
|
+
const maxValue = useMemo(() => {
|
|
132
|
+
if (maxValueProp !== void 0) {
|
|
133
|
+
return maxValueProp;
|
|
134
|
+
}
|
|
135
|
+
let max = 0;
|
|
136
|
+
for (const d of data) {
|
|
137
|
+
for (const key of [dataKey, ...series.map((s) => s.dataKey)]) {
|
|
138
|
+
max = Math.max(max, radialNumberAt(d, key) ?? 0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return max;
|
|
142
|
+
}, [maxValueProp, data, dataKey, series]);
|
|
143
|
+
const scale = useMemo(
|
|
144
|
+
() => maxValueProp === void 0 && sharedValueScale ? valueScale : ownRadialScale(maxValue, innerRadius, outerRadius),
|
|
145
|
+
[
|
|
146
|
+
maxValueProp,
|
|
147
|
+
sharedValueScale,
|
|
148
|
+
valueScale,
|
|
149
|
+
maxValue,
|
|
150
|
+
innerRadius,
|
|
151
|
+
outerRadius
|
|
152
|
+
]
|
|
153
|
+
);
|
|
154
|
+
const closed = closedProp ?? isClosedLoop(isFullCircle, values);
|
|
155
|
+
const curve = curveProp ?? (closed ? curveCatmullRomClosed : curveCatmullRom);
|
|
156
|
+
const pathD = useMemo(() => {
|
|
157
|
+
if (binCount === 0 || outerRadius <= 0) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const indices = values.map((_, i) => i);
|
|
161
|
+
const generator = lineRadial().angle((i) => binAngle(i)).radius((i) => scale(values[i] ?? 0)).defined((i) => values[i] !== null).curve(curve);
|
|
162
|
+
return generator(indices);
|
|
163
|
+
}, [binCount, outerRadius, values, binAngle, scale, curve]);
|
|
164
|
+
const edge = useMemo(
|
|
165
|
+
() => showMarkers && pathD ? lineEdgeLookup(values, binAngle, scale, curve) : null,
|
|
166
|
+
[showMarkers, pathD, values, binAngle, scale, curve]
|
|
167
|
+
);
|
|
168
|
+
const markerAngle = useRadialDotAngle(markerMotion, markerSpring);
|
|
169
|
+
const pointAt = (index) => {
|
|
170
|
+
if (index === null) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
const value = values[index];
|
|
174
|
+
if (value === null || value === void 0) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return polarToCartesian(binAngle(index), scale(value));
|
|
178
|
+
};
|
|
179
|
+
const lastIndex = useMemo(() => {
|
|
180
|
+
for (let i = values.length - 1; i >= 0; i--) {
|
|
181
|
+
if (values[i] !== null) {
|
|
182
|
+
return i;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
186
|
+
}, [values]);
|
|
187
|
+
const showNowMarker = showNowMarkerProp ?? !closed;
|
|
188
|
+
const markerRadius = markerRadiusProp ?? Math.max(3.5, radius * 0.016);
|
|
189
|
+
const nowPoint = showNowMarker ? pointAt(lastIndex) : null;
|
|
190
|
+
const markerLookup = pointAt(hoveredIndex) ? edge : null;
|
|
191
|
+
const dashArray = resolveDashArray(dash, strokeWidth);
|
|
192
|
+
const dimmed = hoveredSeries !== null && hoveredSeries !== seriesIndex;
|
|
193
|
+
const drawEnd = enterDelay + DRAW_DURATION_S;
|
|
194
|
+
if (!pathD) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
return /* @__PURE__ */ jsxs(
|
|
198
|
+
"g",
|
|
199
|
+
{
|
|
200
|
+
pointerEvents: "none",
|
|
201
|
+
style: {
|
|
202
|
+
opacity: dimmed ? fadedOpacity : 1,
|
|
203
|
+
transition: "opacity 0.15s ease-out"
|
|
204
|
+
},
|
|
205
|
+
children: [
|
|
206
|
+
animate ? /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
|
|
207
|
+
"mask",
|
|
208
|
+
{
|
|
209
|
+
height: radius * 2,
|
|
210
|
+
id: maskId,
|
|
211
|
+
maskUnits: "userSpaceOnUse",
|
|
212
|
+
width: radius * 2,
|
|
213
|
+
x: -radius,
|
|
214
|
+
y: -radius,
|
|
215
|
+
children: /* @__PURE__ */ jsx(
|
|
216
|
+
"path",
|
|
217
|
+
{
|
|
218
|
+
d: pathD,
|
|
219
|
+
fill: "none",
|
|
220
|
+
pathLength: 1,
|
|
221
|
+
stroke: "white",
|
|
222
|
+
strokeDasharray: "1 1",
|
|
223
|
+
strokeLinecap: "butt",
|
|
224
|
+
strokeWidth: strokeWidth + 6,
|
|
225
|
+
style: {
|
|
226
|
+
strokeDashoffset: revealed ? 0 : 1,
|
|
227
|
+
transition: `stroke-dashoffset ${DRAW_DURATION_S}s ${DRAW_EASE} ${enterDelay}s`
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
) }) : null,
|
|
233
|
+
/* @__PURE__ */ jsx(
|
|
234
|
+
"path",
|
|
235
|
+
{
|
|
236
|
+
d: pathD,
|
|
237
|
+
fill: "none",
|
|
238
|
+
mask: animate ? `url(#${maskId})` : void 0,
|
|
239
|
+
stroke,
|
|
240
|
+
strokeDasharray: dashArray,
|
|
241
|
+
strokeLinecap: "round",
|
|
242
|
+
strokeLinejoin: "round",
|
|
243
|
+
strokeOpacity,
|
|
244
|
+
strokeWidth
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
nowPoint ? /* @__PURE__ */ jsx(
|
|
248
|
+
NowMarker,
|
|
249
|
+
{
|
|
250
|
+
animate,
|
|
251
|
+
color: stroke,
|
|
252
|
+
delay: drawEnd,
|
|
253
|
+
point: nowPoint,
|
|
254
|
+
pulse: pulse && !reducedMotion,
|
|
255
|
+
r: markerRadius,
|
|
256
|
+
visible: revealed
|
|
257
|
+
}
|
|
258
|
+
) : null,
|
|
259
|
+
markerLookup ? /* @__PURE__ */ jsx(
|
|
260
|
+
RadialHoverDot,
|
|
261
|
+
{
|
|
262
|
+
angle: markerAngle,
|
|
263
|
+
fill: stroke,
|
|
264
|
+
fillOpacity: Math.max(strokeOpacity, 0.5),
|
|
265
|
+
lookup: markerLookup,
|
|
266
|
+
r: markerRadius,
|
|
267
|
+
stroke: "var(--chart-background)",
|
|
268
|
+
strokeWidth: Math.max(1.5, markerRadius * 0.5)
|
|
269
|
+
}
|
|
270
|
+
) : null
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
RadialLine.displayName = "RadialLine";
|
|
276
|
+
var radial_line_default = RadialLine;
|
|
277
|
+
export {
|
|
278
|
+
RadialLine,
|
|
279
|
+
radial_line_default as default
|
|
280
|
+
};
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { arc as d3Arc } from "d3-shape";
|
|
4
|
+
import {
|
|
5
|
+
animate as animateValue,
|
|
6
|
+
m,
|
|
7
|
+
useMotionValue,
|
|
8
|
+
useTransform
|
|
9
|
+
} from "motion/react";
|
|
10
|
+
import { memo, useEffect, useMemo } from "react";
|
|
11
|
+
import { DEFAULT_CHART_ENTER_TRANSITION } from "./animation";
|
|
12
|
+
import { radialNumberAt, useRadialChart } from "./radial-chart";
|
|
13
|
+
import { radialSeriesColor } from "./radial-series-color";
|
|
14
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
15
|
+
const EXPAND_STAGGER_S = 0.08;
|
|
16
|
+
const SWEEP_DELAY_S = 0.6;
|
|
17
|
+
const SWEEP_STAGGER_S = 0.1;
|
|
18
|
+
function useEnterProgress(animate, revealed, delay) {
|
|
19
|
+
const progress = useMotionValue(animate ? 0 : 1);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!animate) {
|
|
22
|
+
progress.jump(1);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!revealed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const controls = animateValue(progress, 1, {
|
|
29
|
+
...DEFAULT_CHART_ENTER_TRANSITION,
|
|
30
|
+
delay
|
|
31
|
+
});
|
|
32
|
+
return () => controls.stop();
|
|
33
|
+
}, [animate, revealed, progress, delay]);
|
|
34
|
+
return progress;
|
|
35
|
+
}
|
|
36
|
+
function segmentArc(segment, p, inner, outer, pad, direction, toAngle) {
|
|
37
|
+
const half = pad / 2 * direction;
|
|
38
|
+
return {
|
|
39
|
+
inner,
|
|
40
|
+
outer,
|
|
41
|
+
start: toAngle(segment.y0 * p) - (segment.padStart ? half : 0),
|
|
42
|
+
end: toAngle(segment.y1 * p) + (segment.padEnd ? half : 0),
|
|
43
|
+
pad
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const RingSegmentPath = memo(function RingSegmentPath2({
|
|
47
|
+
segment,
|
|
48
|
+
progress,
|
|
49
|
+
static: isStatic,
|
|
50
|
+
arcPath,
|
|
51
|
+
inner,
|
|
52
|
+
outer,
|
|
53
|
+
pad,
|
|
54
|
+
direction,
|
|
55
|
+
toAngle,
|
|
56
|
+
dimmed,
|
|
57
|
+
seriesFadedOpacity
|
|
58
|
+
}) {
|
|
59
|
+
const d = useTransform(
|
|
60
|
+
progress,
|
|
61
|
+
(p) => arcPath(segmentArc(segment, p, inner, outer, pad, direction, toAngle))
|
|
62
|
+
);
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
"g",
|
|
65
|
+
{
|
|
66
|
+
style: {
|
|
67
|
+
opacity: segment.opacity * (dimmed ? seriesFadedOpacity : 1),
|
|
68
|
+
transition: "opacity 0.15s ease-out"
|
|
69
|
+
},
|
|
70
|
+
children: isStatic ? /* @__PURE__ */ jsx(
|
|
71
|
+
"path",
|
|
72
|
+
{
|
|
73
|
+
d: arcPath(
|
|
74
|
+
segmentArc(segment, 1, inner, outer, pad, direction, toAngle)
|
|
75
|
+
),
|
|
76
|
+
fill: segment.fill
|
|
77
|
+
}
|
|
78
|
+
) : /* @__PURE__ */ jsx(m.path, { d, fill: segment.fill })
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
const RingRow = memo(function RingRow2({
|
|
83
|
+
index,
|
|
84
|
+
segments,
|
|
85
|
+
inner,
|
|
86
|
+
outer,
|
|
87
|
+
pad,
|
|
88
|
+
direction,
|
|
89
|
+
arcPath,
|
|
90
|
+
toAngle,
|
|
91
|
+
trackPath,
|
|
92
|
+
trackColor,
|
|
93
|
+
trackOpacity,
|
|
94
|
+
revealed,
|
|
95
|
+
animate,
|
|
96
|
+
faded,
|
|
97
|
+
fadedOpacity,
|
|
98
|
+
hoveredSeries,
|
|
99
|
+
seriesFadedOpacity
|
|
100
|
+
}) {
|
|
101
|
+
const expand = useEnterProgress(animate, revealed, index * EXPAND_STAGGER_S);
|
|
102
|
+
const sweep = useEnterProgress(
|
|
103
|
+
animate,
|
|
104
|
+
revealed,
|
|
105
|
+
SWEEP_DELAY_S + index * SWEEP_STAGGER_S
|
|
106
|
+
);
|
|
107
|
+
const expandDone = useEnterComplete(expand);
|
|
108
|
+
const sweepDone = useEnterComplete(sweep);
|
|
109
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
110
|
+
trackPath ? /* @__PURE__ */ jsx("path", { d: trackPath, fill: trackColor, fillOpacity: trackOpacity }) : null,
|
|
111
|
+
segments.map((segment) => /* @__PURE__ */ jsx(
|
|
112
|
+
RingSegmentPath,
|
|
113
|
+
{
|
|
114
|
+
arcPath,
|
|
115
|
+
dimmed: hoveredSeries !== null && hoveredSeries !== segment.seriesIndex,
|
|
116
|
+
direction,
|
|
117
|
+
inner,
|
|
118
|
+
outer,
|
|
119
|
+
pad,
|
|
120
|
+
progress: sweep,
|
|
121
|
+
segment,
|
|
122
|
+
seriesFadedOpacity,
|
|
123
|
+
static: !animate || sweepDone,
|
|
124
|
+
toAngle
|
|
125
|
+
},
|
|
126
|
+
segment.key
|
|
127
|
+
))
|
|
128
|
+
] });
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
"g",
|
|
131
|
+
{
|
|
132
|
+
style: {
|
|
133
|
+
opacity: faded ? fadedOpacity : 1,
|
|
134
|
+
transition: "opacity 0.15s ease-out"
|
|
135
|
+
},
|
|
136
|
+
children: !animate || expandDone ? content : /* @__PURE__ */ jsx(m.g, { style: { scale: expand, transformOrigin: "0px 0px" }, children: content })
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
function RadialRingBar({
|
|
141
|
+
maxValue: maxValueProp,
|
|
142
|
+
cornerRadius = 0,
|
|
143
|
+
segmentGap = 0,
|
|
144
|
+
track = true,
|
|
145
|
+
trackColor = "var(--chart-foreground)",
|
|
146
|
+
trackOpacity = 0.06,
|
|
147
|
+
fadedOpacity = 0.35,
|
|
148
|
+
seriesFadedOpacity = 0.2
|
|
149
|
+
}) {
|
|
150
|
+
const {
|
|
151
|
+
data,
|
|
152
|
+
series,
|
|
153
|
+
binCount,
|
|
154
|
+
startAngle,
|
|
155
|
+
endAngle,
|
|
156
|
+
isFullCircle,
|
|
157
|
+
valueDomain,
|
|
158
|
+
valueToAngle,
|
|
159
|
+
ringBand,
|
|
160
|
+
hoveredIndex,
|
|
161
|
+
hoveredSeries,
|
|
162
|
+
revealed,
|
|
163
|
+
animate
|
|
164
|
+
} = useRadialChart();
|
|
165
|
+
const direction = endAngle >= startAngle ? 1 : -1;
|
|
166
|
+
const toAngle = useMemo(() => {
|
|
167
|
+
if (maxValueProp === void 0) {
|
|
168
|
+
return valueToAngle;
|
|
169
|
+
}
|
|
170
|
+
const lo = valueDomain[0];
|
|
171
|
+
const span = endAngle - startAngle;
|
|
172
|
+
return (value) => {
|
|
173
|
+
const t = maxValueProp > lo ? (value - lo) / (maxValueProp - lo) : 0;
|
|
174
|
+
return startAngle + Math.min(1, Math.max(0, t)) * span;
|
|
175
|
+
};
|
|
176
|
+
}, [maxValueProp, valueToAngle, valueDomain, startAngle, endAngle]);
|
|
177
|
+
const arcPath = useMemo(() => {
|
|
178
|
+
const generator = d3Arc().innerRadius((d) => d.inner).outerRadius((d) => d.outer).startAngle((d) => d.start).endAngle((d) => d.end).padAngle((d) => d.pad).cornerRadius(
|
|
179
|
+
(d) => cornerRadius === "round" ? (d.outer - d.inner) / 2 : cornerRadius
|
|
180
|
+
);
|
|
181
|
+
return (d) => Math.abs(d.end - d.start) <= d.pad + 1e-4 ? "" : generator(d) ?? "";
|
|
182
|
+
}, [cornerRadius]);
|
|
183
|
+
const rings = useMemo(
|
|
184
|
+
() => data.map((d, index) => {
|
|
185
|
+
const band = ringBand(index);
|
|
186
|
+
const segments = [];
|
|
187
|
+
let y0 = 0;
|
|
188
|
+
series.forEach((s, seriesIndex) => {
|
|
189
|
+
const value = Math.max(0, radialNumberAt(d, s.dataKey) ?? 0);
|
|
190
|
+
if (value <= 0) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
segments.push({
|
|
194
|
+
key: s.dataKey,
|
|
195
|
+
seriesIndex,
|
|
196
|
+
fill: radialSeriesColor(s, seriesIndex),
|
|
197
|
+
opacity: s.opacity ?? 1,
|
|
198
|
+
y0,
|
|
199
|
+
y1: y0 + value,
|
|
200
|
+
padStart: false,
|
|
201
|
+
padEnd: false
|
|
202
|
+
});
|
|
203
|
+
y0 += value;
|
|
204
|
+
});
|
|
205
|
+
const first = segments[0];
|
|
206
|
+
const last = segments.at(-1);
|
|
207
|
+
if (first && last && !isFullCircle) {
|
|
208
|
+
first.padStart = true;
|
|
209
|
+
last.padEnd = true;
|
|
210
|
+
}
|
|
211
|
+
const padRadius = Math.sqrt(band.inner ** 2 + band.outer ** 2);
|
|
212
|
+
const pad = segmentGap > 0 && segments.length > 0 && padRadius > 0 ? segmentGap / padRadius : 0;
|
|
213
|
+
return { index, band, segments, pad };
|
|
214
|
+
}),
|
|
215
|
+
[data, series, ringBand, segmentGap, isFullCircle]
|
|
216
|
+
);
|
|
217
|
+
if (binCount === 0) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return /* @__PURE__ */ jsx("g", { pointerEvents: "none", children: rings.map((ring) => /* @__PURE__ */ jsx(
|
|
221
|
+
RingRow,
|
|
222
|
+
{
|
|
223
|
+
animate,
|
|
224
|
+
arcPath,
|
|
225
|
+
direction,
|
|
226
|
+
faded: hoveredIndex !== null && hoveredIndex !== ring.index,
|
|
227
|
+
fadedOpacity,
|
|
228
|
+
hoveredSeries,
|
|
229
|
+
index: ring.index,
|
|
230
|
+
inner: ring.band.inner,
|
|
231
|
+
outer: ring.band.outer,
|
|
232
|
+
pad: ring.pad,
|
|
233
|
+
revealed,
|
|
234
|
+
segments: ring.segments,
|
|
235
|
+
seriesFadedOpacity,
|
|
236
|
+
toAngle,
|
|
237
|
+
trackColor,
|
|
238
|
+
trackOpacity,
|
|
239
|
+
trackPath: track ? arcPath({
|
|
240
|
+
inner: ring.band.inner,
|
|
241
|
+
outer: ring.band.outer,
|
|
242
|
+
start: startAngle,
|
|
243
|
+
end: endAngle,
|
|
244
|
+
pad: 0
|
|
245
|
+
}) : null
|
|
246
|
+
},
|
|
247
|
+
ring.index
|
|
248
|
+
)) });
|
|
249
|
+
}
|
|
250
|
+
RadialRingBar.displayName = "RadialRingBar";
|
|
251
|
+
var radial_ring_bar_default = RadialRingBar;
|
|
252
|
+
export {
|
|
253
|
+
RadialRingBar,
|
|
254
|
+
radial_ring_bar_default as default
|
|
255
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m, useTransform } from "motion/react";
|
|
4
|
+
import { useId, useLayoutEffect } from "react";
|
|
5
|
+
import {
|
|
6
|
+
RADIAL_CROSSHAIR_SPRING,
|
|
7
|
+
useRadialAngleSpring,
|
|
8
|
+
useRadialChart
|
|
9
|
+
} from "./radial-chart";
|
|
10
|
+
function RadialScrubber({
|
|
11
|
+
variant = "solid",
|
|
12
|
+
dashArray = "4 4",
|
|
13
|
+
showDot: showDotProp,
|
|
14
|
+
color = "var(--chart-foreground)",
|
|
15
|
+
lineOpacity = 0.7,
|
|
16
|
+
strokeWidth = 1.5,
|
|
17
|
+
dotRadius,
|
|
18
|
+
rest: restProp,
|
|
19
|
+
spring: springOptions = RADIAL_CROSSHAIR_SPRING
|
|
20
|
+
}) {
|
|
21
|
+
const {
|
|
22
|
+
binCount,
|
|
23
|
+
nowIndex,
|
|
24
|
+
trackNow,
|
|
25
|
+
hoveredIndex,
|
|
26
|
+
binAngle,
|
|
27
|
+
binStartAngle,
|
|
28
|
+
isFullCircle,
|
|
29
|
+
orientation,
|
|
30
|
+
centerRadius,
|
|
31
|
+
radius,
|
|
32
|
+
layout,
|
|
33
|
+
reducedMotion,
|
|
34
|
+
registerCrosshair
|
|
35
|
+
} = useRadialChart();
|
|
36
|
+
const gradientId = `radial-scrubber-${useId().replace(/:/g, "")}`;
|
|
37
|
+
const rest = restProp ?? (trackNow ? "now" : "hidden");
|
|
38
|
+
const hidden = hoveredIndex === null && rest === "hidden";
|
|
39
|
+
const angle = hoveredIndex === null ? binStartAngle(nowIndex + 1) : binAngle(hoveredIndex);
|
|
40
|
+
const spring = useRadialAngleSpring({
|
|
41
|
+
angle,
|
|
42
|
+
hidden,
|
|
43
|
+
isFullCircle,
|
|
44
|
+
snap: reducedMotion,
|
|
45
|
+
spring: springOptions
|
|
46
|
+
});
|
|
47
|
+
const drawn = binCount > 0 && orientation !== "angular";
|
|
48
|
+
useLayoutEffect(
|
|
49
|
+
() => drawn ? registerCrosshair(spring) : void 0,
|
|
50
|
+
[drawn, registerCrosshair, spring]
|
|
51
|
+
);
|
|
52
|
+
const inner = centerRadius + 2;
|
|
53
|
+
const outer = radius * layout.scrubberOuter;
|
|
54
|
+
const x1 = useTransform(spring, (a) => inner * Math.sin(a));
|
|
55
|
+
const y1 = useTransform(spring, (a) => -inner * Math.cos(a));
|
|
56
|
+
const x2 = useTransform(spring, (a) => outer * Math.sin(a));
|
|
57
|
+
const y2 = useTransform(spring, (a) => -outer * Math.cos(a));
|
|
58
|
+
if (binCount === 0 || orientation === "angular") {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const gradient = variant === "gradient";
|
|
62
|
+
const dashed = variant === "dashed";
|
|
63
|
+
const showDot = showDotProp ?? !gradient;
|
|
64
|
+
return /* @__PURE__ */ jsxs(
|
|
65
|
+
"g",
|
|
66
|
+
{
|
|
67
|
+
pointerEvents: "none",
|
|
68
|
+
style: {
|
|
69
|
+
opacity: hidden ? 0 : 1,
|
|
70
|
+
transition: "opacity 0.15s ease-out"
|
|
71
|
+
},
|
|
72
|
+
children: [
|
|
73
|
+
gradient ? /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
|
|
74
|
+
m.linearGradient,
|
|
75
|
+
{
|
|
76
|
+
gradientUnits: "userSpaceOnUse",
|
|
77
|
+
id: gradientId,
|
|
78
|
+
x1,
|
|
79
|
+
x2,
|
|
80
|
+
y1,
|
|
81
|
+
y2,
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0 }),
|
|
84
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: 1 })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
) }) : null,
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
m.line,
|
|
90
|
+
{
|
|
91
|
+
stroke: gradient ? `url(#${gradientId})` : color,
|
|
92
|
+
strokeDasharray: dashed ? dashArray : void 0,
|
|
93
|
+
strokeLinecap: dashed ? "butt" : "round",
|
|
94
|
+
strokeOpacity: lineOpacity,
|
|
95
|
+
strokeWidth,
|
|
96
|
+
x1,
|
|
97
|
+
x2,
|
|
98
|
+
y1,
|
|
99
|
+
y2
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
showDot ? /* @__PURE__ */ jsx(
|
|
103
|
+
m.circle,
|
|
104
|
+
{
|
|
105
|
+
cx: x2,
|
|
106
|
+
cy: y2,
|
|
107
|
+
fill: color,
|
|
108
|
+
r: dotRadius ?? Math.max(2.5, radius * 0.011)
|
|
109
|
+
}
|
|
110
|
+
) : null
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
RadialScrubber.displayName = "RadialScrubber";
|
|
116
|
+
var radial_scrubber_default = RadialScrubber;
|
|
117
|
+
export {
|
|
118
|
+
RadialScrubber,
|
|
119
|
+
radial_scrubber_default as default
|
|
120
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
isValidElement
|
|
4
|
+
} from "react";
|
|
5
|
+
import { normalizeYAxisId } from "./y-axis-scales";
|
|
6
|
+
function getChildComponentName(child) {
|
|
7
|
+
const childType = child.type;
|
|
8
|
+
return typeof child.type === "function" ? childType.displayName || childType.name || "" : "";
|
|
9
|
+
}
|
|
10
|
+
function isReferenceAreaElement(child) {
|
|
11
|
+
return getChildComponentName(child) === "ReferenceArea";
|
|
12
|
+
}
|
|
13
|
+
function extractReferenceAreaConfigs(children) {
|
|
14
|
+
const configs = [];
|
|
15
|
+
const visit = (node) => {
|
|
16
|
+
Children.forEach(node, (child) => {
|
|
17
|
+
if (!isValidElement(child)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (isReferenceAreaElement(child)) {
|
|
21
|
+
const props = child.props;
|
|
22
|
+
if (props) {
|
|
23
|
+
configs.push({
|
|
24
|
+
yAxisId: normalizeYAxisId(props.yAxisId),
|
|
25
|
+
y1: props.y1,
|
|
26
|
+
y2: props.y2,
|
|
27
|
+
axisLabelColor: props.axisLabelColor
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const childProps = child.props;
|
|
33
|
+
if (childProps?.children) {
|
|
34
|
+
visit(childProps.children);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
visit(children);
|
|
39
|
+
return configs;
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
extractReferenceAreaConfigs
|
|
43
|
+
};
|