@aiconstructions/graficos 0.0.0-stage → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ALTERACOES.md +57 -0
- package/LICENSE-BKLIT +21 -0
- package/LICENSE-visx-pattern +21 -0
- package/README.md +189 -2
- package/dist/aic/cores.js +83 -0
- package/dist/aic/index.js +22 -0
- package/dist/aic/interacao.js +55 -0
- package/dist/charts/animation.js +55 -0
- package/dist/charts/arc-geometry.js +58 -0
- package/dist/charts/arc-path.js +15 -0
- package/dist/charts/area-chart-loading.js +89 -0
- package/dist/charts/area-chart.js +149 -0
- package/dist/charts/area-gradient-defs.js +90 -0
- package/dist/charts/area-value-label-layout.js +70 -0
- package/dist/charts/area-value-labels.js +211 -0
- package/dist/charts/area.js +272 -0
- package/dist/charts/background.js +198 -0
- package/dist/charts/band-config.js +82 -0
- package/dist/charts/band-geometry.js +186 -0
- package/dist/charts/band.js +346 -0
- package/dist/charts/bar-chart-loading.js +27 -0
- package/dist/charts/bar-chart.js +545 -0
- package/dist/charts/bar-depth-geometry.js +18 -0
- package/dist/charts/bar-depth.js +608 -0
- package/dist/charts/bar-lollipop.js +278 -0
- package/dist/charts/bar-squares-layout.js +66 -0
- package/dist/charts/bar-squares.js +467 -0
- package/dist/charts/bar-value-label-layout.js +42 -0
- package/dist/charts/bar-x-axis.js +133 -0
- package/dist/charts/bar-y-axis.js +116 -0
- package/dist/charts/bar.js +457 -0
- package/dist/charts/bollinger.js +49 -0
- package/dist/charts/candlestick-chart.js +370 -0
- package/dist/charts/candlestick.js +368 -0
- package/dist/charts/chart-brush-handle.js +91 -0
- package/dist/charts/chart-brush-layout.js +91 -0
- package/dist/charts/chart-brush-selection-overlay.js +87 -0
- package/dist/charts/chart-brush-state.js +253 -0
- package/dist/charts/chart-brush-track-overlay.js +103 -0
- package/dist/charts/chart-brush.js +517 -0
- package/dist/charts/chart-center-typography.js +8 -0
- package/dist/charts/chart-child-passthrough.js +119 -0
- package/dist/charts/chart-config-context.js +56 -0
- package/dist/charts/chart-context.js +337 -0
- package/dist/charts/chart-crosshair.js +262 -0
- package/dist/charts/chart-data-override.js +186 -0
- package/dist/charts/chart-defs.js +56 -0
- package/dist/charts/chart-formatters.js +77 -0
- package/dist/charts/chart-legend-hover.js +27 -0
- package/dist/charts/chart-legend.js +163 -0
- package/dist/charts/chart-loading-label.js +52 -0
- package/dist/charts/chart-parent-size.js +138 -0
- package/dist/charts/chart-phase.js +29 -0
- package/dist/charts/chart-reveal-clip.js +62 -0
- package/dist/charts/chart-scale.js +19 -0
- package/dist/charts/chart-stat-flow.js +72 -0
- package/dist/charts/choropleth/choropleth-background.js +29 -0
- package/dist/charts/choropleth/choropleth-camera.js +379 -0
- package/dist/charts/choropleth/choropleth-chart.js +644 -0
- package/dist/charts/choropleth/choropleth-context.js +152 -0
- package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
- package/dist/charts/choropleth/choropleth-feature.js +291 -0
- package/dist/charts/choropleth/choropleth-graticule.js +40 -0
- package/dist/charts/choropleth/choropleth-marker.js +222 -0
- package/dist/charts/choropleth/choropleth-projection.js +37 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
- package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
- package/dist/charts/choropleth/index.js +44 -0
- package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
- package/dist/charts/composed-chart.js +346 -0
- package/dist/charts/crosshair-store.js +49 -0
- package/dist/charts/dash-tail-stroke.js +58 -0
- package/dist/charts/date-pill-store.js +50 -0
- package/dist/charts/date-ranges.js +131 -0
- package/dist/charts/deadline.js +295 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.js +171 -0
- package/dist/charts/fast-path.js +78 -0
- package/dist/charts/filter-data-by-x-domain.js +45 -0
- package/dist/charts/funnel-chart.js +773 -0
- package/dist/charts/gauge-arc-layers.js +479 -0
- package/dist/charts/gauge-dial.js +329 -0
- package/dist/charts/gauge-label-layout.js +148 -0
- package/dist/charts/gauge.js +946 -0
- package/dist/charts/generate-chart-skeleton-data.js +27 -0
- package/dist/charts/gradients.js +158 -0
- package/dist/charts/grid-lines.js +114 -0
- package/dist/charts/grid.js +225 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
- package/dist/charts/heatmap/heatmap-animation.js +128 -0
- package/dist/charts/heatmap/heatmap-cells.js +519 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
- package/dist/charts/heatmap/heatmap-chart.js +548 -0
- package/dist/charts/heatmap/heatmap-colors.js +127 -0
- package/dist/charts/heatmap/heatmap-context.js +107 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
- package/dist/charts/heatmap/heatmap-legend.js +165 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
- package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
- package/dist/charts/heatmap/heatmap-separator.js +168 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
- package/dist/charts/heatmap/heatmap-utils.js +633 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
- package/dist/charts/heatmap/index.js +208 -0
- package/dist/charts/highlight-segment-bounds.js +34 -0
- package/dist/charts/highlight-segment.js +119 -0
- package/dist/charts/index.js +944 -0
- package/dist/charts/indicator-fade.js +44 -0
- package/dist/charts/legend/index.js +22 -0
- package/dist/charts/legend/legend-context.js +47 -0
- package/dist/charts/legend/legend-item.js +30 -0
- package/dist/charts/legend/legend-label.js +14 -0
- package/dist/charts/legend/legend-marker.js +18 -0
- package/dist/charts/legend/legend-progress.js +39 -0
- package/dist/charts/legend/legend-value.js +31 -0
- package/dist/charts/legend/legend.js +69 -0
- package/dist/charts/line-backdrop.js +129 -0
- package/dist/charts/line-chart-loading.js +85 -0
- package/dist/charts/line-chart.js +182 -0
- package/dist/charts/line-loading-pulse.js +185 -0
- package/dist/charts/line-loading-timing.js +12 -0
- package/dist/charts/line-path.js +58 -0
- package/dist/charts/line-series-terminal-marker.js +75 -0
- package/dist/charts/line.js +499 -0
- package/dist/charts/live-line-chart.js +494 -0
- package/dist/charts/live-line.js +277 -0
- package/dist/charts/live-x-axis.js +116 -0
- package/dist/charts/live-y-axis.js +164 -0
- package/dist/charts/loading-sweep.js +344 -0
- package/dist/charts/local-point.js +56 -0
- package/dist/charts/markers/chart-markers.js +149 -0
- package/dist/charts/markers/index.js +14 -0
- package/dist/charts/markers/marker-group.js +411 -0
- package/dist/charts/motion-utils.js +29 -0
- package/dist/charts/notch-gauge-shared.js +146 -0
- package/dist/charts/particle-line.js +1340 -0
- package/dist/charts/path-stroke-utils.js +51 -0
- package/dist/charts/pattern-area.js +127 -0
- package/dist/charts/pattern-preset.js +287 -0
- package/dist/charts/pattern-tile.js +31 -0
- package/dist/charts/patterns/circles.js +62 -0
- package/dist/charts/patterns/constants.js +9 -0
- package/dist/charts/patterns/hexagons.js +38 -0
- package/dist/charts/patterns/index.js +16 -0
- package/dist/charts/patterns/lines.js +65 -0
- package/dist/charts/patterns/path.js +37 -0
- package/dist/charts/patterns/pattern.js +16 -0
- package/dist/charts/patterns/waves.js +40 -0
- package/dist/charts/pie-center-shell.js +127 -0
- package/dist/charts/pie-center.js +87 -0
- package/dist/charts/pie-chart.js +377 -0
- package/dist/charts/pie-context.js +116 -0
- package/dist/charts/pie-slice.js +394 -0
- package/dist/charts/pie-ticks.js +332 -0
- package/dist/charts/profit-loss-legend-hover.js +18 -0
- package/dist/charts/profit-loss-legend.js +53 -0
- package/dist/charts/profit-loss-line.js +162 -0
- package/dist/charts/profit-loss-segments.js +88 -0
- package/dist/charts/projection-config.js +90 -0
- package/dist/charts/projection-line-end-marker.js +50 -0
- package/dist/charts/projection-line.js +466 -0
- package/dist/charts/projection-utils.js +303 -0
- package/dist/charts/radar-area.js +192 -0
- package/dist/charts/radar-axis.js +41 -0
- package/dist/charts/radar-chart.js +184 -0
- package/dist/charts/radar-context.js +104 -0
- package/dist/charts/radar-grid.js +121 -0
- package/dist/charts/radar-labels.js +62 -0
- package/dist/charts/radial-area.js +498 -0
- package/dist/charts/radial-axis.js +652 -0
- package/dist/charts/radial-bar.js +316 -0
- package/dist/charts/radial-center.js +67 -0
- package/dist/charts/radial-chart.js +740 -0
- package/dist/charts/radial-dot-bar-layout.js +68 -0
- package/dist/charts/radial-dot-bar.js +387 -0
- package/dist/charts/radial-geometry.js +114 -0
- package/dist/charts/radial-legend.js +66 -0
- package/dist/charts/radial-line.js +280 -0
- package/dist/charts/radial-ring-bar.js +255 -0
- package/dist/charts/radial-scrubber.js +120 -0
- package/dist/charts/radial-series-color.js +10 -0
- package/dist/charts/reference-area-config.js +43 -0
- package/dist/charts/reference-area-geometry.js +76 -0
- package/dist/charts/reference-area-registration-context.js +10 -0
- package/dist/charts/reference-area.js +241 -0
- package/dist/charts/responsive-chart-label-count.js +18 -0
- package/dist/charts/ring-center.js +78 -0
- package/dist/charts/ring-chart.js +362 -0
- package/dist/charts/ring-context.js +122 -0
- package/dist/charts/ring-grid.js +175 -0
- package/dist/charts/ring-labels.js +109 -0
- package/dist/charts/ring.js +237 -0
- package/dist/charts/sankey/index.js +22 -0
- package/dist/charts/sankey/sankey-chart.js +199 -0
- package/dist/charts/sankey/sankey-context.js +32 -0
- package/dist/charts/sankey/sankey-link.js +232 -0
- package/dist/charts/sankey/sankey-node.js +348 -0
- package/dist/charts/sankey/sankey-tooltip.js +94 -0
- package/dist/charts/scatter-chart-shell.js +279 -0
- package/dist/charts/scatter-chart.js +150 -0
- package/dist/charts/scatter-jitter.js +86 -0
- package/dist/charts/scatter-svg.js +17 -0
- package/dist/charts/scatter.js +92 -0
- package/dist/charts/segment.js +107 -0
- package/dist/charts/series-bar-layout.js +42 -0
- package/dist/charts/series-bar.js +241 -0
- package/dist/charts/series-dash-tail-overlay.js +53 -0
- package/dist/charts/series-highlight-layer.js +43 -0
- package/dist/charts/series-hover-dim.js +32 -0
- package/dist/charts/series-markers.js +239 -0
- package/dist/charts/series-path-utils.js +185 -0
- package/dist/charts/series-point-marker.js +150 -0
- package/dist/charts/sparkline-geometry.js +197 -0
- package/dist/charts/sparkline.js +910 -0
- package/dist/charts/static-chart-preview-context.js +16 -0
- package/dist/charts/sunburst-breadcrumb.js +33 -0
- package/dist/charts/sunburst-center.js +37 -0
- package/dist/charts/sunburst-chart.js +408 -0
- package/dist/charts/sunburst-context.js +140 -0
- package/dist/charts/sunburst-data.js +0 -0
- package/dist/charts/sunburst-hint.js +42 -0
- package/dist/charts/sunburst-labels.js +130 -0
- package/dist/charts/sunburst-segment.js +144 -0
- package/dist/charts/sunburst.js +419 -0
- package/dist/charts/time-series-chart-shell.js +688 -0
- package/dist/charts/tooltip/chart-tooltip.js +516 -0
- package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
- package/dist/charts/tooltip/date-ticker.js +376 -0
- package/dist/charts/tooltip/index.js +32 -0
- package/dist/charts/tooltip/liquid-glass.js +142 -0
- package/dist/charts/tooltip/tooltip-box.js +502 -0
- package/dist/charts/tooltip/tooltip-content.js +59 -0
- package/dist/charts/tooltip/tooltip-dot.js +170 -0
- package/dist/charts/tooltip/tooltip-indicator.js +175 -0
- package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
- package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
- package/dist/charts/trend-line-utils.js +64 -0
- package/dist/charts/trend-line.js +318 -0
- package/dist/charts/use-animated-band.js +175 -0
- package/dist/charts/use-animated-series-path.js +208 -0
- package/dist/charts/use-animated-y-domains.js +192 -0
- package/dist/charts/use-category-slots.js +29 -0
- package/dist/charts/use-chart-interaction.js +296 -0
- package/dist/charts/use-chart-phase-orchestrator.js +183 -0
- package/dist/charts/use-enter-complete.js +18 -0
- package/dist/charts/use-grid-shimmer.js +88 -0
- package/dist/charts/use-highlight-segment.js +65 -0
- package/dist/charts/use-mount-progress.js +23 -0
- package/dist/charts/use-scatter-chart-interaction.js +364 -0
- package/dist/charts/use-scheduled-tooltip.js +84 -0
- package/dist/charts/visx-pattern.js +30 -0
- package/dist/charts/weekends.js +174 -0
- package/dist/charts/x-axis-hover.js +46 -0
- package/dist/charts/x-axis.js +523 -0
- package/dist/charts/y-axis-scales.js +71 -0
- package/dist/charts/y-axis-ticks.js +22 -0
- package/dist/charts/y-axis.js +233 -0
- package/dist/charts/y-domain-utils.js +189 -0
- package/dist/index.d.ts +7346 -0
- package/dist/index.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/shimmering-text.js +54 -0
- package/package.json +78 -4
- package/tema.css +202 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
function readDate(row, xDataKey) {
|
|
2
|
+
const raw = row[xDataKey];
|
|
3
|
+
if (raw instanceof Date && !Number.isNaN(raw.getTime())) {
|
|
4
|
+
return raw;
|
|
5
|
+
}
|
|
6
|
+
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
7
|
+
const date = new Date(raw);
|
|
8
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
9
|
+
}
|
|
10
|
+
if (typeof raw === "string") {
|
|
11
|
+
const date = new Date(raw);
|
|
12
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function readValue(row, seriesKey) {
|
|
17
|
+
const raw = row[seriesKey];
|
|
18
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : null;
|
|
19
|
+
}
|
|
20
|
+
function resolveStartIndex(sourceData, startIndex) {
|
|
21
|
+
if (startIndex == null || !Number.isFinite(startIndex)) {
|
|
22
|
+
return Math.max(0, sourceData.length - 1);
|
|
23
|
+
}
|
|
24
|
+
return Math.min(Math.max(0, Math.floor(startIndex)), sourceData.length - 1);
|
|
25
|
+
}
|
|
26
|
+
function intervalFromAdjacentRows(sourceData, xDataKey, startIndex) {
|
|
27
|
+
if (startIndex < 1) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const prevRow = sourceData[startIndex - 1];
|
|
31
|
+
const currentRow = sourceData[startIndex];
|
|
32
|
+
const prev = prevRow ? readDate(prevRow, xDataKey) : null;
|
|
33
|
+
const current = currentRow ? readDate(currentRow, xDataKey) : null;
|
|
34
|
+
if (!(prev && current)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const delta = current.getTime() - prev.getTime();
|
|
38
|
+
return delta > 0 ? delta : null;
|
|
39
|
+
}
|
|
40
|
+
function intervalFromSeriesSpan(sourceData, xDataKey) {
|
|
41
|
+
if (sourceData.length < 2) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const firstRow = sourceData[0];
|
|
45
|
+
const lastRow = sourceData.at(-1);
|
|
46
|
+
const first = firstRow ? readDate(firstRow, xDataKey) : null;
|
|
47
|
+
const last = lastRow ? readDate(lastRow, xDataKey) : null;
|
|
48
|
+
if (!(first && last)) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const span = last.getTime() - first.getTime();
|
|
52
|
+
return span > 0 ? span / (sourceData.length - 1) : null;
|
|
53
|
+
}
|
|
54
|
+
function resolveIntervalMs(sourceData, xDataKey, startIndex) {
|
|
55
|
+
return intervalFromAdjacentRows(sourceData, xDataKey, startIndex) ?? intervalFromSeriesSpan(sourceData, xDataKey) ?? 864e5;
|
|
56
|
+
}
|
|
57
|
+
function linearRegressionSlope(points) {
|
|
58
|
+
if (points.length < 2) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
const n = points.length;
|
|
62
|
+
let sumT = 0;
|
|
63
|
+
let sumY = 0;
|
|
64
|
+
let sumTY = 0;
|
|
65
|
+
let sumTT = 0;
|
|
66
|
+
for (const { t, y } of points) {
|
|
67
|
+
sumT += t;
|
|
68
|
+
sumY += y;
|
|
69
|
+
sumTY += t * y;
|
|
70
|
+
sumTT += t * t;
|
|
71
|
+
}
|
|
72
|
+
const denom = n * sumTT - sumT * sumT;
|
|
73
|
+
if (Math.abs(denom) < 1e-12) {
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
return (n * sumTY - sumT * sumY) / denom;
|
|
77
|
+
}
|
|
78
|
+
function buildAutoFutureValues(options) {
|
|
79
|
+
const {
|
|
80
|
+
anchorTime,
|
|
81
|
+
anchorValue,
|
|
82
|
+
autoMethod,
|
|
83
|
+
historyPoints,
|
|
84
|
+
horizonPoints,
|
|
85
|
+
intervalMs,
|
|
86
|
+
pathDensity
|
|
87
|
+
} = options;
|
|
88
|
+
const slope = autoMethod === "lastSegment" && historyPoints.length >= 2 ? (() => {
|
|
89
|
+
const prev = historyPoints.at(-2);
|
|
90
|
+
const last = historyPoints.at(-1);
|
|
91
|
+
if (!(prev && last)) {
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
const dt = last.t - prev.t;
|
|
95
|
+
return dt === 0 ? 0 : (last.y - prev.y) / dt;
|
|
96
|
+
})() : linearRegressionSlope(historyPoints);
|
|
97
|
+
if (pathDensity === "endpoints") {
|
|
98
|
+
const endTime = anchorTime + intervalMs * horizonPoints;
|
|
99
|
+
const endValue = anchorValue + slope * intervalMs * horizonPoints;
|
|
100
|
+
return [
|
|
101
|
+
{ date: new Date(anchorTime), value: anchorValue },
|
|
102
|
+
{ date: new Date(endTime), value: endValue }
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
const result = [
|
|
106
|
+
{ date: new Date(anchorTime), value: anchorValue }
|
|
107
|
+
];
|
|
108
|
+
for (let i = 1; i <= horizonPoints; i++) {
|
|
109
|
+
const t = anchorTime + intervalMs * i;
|
|
110
|
+
const value = anchorValue + slope * intervalMs * i;
|
|
111
|
+
result.push({ date: new Date(t), value });
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
function computeProjectionAnchorTangentSlope(sourceData, seriesKey, xDataKey = "date", startIndexProp) {
|
|
116
|
+
if (sourceData.length < 2) {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
119
|
+
const startIndex = resolveStartIndex(sourceData, startIndexProp);
|
|
120
|
+
const historyPoints = [];
|
|
121
|
+
for (let i = 0; i <= startIndex; i++) {
|
|
122
|
+
const row = sourceData[i];
|
|
123
|
+
if (!row) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const date = readDate(row, xDataKey);
|
|
127
|
+
const value = readValue(row, seriesKey);
|
|
128
|
+
if (date && value != null) {
|
|
129
|
+
historyPoints.push({ t: date.getTime(), y: value });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (historyPoints.length < 2) {
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
const prev = historyPoints.at(-2);
|
|
136
|
+
const last = historyPoints.at(-1);
|
|
137
|
+
if (!(prev && last)) {
|
|
138
|
+
return 0;
|
|
139
|
+
}
|
|
140
|
+
const dt = last.t - prev.t;
|
|
141
|
+
return dt === 0 ? 0 : (last.y - prev.y) / dt;
|
|
142
|
+
}
|
|
143
|
+
function buildHorizontalTangentBezierPath(x0, y0, x1, y1, tension = 0.45) {
|
|
144
|
+
const dx = x1 - x0;
|
|
145
|
+
if (Math.abs(dx) < 1e-6) {
|
|
146
|
+
return `M ${x0},${y0} L ${x1},${y1}`;
|
|
147
|
+
}
|
|
148
|
+
const t = Math.min(0.5, Math.max(0.05, tension));
|
|
149
|
+
const c1x = x0 + dx * t;
|
|
150
|
+
const c2x = x1 - dx * t;
|
|
151
|
+
return `M ${x0},${y0} C ${c1x},${y0} ${c2x},${y1} ${x1},${y1}`;
|
|
152
|
+
}
|
|
153
|
+
function projectionCrossingX(x0, y0, x1, y1, targetY, curveKind = "linear", tension = 0.45) {
|
|
154
|
+
const lo = Math.min(y0, y1);
|
|
155
|
+
const hi = Math.max(y0, y1);
|
|
156
|
+
if (!Number.isFinite(targetY) || targetY < lo || targetY > hi) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (Math.abs(y1 - y0) < 1e-9) {
|
|
160
|
+
return x0;
|
|
161
|
+
}
|
|
162
|
+
const dx = x1 - x0;
|
|
163
|
+
if (curveKind === "linear" || Math.abs(dx) < 1e-6) {
|
|
164
|
+
return x0 + dx * (targetY - y0) / (y1 - y0);
|
|
165
|
+
}
|
|
166
|
+
const k = Math.min(0.5, Math.max(0.05, tension));
|
|
167
|
+
const bezier = (t2, a, b, c, d) => {
|
|
168
|
+
const u = 1 - t2;
|
|
169
|
+
return u * u * u * a + 3 * u * u * t2 * b + 3 * u * t2 * t2 * c + t2 * t2 * t2 * d;
|
|
170
|
+
};
|
|
171
|
+
const rising = y1 > y0;
|
|
172
|
+
let tLo = 0;
|
|
173
|
+
let tHi = 1;
|
|
174
|
+
for (let step = 0; step < 40; step++) {
|
|
175
|
+
const mid = (tLo + tHi) / 2;
|
|
176
|
+
const y = bezier(mid, y0, y0, y1, y1);
|
|
177
|
+
if (y < targetY === rising) {
|
|
178
|
+
tLo = mid;
|
|
179
|
+
} else {
|
|
180
|
+
tHi = mid;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const t = (tLo + tHi) / 2;
|
|
184
|
+
return bezier(t, x0, x0 + dx * k, x1 - dx * k, x1);
|
|
185
|
+
}
|
|
186
|
+
function buildTargetPath(options) {
|
|
187
|
+
const { anchorTime, anchorValue, endValue, horizonPoints, intervalMs } = options;
|
|
188
|
+
const endTime = anchorTime + intervalMs * horizonPoints;
|
|
189
|
+
return [
|
|
190
|
+
{ date: new Date(anchorTime), value: anchorValue },
|
|
191
|
+
{ date: new Date(endTime), value: endValue }
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
function buildProjectionPath(options) {
|
|
195
|
+
const {
|
|
196
|
+
sourceData,
|
|
197
|
+
seriesKey,
|
|
198
|
+
xDataKey = "date",
|
|
199
|
+
mode,
|
|
200
|
+
autoMethod = "linearRegression",
|
|
201
|
+
pathDensity = "endpoints",
|
|
202
|
+
startIndex: startIndexProp,
|
|
203
|
+
horizonPoints = 6,
|
|
204
|
+
endValue,
|
|
205
|
+
points
|
|
206
|
+
} = options;
|
|
207
|
+
if (mode === "manual" && points && points.length >= 2) {
|
|
208
|
+
return points.map((point) => ({
|
|
209
|
+
date: new Date(point.date),
|
|
210
|
+
value: point.value
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
if (sourceData.length === 0) {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
const startIndex = resolveStartIndex(sourceData, startIndexProp);
|
|
217
|
+
const anchorRow = sourceData[startIndex];
|
|
218
|
+
if (!anchorRow) {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
const anchorDate = readDate(anchorRow, xDataKey);
|
|
222
|
+
const anchorValue = readValue(anchorRow, seriesKey);
|
|
223
|
+
if (!anchorDate || anchorValue == null) {
|
|
224
|
+
return [];
|
|
225
|
+
}
|
|
226
|
+
const intervalMs = resolveIntervalMs(sourceData, xDataKey, startIndex);
|
|
227
|
+
const anchorTime = anchorDate.getTime();
|
|
228
|
+
const historyPoints = [];
|
|
229
|
+
for (let i = 0; i <= startIndex; i++) {
|
|
230
|
+
const row = sourceData[i];
|
|
231
|
+
if (!row) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const date = readDate(row, xDataKey);
|
|
235
|
+
const value = readValue(row, seriesKey);
|
|
236
|
+
if (date && value != null) {
|
|
237
|
+
historyPoints.push({ t: date.getTime(), y: value });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (mode === "target" && endValue != null && Number.isFinite(endValue)) {
|
|
241
|
+
return buildTargetPath({
|
|
242
|
+
anchorTime,
|
|
243
|
+
anchorValue,
|
|
244
|
+
endValue,
|
|
245
|
+
horizonPoints,
|
|
246
|
+
intervalMs
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return buildAutoFutureValues({
|
|
250
|
+
anchorTime,
|
|
251
|
+
anchorValue,
|
|
252
|
+
autoMethod,
|
|
253
|
+
historyPoints,
|
|
254
|
+
horizonPoints,
|
|
255
|
+
intervalMs,
|
|
256
|
+
pathDensity
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function projectionValueExtents(paths) {
|
|
260
|
+
let minValue = Number.POSITIVE_INFINITY;
|
|
261
|
+
let maxValue = Number.NEGATIVE_INFINITY;
|
|
262
|
+
for (const path of paths) {
|
|
263
|
+
for (const point of path) {
|
|
264
|
+
if (point.value < minValue) {
|
|
265
|
+
minValue = point.value;
|
|
266
|
+
}
|
|
267
|
+
if (point.value > maxValue) {
|
|
268
|
+
maxValue = point.value;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (minValue === Number.POSITIVE_INFINITY) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
return { minValue, maxValue };
|
|
276
|
+
}
|
|
277
|
+
function projectionDateExtents(paths) {
|
|
278
|
+
let minTime = Number.POSITIVE_INFINITY;
|
|
279
|
+
let maxTime = Number.NEGATIVE_INFINITY;
|
|
280
|
+
for (const path of paths) {
|
|
281
|
+
for (const point of path) {
|
|
282
|
+
const time = point.date.getTime();
|
|
283
|
+
if (time < minTime) {
|
|
284
|
+
minTime = time;
|
|
285
|
+
}
|
|
286
|
+
if (time > maxTime) {
|
|
287
|
+
maxTime = time;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (minTime === Number.POSITIVE_INFINITY) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return { minTime, maxTime };
|
|
295
|
+
}
|
|
296
|
+
export {
|
|
297
|
+
buildHorizontalTangentBezierPath,
|
|
298
|
+
buildProjectionPath,
|
|
299
|
+
computeProjectionAnchorTangentSlope,
|
|
300
|
+
projectionCrossingX,
|
|
301
|
+
projectionDateExtents,
|
|
302
|
+
projectionValueExtents
|
|
303
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m, useTransform } from "motion/react";
|
|
4
|
+
import { memo, useMemo } from "react";
|
|
5
|
+
import { radarCssVars, useRadarHover, useRadarStable } from "./radar-context";
|
|
6
|
+
import { useEnterComplete } from "./use-enter-complete";
|
|
7
|
+
import { useMountProgress } from "./use-mount-progress";
|
|
8
|
+
function getStrokeWidth(isHovered) {
|
|
9
|
+
return isHovered ? 3 : 2;
|
|
10
|
+
}
|
|
11
|
+
function positionsToPath(positions) {
|
|
12
|
+
if (positions.length === 0) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return `M ${positions.map((p) => `${p.x},${p.y}`).join(" L ")} Z`;
|
|
16
|
+
}
|
|
17
|
+
const RadarPoint = memo(function RadarPoint2({
|
|
18
|
+
mountProgress,
|
|
19
|
+
target,
|
|
20
|
+
color,
|
|
21
|
+
isHovered,
|
|
22
|
+
metricKey,
|
|
23
|
+
enterComplete
|
|
24
|
+
}) {
|
|
25
|
+
const cx = useTransform(mountProgress, (t) => target.x * t);
|
|
26
|
+
const cy = useTransform(mountProgress, (t) => target.y * t);
|
|
27
|
+
if (enterComplete) {
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
"circle",
|
|
30
|
+
{
|
|
31
|
+
cx: target.x,
|
|
32
|
+
cy: target.y,
|
|
33
|
+
fill: color,
|
|
34
|
+
r: isHovered ? 6 : 4,
|
|
35
|
+
stroke: radarCssVars.background,
|
|
36
|
+
strokeWidth: 2
|
|
37
|
+
},
|
|
38
|
+
metricKey
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
m.circle,
|
|
43
|
+
{
|
|
44
|
+
cx,
|
|
45
|
+
cy,
|
|
46
|
+
fill: color,
|
|
47
|
+
r: isHovered ? 6 : 4,
|
|
48
|
+
stroke: radarCssVars.background,
|
|
49
|
+
strokeWidth: 2,
|
|
50
|
+
transition: {
|
|
51
|
+
r: { type: "spring", stiffness: 300, damping: 20 }
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
metricKey
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
const RadarArea = memo(function RadarArea2({
|
|
58
|
+
index,
|
|
59
|
+
color: colorProp,
|
|
60
|
+
showPoints = true,
|
|
61
|
+
showStroke = true,
|
|
62
|
+
showGlow = false,
|
|
63
|
+
className = ""
|
|
64
|
+
}) {
|
|
65
|
+
const {
|
|
66
|
+
data,
|
|
67
|
+
metrics,
|
|
68
|
+
levels,
|
|
69
|
+
animate,
|
|
70
|
+
enterDurationMs,
|
|
71
|
+
staggerScale,
|
|
72
|
+
enterTransition,
|
|
73
|
+
motionReplayKey,
|
|
74
|
+
getColor,
|
|
75
|
+
getPointPosition
|
|
76
|
+
} = useRadarStable();
|
|
77
|
+
const { hoveredIndex, setHoveredIndex } = useRadarHover();
|
|
78
|
+
const durationFactor = enterDurationMs / 1100;
|
|
79
|
+
const areaData = data[index];
|
|
80
|
+
const targetPositions = useMemo(() => {
|
|
81
|
+
if (!areaData) {
|
|
82
|
+
return metrics.map(() => ({ x: 0, y: 0 }));
|
|
83
|
+
}
|
|
84
|
+
return metrics.map((metric, i) => {
|
|
85
|
+
const value = areaData.values[metric.key] ?? 0;
|
|
86
|
+
return getPointPosition(i, value);
|
|
87
|
+
});
|
|
88
|
+
}, [metrics, areaData, getPointPosition]);
|
|
89
|
+
const staticPath = useMemo(
|
|
90
|
+
() => positionsToPath(targetPositions),
|
|
91
|
+
[targetPositions]
|
|
92
|
+
);
|
|
93
|
+
const gridStagger = 0.08 * staggerScale * durationFactor;
|
|
94
|
+
const campaignBaseDelay = (levels * gridStagger + 0.2) * durationFactor;
|
|
95
|
+
const campaignStagger = 0.15 * staggerScale * durationFactor;
|
|
96
|
+
const animationDelay = campaignBaseDelay + index * campaignStagger;
|
|
97
|
+
const mountProgress = useMountProgress(
|
|
98
|
+
enterTransition,
|
|
99
|
+
animationDelay,
|
|
100
|
+
`${motionReplayKey}-${index}`
|
|
101
|
+
);
|
|
102
|
+
const enterComplete = useEnterComplete(mountProgress);
|
|
103
|
+
const animatedPositions = useTransform(
|
|
104
|
+
mountProgress,
|
|
105
|
+
(t) => targetPositions.map((p) => ({ x: p.x * t, y: p.y * t }))
|
|
106
|
+
);
|
|
107
|
+
const pathD = useTransform(animatedPositions, positionsToPath);
|
|
108
|
+
if (!areaData) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const color = colorProp || getColor(index);
|
|
112
|
+
const isHovered = hoveredIndex === index;
|
|
113
|
+
const isOtherHovered = hoveredIndex !== null && hoveredIndex !== index;
|
|
114
|
+
return /* @__PURE__ */ jsxs(
|
|
115
|
+
m.g,
|
|
116
|
+
{
|
|
117
|
+
animate: {
|
|
118
|
+
opacity: isOtherHovered ? 0.3 : 1,
|
|
119
|
+
scale: isHovered ? 1.05 : 1
|
|
120
|
+
},
|
|
121
|
+
className,
|
|
122
|
+
initial: { opacity: animate ? 0 : 1 },
|
|
123
|
+
onMouseEnter: () => setHoveredIndex(index),
|
|
124
|
+
onMouseLeave: () => setHoveredIndex(null),
|
|
125
|
+
style: { transformOrigin: "0px 0px", cursor: "pointer" },
|
|
126
|
+
transition: {
|
|
127
|
+
opacity: { duration: 0.15 },
|
|
128
|
+
scale: { type: "spring", stiffness: 400, damping: 25 }
|
|
129
|
+
},
|
|
130
|
+
children: [
|
|
131
|
+
enterComplete ? /* @__PURE__ */ jsx(
|
|
132
|
+
"path",
|
|
133
|
+
{
|
|
134
|
+
d: staticPath,
|
|
135
|
+
fill: color,
|
|
136
|
+
fillOpacity: isHovered ? 0.35 : 0.15,
|
|
137
|
+
stroke: showStroke ? color : "none",
|
|
138
|
+
strokeLinejoin: "round",
|
|
139
|
+
strokeWidth: showStroke ? getStrokeWidth(isHovered) : 0,
|
|
140
|
+
style: {
|
|
141
|
+
filter: showGlow && isHovered ? `drop-shadow(0 0 12px ${color})` : "none"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
) : /* @__PURE__ */ jsx(
|
|
145
|
+
m.path,
|
|
146
|
+
{
|
|
147
|
+
animate: {
|
|
148
|
+
fillOpacity: isHovered ? 0.35 : 0.15,
|
|
149
|
+
strokeWidth: showStroke ? getStrokeWidth(isHovered) : 0
|
|
150
|
+
},
|
|
151
|
+
d: pathD,
|
|
152
|
+
fill: color,
|
|
153
|
+
initial: false,
|
|
154
|
+
stroke: showStroke ? color : "none",
|
|
155
|
+
strokeLinejoin: "round",
|
|
156
|
+
style: {
|
|
157
|
+
filter: showGlow && isHovered ? `drop-shadow(0 0 12px ${color})` : "none"
|
|
158
|
+
},
|
|
159
|
+
transition: {
|
|
160
|
+
fillOpacity: { duration: 0.2 },
|
|
161
|
+
strokeWidth: { duration: 0.2 }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
showPoints && metrics.map((metric, i) => {
|
|
166
|
+
const target = targetPositions[i];
|
|
167
|
+
if (!target) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return /* @__PURE__ */ jsx(
|
|
171
|
+
RadarPoint,
|
|
172
|
+
{
|
|
173
|
+
color,
|
|
174
|
+
enterComplete,
|
|
175
|
+
isHovered,
|
|
176
|
+
metricKey: metric.key,
|
|
177
|
+
mountProgress,
|
|
178
|
+
target
|
|
179
|
+
},
|
|
180
|
+
metric.key
|
|
181
|
+
);
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
RadarArea.displayName = "RadarArea";
|
|
188
|
+
var radar_area_default = RadarArea;
|
|
189
|
+
export {
|
|
190
|
+
RadarArea,
|
|
191
|
+
radar_area_default as default
|
|
192
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "motion/react";
|
|
4
|
+
import { GRID_SPOKE_SPRING, GRID_SPOKE_STAGGER_S } from "./animation";
|
|
5
|
+
import { radarCssVars, useRadarStable } from "./radar-context";
|
|
6
|
+
function RadarAxis({
|
|
7
|
+
stroke = radarCssVars.border,
|
|
8
|
+
strokeOpacity = 0.6,
|
|
9
|
+
className = ""
|
|
10
|
+
}) {
|
|
11
|
+
const { metrics, radius, getAngle, animate } = useRadarStable();
|
|
12
|
+
const axisBaseDelay = 0;
|
|
13
|
+
return /* @__PURE__ */ jsx("g", { className, children: metrics.map((metric, i) => {
|
|
14
|
+
const angle = getAngle(i);
|
|
15
|
+
const targetX = radius * Math.cos(angle);
|
|
16
|
+
const targetY = radius * Math.sin(angle);
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
m.line,
|
|
19
|
+
{
|
|
20
|
+
animate: { x2: targetX, y2: targetY },
|
|
21
|
+
initial: animate ? { x2: 0, y2: 0 } : { x2: targetX, y2: targetY },
|
|
22
|
+
stroke,
|
|
23
|
+
strokeOpacity,
|
|
24
|
+
strokeWidth: 1,
|
|
25
|
+
transition: {
|
|
26
|
+
...GRID_SPOKE_SPRING,
|
|
27
|
+
delay: animate ? axisBaseDelay + i * GRID_SPOKE_STAGGER_S : 0
|
|
28
|
+
},
|
|
29
|
+
x1: 0,
|
|
30
|
+
y1: 0
|
|
31
|
+
},
|
|
32
|
+
`axis-${metric.key}`
|
|
33
|
+
);
|
|
34
|
+
}) });
|
|
35
|
+
}
|
|
36
|
+
RadarAxis.displayName = "RadarAxis";
|
|
37
|
+
var radar_axis_default = RadarAxis;
|
|
38
|
+
export {
|
|
39
|
+
RadarAxis,
|
|
40
|
+
radar_axis_default as default
|
|
41
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { scaleLinear } from "d3-scale";
|
|
4
|
+
import { domAnimation, LazyMotion } from "motion/react";
|
|
5
|
+
import { useCallback, useState } from "react";
|
|
6
|
+
import { cn } from "../lib/utils";
|
|
7
|
+
import { useChartDataOverride } from "./chart-data-override";
|
|
8
|
+
import { ParentSize } from "./chart-parent-size";
|
|
9
|
+
import {
|
|
10
|
+
defaultRadarColors,
|
|
11
|
+
RadarProvider
|
|
12
|
+
} from "./radar-context";
|
|
13
|
+
function RadarChartInner({
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
data,
|
|
17
|
+
metrics,
|
|
18
|
+
levels,
|
|
19
|
+
margin,
|
|
20
|
+
animate,
|
|
21
|
+
enterDurationMs,
|
|
22
|
+
staggerScale,
|
|
23
|
+
enterTransition,
|
|
24
|
+
motionReplayKey,
|
|
25
|
+
children,
|
|
26
|
+
hoveredIndexProp,
|
|
27
|
+
onHoverChange
|
|
28
|
+
}) {
|
|
29
|
+
const [internalHoveredIndex, setInternalHoveredIndex] = useState(null);
|
|
30
|
+
const isControlled = hoveredIndexProp !== void 0;
|
|
31
|
+
const hoveredIndex = isControlled ? hoveredIndexProp : internalHoveredIndex;
|
|
32
|
+
const setHoveredIndex = useCallback(
|
|
33
|
+
(index) => {
|
|
34
|
+
if (isControlled) {
|
|
35
|
+
onHoverChange?.(index);
|
|
36
|
+
} else {
|
|
37
|
+
setInternalHoveredIndex(index);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[isControlled, onHoverChange]
|
|
41
|
+
);
|
|
42
|
+
const size = Math.min(width, height);
|
|
43
|
+
const radius = (size - margin * 2) / 2;
|
|
44
|
+
const yScale = useCallback(
|
|
45
|
+
(value) => {
|
|
46
|
+
const scale = scaleLinear().domain([0, 100]).range([0, radius]);
|
|
47
|
+
return scale(value) ?? 0;
|
|
48
|
+
},
|
|
49
|
+
[radius]
|
|
50
|
+
);
|
|
51
|
+
const getAngle = useCallback(
|
|
52
|
+
(metricIndex) => {
|
|
53
|
+
const step = Math.PI * 2 / metrics.length;
|
|
54
|
+
const angleOffset = -Math.PI / 2;
|
|
55
|
+
return metricIndex * step + angleOffset;
|
|
56
|
+
},
|
|
57
|
+
[metrics.length]
|
|
58
|
+
);
|
|
59
|
+
const getPointPosition = useCallback(
|
|
60
|
+
(metricIndex, value) => {
|
|
61
|
+
const angle = getAngle(metricIndex);
|
|
62
|
+
const r = yScale(value);
|
|
63
|
+
return {
|
|
64
|
+
x: r * Math.cos(angle),
|
|
65
|
+
y: r * Math.sin(angle)
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
[getAngle, yScale]
|
|
69
|
+
);
|
|
70
|
+
const getColor = useCallback(
|
|
71
|
+
(index) => {
|
|
72
|
+
const item = data[index];
|
|
73
|
+
if (item?.color) {
|
|
74
|
+
return item.color;
|
|
75
|
+
}
|
|
76
|
+
return defaultRadarColors[index % defaultRadarColors.length];
|
|
77
|
+
},
|
|
78
|
+
[data]
|
|
79
|
+
);
|
|
80
|
+
if (size < 10) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const contextValue = {
|
|
84
|
+
data,
|
|
85
|
+
metrics,
|
|
86
|
+
size,
|
|
87
|
+
radius,
|
|
88
|
+
levels,
|
|
89
|
+
hoveredIndex,
|
|
90
|
+
setHoveredIndex,
|
|
91
|
+
animate,
|
|
92
|
+
enterDurationMs,
|
|
93
|
+
staggerScale,
|
|
94
|
+
enterTransition,
|
|
95
|
+
motionReplayKey,
|
|
96
|
+
getColor,
|
|
97
|
+
getAngle,
|
|
98
|
+
getPointPosition,
|
|
99
|
+
yScale
|
|
100
|
+
};
|
|
101
|
+
return /* @__PURE__ */ jsx(RadarProvider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
102
|
+
"svg",
|
|
103
|
+
{
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
height: size,
|
|
106
|
+
style: { overflow: "visible" },
|
|
107
|
+
width: size,
|
|
108
|
+
children: /* @__PURE__ */ jsx("g", { transform: `translate(${size / 2}, ${size / 2})`, children })
|
|
109
|
+
}
|
|
110
|
+
) });
|
|
111
|
+
}
|
|
112
|
+
function RadarChart({
|
|
113
|
+
data: dataProp,
|
|
114
|
+
metrics: metricsProp,
|
|
115
|
+
size: fixedSize,
|
|
116
|
+
levels = 5,
|
|
117
|
+
margin = 60,
|
|
118
|
+
animate = true,
|
|
119
|
+
enterDurationMs = 1100,
|
|
120
|
+
staggerScale = 1,
|
|
121
|
+
enterTransition,
|
|
122
|
+
motionReplayKey = "",
|
|
123
|
+
className = "",
|
|
124
|
+
hoveredIndex,
|
|
125
|
+
onHoverChange,
|
|
126
|
+
children
|
|
127
|
+
}) {
|
|
128
|
+
const { data, metrics } = useChartDataOverride("RadarChart", {
|
|
129
|
+
data: dataProp,
|
|
130
|
+
metrics: metricsProp
|
|
131
|
+
});
|
|
132
|
+
if (fixedSize) {
|
|
133
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(
|
|
134
|
+
"div",
|
|
135
|
+
{
|
|
136
|
+
className: cn("relative flex items-center justify-center", className),
|
|
137
|
+
style: { width: fixedSize, height: fixedSize },
|
|
138
|
+
children: /* @__PURE__ */ jsx(
|
|
139
|
+
RadarChartInner,
|
|
140
|
+
{
|
|
141
|
+
animate,
|
|
142
|
+
data,
|
|
143
|
+
enterDurationMs,
|
|
144
|
+
enterTransition,
|
|
145
|
+
height: fixedSize,
|
|
146
|
+
hoveredIndexProp: hoveredIndex,
|
|
147
|
+
levels,
|
|
148
|
+
margin,
|
|
149
|
+
metrics,
|
|
150
|
+
motionReplayKey,
|
|
151
|
+
onHoverChange,
|
|
152
|
+
staggerScale,
|
|
153
|
+
width: fixedSize,
|
|
154
|
+
children
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
) });
|
|
159
|
+
}
|
|
160
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx("div", { className: cn("relative aspect-square w-full", className), children: /* @__PURE__ */ jsx(ParentSize, { debounceTime: 10, children: ({ width, height }) => /* @__PURE__ */ jsx(
|
|
161
|
+
RadarChartInner,
|
|
162
|
+
{
|
|
163
|
+
animate,
|
|
164
|
+
data,
|
|
165
|
+
enterDurationMs,
|
|
166
|
+
enterTransition,
|
|
167
|
+
height,
|
|
168
|
+
hoveredIndexProp: hoveredIndex,
|
|
169
|
+
levels,
|
|
170
|
+
margin,
|
|
171
|
+
metrics,
|
|
172
|
+
motionReplayKey,
|
|
173
|
+
onHoverChange,
|
|
174
|
+
staggerScale,
|
|
175
|
+
width,
|
|
176
|
+
children
|
|
177
|
+
}
|
|
178
|
+
) }) }) });
|
|
179
|
+
}
|
|
180
|
+
var radar_chart_default = RadarChart;
|
|
181
|
+
export {
|
|
182
|
+
RadarChart,
|
|
183
|
+
radar_chart_default as default
|
|
184
|
+
};
|