@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,316 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { 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, useId, useMemo } from "react";
|
|
11
|
+
import { radialNumberAt, useRadialChart } from "./radial-chart";
|
|
12
|
+
import { createRadialScale } from "./radial-geometry";
|
|
13
|
+
import { radialSeriesColor } from "./radial-series-color";
|
|
14
|
+
const ENTER_SPREAD_S = 0.6;
|
|
15
|
+
const ENTER_DURATION_S = 0.6;
|
|
16
|
+
const ENTER_EASE = [0.2, 0.8, 0.2, 1];
|
|
17
|
+
const RadialBarSegment = memo(function RadialBarSegment2({
|
|
18
|
+
segment,
|
|
19
|
+
column,
|
|
20
|
+
progress,
|
|
21
|
+
toRadius,
|
|
22
|
+
arcPath,
|
|
23
|
+
cornerRadius,
|
|
24
|
+
stackGap,
|
|
25
|
+
isTop,
|
|
26
|
+
clipPath,
|
|
27
|
+
dimmed,
|
|
28
|
+
seriesFadedOpacity
|
|
29
|
+
}) {
|
|
30
|
+
const d = useTransform(progress, (p) => {
|
|
31
|
+
const inner = toRadius(segment.y0 * p);
|
|
32
|
+
const outer = Math.max(
|
|
33
|
+
inner,
|
|
34
|
+
toRadius(segment.y1 * p) - (isTop ? 0 : stackGap)
|
|
35
|
+
);
|
|
36
|
+
return arcPath({
|
|
37
|
+
inner,
|
|
38
|
+
outer,
|
|
39
|
+
start: column.start,
|
|
40
|
+
end: column.end,
|
|
41
|
+
corner: stackGap > 0 ? cornerRadius : 0
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return (
|
|
45
|
+
// Opacity lives on a plain group: m.path doesn't re-apply a changed
|
|
46
|
+
// static `style.opacity`, which would break legend dimming.
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
"g",
|
|
49
|
+
{
|
|
50
|
+
style: {
|
|
51
|
+
opacity: segment.opacity * (dimmed ? seriesFadedOpacity : 1),
|
|
52
|
+
transition: "opacity 0.15s ease-out"
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ jsx(m.path, { clipPath, d, fill: segment.fill })
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
const RadialBarColumn = memo(function RadialBarColumn2({
|
|
60
|
+
column,
|
|
61
|
+
toRadius,
|
|
62
|
+
arcPath,
|
|
63
|
+
cornerRadius,
|
|
64
|
+
stackGap,
|
|
65
|
+
revealed,
|
|
66
|
+
animate,
|
|
67
|
+
faded,
|
|
68
|
+
fadedOpacity,
|
|
69
|
+
hoveredSeries,
|
|
70
|
+
seriesFadedOpacity
|
|
71
|
+
}) {
|
|
72
|
+
const progress = useMotionValue(animate ? 0 : 1);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!animate) {
|
|
75
|
+
progress.jump(1);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!revealed) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const controls = animateValue(progress, 1, {
|
|
82
|
+
duration: ENTER_DURATION_S,
|
|
83
|
+
delay: column.delay,
|
|
84
|
+
ease: ENTER_EASE
|
|
85
|
+
});
|
|
86
|
+
return () => controls.stop();
|
|
87
|
+
}, [animate, revealed, progress, column.delay]);
|
|
88
|
+
const top = column.segments.at(-1)?.y1 ?? 0;
|
|
89
|
+
const clipId = `radial-bar-clip-${useId().replace(/:/g, "")}`;
|
|
90
|
+
const useClip = cornerRadius > 0 && stackGap <= 0;
|
|
91
|
+
const outline = useTransform(
|
|
92
|
+
progress,
|
|
93
|
+
(p) => arcPath({
|
|
94
|
+
inner: toRadius(0),
|
|
95
|
+
outer: toRadius(top * p),
|
|
96
|
+
start: column.start,
|
|
97
|
+
end: column.end,
|
|
98
|
+
corner: cornerRadius
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
if (column.segments.length === 0) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
return /* @__PURE__ */ jsxs(
|
|
105
|
+
"g",
|
|
106
|
+
{
|
|
107
|
+
style: {
|
|
108
|
+
opacity: faded ? fadedOpacity : 1,
|
|
109
|
+
transition: "opacity 0.15s ease-out"
|
|
110
|
+
},
|
|
111
|
+
children: [
|
|
112
|
+
useClip ? /* @__PURE__ */ jsx("clipPath", { id: clipId, children: /* @__PURE__ */ jsx(m.path, { d: outline }) }) : null,
|
|
113
|
+
column.segments.map((segment, i) => /* @__PURE__ */ jsx(
|
|
114
|
+
RadialBarSegment,
|
|
115
|
+
{
|
|
116
|
+
arcPath,
|
|
117
|
+
clipPath: useClip ? `url(#${clipId})` : void 0,
|
|
118
|
+
column,
|
|
119
|
+
cornerRadius,
|
|
120
|
+
dimmed: hoveredSeries !== null && hoveredSeries !== segment.seriesIndex,
|
|
121
|
+
isTop: i === column.segments.length - 1,
|
|
122
|
+
progress,
|
|
123
|
+
segment,
|
|
124
|
+
seriesFadedOpacity,
|
|
125
|
+
stackGap,
|
|
126
|
+
toRadius
|
|
127
|
+
},
|
|
128
|
+
segment.key
|
|
129
|
+
))
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
function RadialBar({
|
|
135
|
+
ghostDataKey,
|
|
136
|
+
ghostColor = "var(--chart-foreground)",
|
|
137
|
+
ghostOpacity = 0.12,
|
|
138
|
+
maxValue: maxValueProp,
|
|
139
|
+
padAngle: padAngleProp,
|
|
140
|
+
cornerRadius = 0,
|
|
141
|
+
stackGap = 0,
|
|
142
|
+
rampExtent = 0.6,
|
|
143
|
+
fadedOpacity = 0.35,
|
|
144
|
+
seriesFadedOpacity = 0.2
|
|
145
|
+
}) {
|
|
146
|
+
const {
|
|
147
|
+
data,
|
|
148
|
+
series,
|
|
149
|
+
binCount,
|
|
150
|
+
innerRadius,
|
|
151
|
+
outerRadius,
|
|
152
|
+
futureBins,
|
|
153
|
+
hoveredIndex,
|
|
154
|
+
hoveredSeries,
|
|
155
|
+
revealed,
|
|
156
|
+
animate,
|
|
157
|
+
binStartAngle,
|
|
158
|
+
binWidth,
|
|
159
|
+
sharedValueScale,
|
|
160
|
+
valueScale
|
|
161
|
+
} = useRadialChart();
|
|
162
|
+
const gradientPrefix = `radial-bar-ramp-${useId().replace(/:/g, "")}`;
|
|
163
|
+
const maxValue = useMemo(() => {
|
|
164
|
+
if (maxValueProp !== void 0) {
|
|
165
|
+
return maxValueProp;
|
|
166
|
+
}
|
|
167
|
+
let max = 0;
|
|
168
|
+
data.forEach((d, i) => {
|
|
169
|
+
const value = futureBins[i] ? (ghostDataKey ? radialNumberAt(d, ghostDataKey) : 0) ?? 0 : series.reduce(
|
|
170
|
+
(sum, s) => sum + Math.max(0, radialNumberAt(d, s.dataKey) ?? 0),
|
|
171
|
+
0
|
|
172
|
+
);
|
|
173
|
+
max = Math.max(max, value);
|
|
174
|
+
});
|
|
175
|
+
return max;
|
|
176
|
+
}, [maxValueProp, data, series, futureBins, ghostDataKey]);
|
|
177
|
+
const toRadius = useMemo(() => {
|
|
178
|
+
if (maxValueProp === void 0 && sharedValueScale) {
|
|
179
|
+
return (value) => valueScale(Math.max(0, value));
|
|
180
|
+
}
|
|
181
|
+
const scale = createRadialScale({ maxValue, innerRadius, outerRadius });
|
|
182
|
+
return (value) => scale(Math.max(0, value)) ?? innerRadius;
|
|
183
|
+
}, [
|
|
184
|
+
maxValueProp,
|
|
185
|
+
sharedValueScale,
|
|
186
|
+
valueScale,
|
|
187
|
+
maxValue,
|
|
188
|
+
innerRadius,
|
|
189
|
+
outerRadius
|
|
190
|
+
]);
|
|
191
|
+
const padAngle = padAngleProp ?? Math.abs(binWidth) * 0.18;
|
|
192
|
+
const arcPath = useMemo(() => {
|
|
193
|
+
const generator = d3Arc().innerRadius((a) => a.inner).outerRadius((a) => a.outer).startAngle((a) => a.start).endAngle((a) => a.end).cornerRadius((a) => a.corner).padAngle(padAngle).padRadius(innerRadius);
|
|
194
|
+
return (radii) => generator(radii) ?? "";
|
|
195
|
+
}, [padAngle, innerRadius]);
|
|
196
|
+
const rampFills = useMemo(
|
|
197
|
+
() => series.map(
|
|
198
|
+
(s, i) => (s.rampFrom ?? 1) < 1 ? `url(#${gradientPrefix}-${i})` : null
|
|
199
|
+
),
|
|
200
|
+
[series, gradientPrefix]
|
|
201
|
+
);
|
|
202
|
+
const columns = useMemo(
|
|
203
|
+
() => data.map((d, index) => {
|
|
204
|
+
const start = binStartAngle(index);
|
|
205
|
+
const delay = index / Math.max(1, binCount) * ENTER_SPREAD_S;
|
|
206
|
+
const column = { index, start, end: start + binWidth, delay };
|
|
207
|
+
if (futureBins[index]) {
|
|
208
|
+
const ghost = ghostDataKey ? radialNumberAt(d, ghostDataKey) ?? 0 : 0;
|
|
209
|
+
return {
|
|
210
|
+
...column,
|
|
211
|
+
segments: ghost > 0 ? [
|
|
212
|
+
{
|
|
213
|
+
key: "ghost",
|
|
214
|
+
seriesIndex: -1,
|
|
215
|
+
fill: ghostColor,
|
|
216
|
+
opacity: ghostOpacity,
|
|
217
|
+
y0: 0,
|
|
218
|
+
y1: ghost
|
|
219
|
+
}
|
|
220
|
+
] : []
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const segments = [];
|
|
224
|
+
let y0 = 0;
|
|
225
|
+
series.forEach((s, seriesIndex) => {
|
|
226
|
+
const value = Math.max(0, radialNumberAt(d, s.dataKey) ?? 0);
|
|
227
|
+
if (value <= 0) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
segments.push({
|
|
231
|
+
key: s.dataKey,
|
|
232
|
+
seriesIndex,
|
|
233
|
+
fill: rampFills[seriesIndex] ?? radialSeriesColor(s, seriesIndex),
|
|
234
|
+
opacity: s.opacity ?? 1,
|
|
235
|
+
y0,
|
|
236
|
+
y1: y0 + value
|
|
237
|
+
});
|
|
238
|
+
y0 += value;
|
|
239
|
+
});
|
|
240
|
+
return { ...column, segments };
|
|
241
|
+
}),
|
|
242
|
+
[
|
|
243
|
+
data,
|
|
244
|
+
binCount,
|
|
245
|
+
binStartAngle,
|
|
246
|
+
binWidth,
|
|
247
|
+
futureBins,
|
|
248
|
+
ghostDataKey,
|
|
249
|
+
ghostColor,
|
|
250
|
+
ghostOpacity,
|
|
251
|
+
series,
|
|
252
|
+
rampFills
|
|
253
|
+
]
|
|
254
|
+
);
|
|
255
|
+
if (binCount === 0 || outerRadius <= innerRadius) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
const rampStart = innerRadius / outerRadius;
|
|
259
|
+
const rampEnd = (innerRadius + (outerRadius - innerRadius) * rampExtent) / outerRadius;
|
|
260
|
+
return /* @__PURE__ */ jsxs("g", { pointerEvents: "none", children: [
|
|
261
|
+
/* @__PURE__ */ jsx("defs", { children: series.map(
|
|
262
|
+
(s, i) => rampFills[i] ? /* @__PURE__ */ jsxs(
|
|
263
|
+
"radialGradient",
|
|
264
|
+
{
|
|
265
|
+
cx: 0,
|
|
266
|
+
cy: 0,
|
|
267
|
+
gradientUnits: "userSpaceOnUse",
|
|
268
|
+
id: `${gradientPrefix}-${i}`,
|
|
269
|
+
r: outerRadius,
|
|
270
|
+
children: [
|
|
271
|
+
/* @__PURE__ */ jsx(
|
|
272
|
+
"stop",
|
|
273
|
+
{
|
|
274
|
+
offset: rampStart,
|
|
275
|
+
stopColor: radialSeriesColor(s, i),
|
|
276
|
+
stopOpacity: s.rampFrom ?? 1
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
/* @__PURE__ */ jsx(
|
|
280
|
+
"stop",
|
|
281
|
+
{
|
|
282
|
+
offset: rampEnd,
|
|
283
|
+
stopColor: radialSeriesColor(s, i),
|
|
284
|
+
stopOpacity: 1
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
s.dataKey
|
|
290
|
+
) : null
|
|
291
|
+
) }),
|
|
292
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
293
|
+
RadialBarColumn,
|
|
294
|
+
{
|
|
295
|
+
animate,
|
|
296
|
+
arcPath,
|
|
297
|
+
column,
|
|
298
|
+
cornerRadius,
|
|
299
|
+
faded: hoveredIndex !== null && hoveredIndex !== column.index,
|
|
300
|
+
fadedOpacity,
|
|
301
|
+
hoveredSeries,
|
|
302
|
+
revealed,
|
|
303
|
+
seriesFadedOpacity,
|
|
304
|
+
stackGap,
|
|
305
|
+
toRadius
|
|
306
|
+
},
|
|
307
|
+
column.index
|
|
308
|
+
))
|
|
309
|
+
] });
|
|
310
|
+
}
|
|
311
|
+
RadialBar.displayName = "RadialBar";
|
|
312
|
+
var radial_bar_default = RadialBar;
|
|
313
|
+
export {
|
|
314
|
+
RadialBar,
|
|
315
|
+
radial_bar_default as default
|
|
316
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { cn } from "../lib/utils";
|
|
5
|
+
import {
|
|
6
|
+
chartCenterContainerClassName,
|
|
7
|
+
chartCenterLabelClassName,
|
|
8
|
+
chartCenterValueClassName
|
|
9
|
+
} from "./chart-center-typography";
|
|
10
|
+
import { ChartStatFlow } from "./chart-stat-flow";
|
|
11
|
+
import { radialNumberAt, useRadialChart } from "./radial-chart";
|
|
12
|
+
function RadialCenter({
|
|
13
|
+
defaultLabel = "Total",
|
|
14
|
+
formatOptions,
|
|
15
|
+
prefix,
|
|
16
|
+
suffix,
|
|
17
|
+
className,
|
|
18
|
+
valueClassName = chartCenterValueClassName,
|
|
19
|
+
labelClassName = chartCenterLabelClassName,
|
|
20
|
+
children
|
|
21
|
+
}) {
|
|
22
|
+
const { data, series, xDataKey, hoveredIndex, futureBins, totals } = useRadialChart();
|
|
23
|
+
const state = useMemo(() => {
|
|
24
|
+
const datum = hoveredIndex === null ? null : data[hoveredIndex] ?? null;
|
|
25
|
+
const values = {};
|
|
26
|
+
for (const s of series) {
|
|
27
|
+
values[s.dataKey] = radialNumberAt(datum, s.dataKey) ?? 0;
|
|
28
|
+
}
|
|
29
|
+
const rawLabel = datum?.[xDataKey];
|
|
30
|
+
return {
|
|
31
|
+
index: hoveredIndex,
|
|
32
|
+
datum,
|
|
33
|
+
label: rawLabel === void 0 ? null : String(rawLabel),
|
|
34
|
+
isFuture: hoveredIndex === null ? false : Boolean(futureBins[hoveredIndex]),
|
|
35
|
+
totals,
|
|
36
|
+
values
|
|
37
|
+
};
|
|
38
|
+
}, [data, series, xDataKey, hoveredIndex, futureBins, totals]);
|
|
39
|
+
const containerClassName = cn(
|
|
40
|
+
chartCenterContainerClassName,
|
|
41
|
+
"flex flex-col items-center justify-center text-center",
|
|
42
|
+
className
|
|
43
|
+
);
|
|
44
|
+
if (children) {
|
|
45
|
+
return /* @__PURE__ */ jsx("div", { className: containerClassName, children: children(state) });
|
|
46
|
+
}
|
|
47
|
+
const source = state.datum ? state.values : state.totals;
|
|
48
|
+
const value = Object.values(source).reduce((sum, v) => sum + v, 0);
|
|
49
|
+
return /* @__PURE__ */ jsx("div", { className: containerClassName, children: /* @__PURE__ */ jsx(
|
|
50
|
+
ChartStatFlow,
|
|
51
|
+
{
|
|
52
|
+
formatOptions,
|
|
53
|
+
label: state.label ?? defaultLabel,
|
|
54
|
+
labelClassName,
|
|
55
|
+
prefix,
|
|
56
|
+
suffix,
|
|
57
|
+
value,
|
|
58
|
+
valueClassName
|
|
59
|
+
}
|
|
60
|
+
) });
|
|
61
|
+
}
|
|
62
|
+
RadialCenter.displayName = "RadialCenter";
|
|
63
|
+
var radial_center_default = RadialCenter;
|
|
64
|
+
export {
|
|
65
|
+
RadialCenter,
|
|
66
|
+
radial_center_default as default
|
|
67
|
+
};
|