@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,411 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence, m } from "motion/react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { createPortal } from "react-dom";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
import { chartCssVars, useChartPortalContainer } from "../chart-context";
|
|
8
|
+
const FAN_RADIUS = 50;
|
|
9
|
+
const FAN_ANGLE = 160;
|
|
10
|
+
const markerEntranceVariants = {
|
|
11
|
+
hidden: {
|
|
12
|
+
scale: 0.85,
|
|
13
|
+
opacity: 0,
|
|
14
|
+
filter: "blur(2px)"
|
|
15
|
+
},
|
|
16
|
+
visible: {
|
|
17
|
+
scale: 1,
|
|
18
|
+
opacity: 1,
|
|
19
|
+
filter: "blur(0px)"
|
|
20
|
+
},
|
|
21
|
+
fanned: {
|
|
22
|
+
scale: 0.6,
|
|
23
|
+
opacity: 0,
|
|
24
|
+
filter: "blur(2px)"
|
|
25
|
+
},
|
|
26
|
+
muted: {
|
|
27
|
+
scale: 1,
|
|
28
|
+
opacity: 0.4,
|
|
29
|
+
filter: "blur(0px)"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function MarkerGroup({
|
|
33
|
+
x,
|
|
34
|
+
y,
|
|
35
|
+
markers,
|
|
36
|
+
isActive = false,
|
|
37
|
+
size = 28,
|
|
38
|
+
onHover,
|
|
39
|
+
containerRef,
|
|
40
|
+
marginLeft = 0,
|
|
41
|
+
marginTop = 0,
|
|
42
|
+
animationDelay = 0,
|
|
43
|
+
animate = true,
|
|
44
|
+
lineHeight = 0,
|
|
45
|
+
showLine = true,
|
|
46
|
+
forceOpen = false,
|
|
47
|
+
iconFill = false,
|
|
48
|
+
borderColor,
|
|
49
|
+
borderWidth = 1.5,
|
|
50
|
+
maxFanned,
|
|
51
|
+
isMuted = false
|
|
52
|
+
}) {
|
|
53
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
54
|
+
const portalContainer = useChartPortalContainer(containerRef);
|
|
55
|
+
const shouldFan = (isHovered || forceOpen) && markers.length > 1;
|
|
56
|
+
const hasMultiple = markers.length > 1;
|
|
57
|
+
const fannedMarkers = maxFanned === void 0 ? markers : markers.slice(0, maxFanned);
|
|
58
|
+
let currentVariant = "visible";
|
|
59
|
+
if (shouldFan) {
|
|
60
|
+
currentVariant = "fanned";
|
|
61
|
+
} else if (isMuted) {
|
|
62
|
+
currentVariant = "muted";
|
|
63
|
+
}
|
|
64
|
+
const getCirclePosition = (index, total) => {
|
|
65
|
+
const startAngle = -90 - FAN_ANGLE / 2;
|
|
66
|
+
const angleStep = total > 1 ? FAN_ANGLE / (total - 1) : 0;
|
|
67
|
+
const angle = startAngle + index * angleStep;
|
|
68
|
+
const radians = angle * Math.PI / 180;
|
|
69
|
+
return {
|
|
70
|
+
x: Math.cos(radians) * FAN_RADIUS,
|
|
71
|
+
y: Math.sin(radians) * FAN_RADIUS
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const handleMouseEnter = (e) => {
|
|
75
|
+
e.stopPropagation();
|
|
76
|
+
setIsHovered(true);
|
|
77
|
+
onHover?.(markers);
|
|
78
|
+
};
|
|
79
|
+
const handleMouseLeave = (e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
setIsHovered(false);
|
|
82
|
+
onHover?.(null);
|
|
83
|
+
};
|
|
84
|
+
const handleMouseMove = (e) => {
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
};
|
|
87
|
+
const portalX = x + marginLeft;
|
|
88
|
+
const portalY = y + marginTop;
|
|
89
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("g", { transform: `translate(${x}, ${y})`, children: [
|
|
91
|
+
showLine && lineHeight > 0 && /* @__PURE__ */ jsx(
|
|
92
|
+
m.line,
|
|
93
|
+
{
|
|
94
|
+
animate: {
|
|
95
|
+
strokeOpacity: (() => {
|
|
96
|
+
if (isHovered) {
|
|
97
|
+
return 1;
|
|
98
|
+
}
|
|
99
|
+
if (isActive) {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
return 0.6;
|
|
103
|
+
})()
|
|
104
|
+
},
|
|
105
|
+
initial: { strokeOpacity: 0.6 },
|
|
106
|
+
stroke: chartCssVars.markerBorder,
|
|
107
|
+
strokeDasharray: "4,4",
|
|
108
|
+
strokeLinecap: "round",
|
|
109
|
+
strokeWidth: 1,
|
|
110
|
+
style: { pointerEvents: "none" },
|
|
111
|
+
transition: { duration: 0.2, ease: "easeOut" },
|
|
112
|
+
x1: 0,
|
|
113
|
+
x2: 0,
|
|
114
|
+
y1: size / 2 + 4,
|
|
115
|
+
y2: lineHeight + Math.abs(y)
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
/* @__PURE__ */ jsx(
|
|
119
|
+
"g",
|
|
120
|
+
{
|
|
121
|
+
onMouseEnter: handleMouseEnter,
|
|
122
|
+
onMouseLeave: handleMouseLeave,
|
|
123
|
+
onMouseMove: handleMouseMove,
|
|
124
|
+
style: { cursor: "pointer" },
|
|
125
|
+
children: /* @__PURE__ */ jsxs(
|
|
126
|
+
m.g,
|
|
127
|
+
{
|
|
128
|
+
animate: currentVariant,
|
|
129
|
+
initial: animate ? "hidden" : currentVariant,
|
|
130
|
+
transition: {
|
|
131
|
+
type: "spring",
|
|
132
|
+
stiffness: 300,
|
|
133
|
+
damping: 25,
|
|
134
|
+
delay: animationDelay
|
|
135
|
+
},
|
|
136
|
+
variants: markerEntranceVariants,
|
|
137
|
+
children: [
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
"rect",
|
|
140
|
+
{
|
|
141
|
+
fill: "transparent",
|
|
142
|
+
height: size * 1.5,
|
|
143
|
+
width: size * 1.5,
|
|
144
|
+
x: -size * 0.75,
|
|
145
|
+
y: -size
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
MarkerCircle,
|
|
150
|
+
{
|
|
151
|
+
borderColor,
|
|
152
|
+
borderWidth,
|
|
153
|
+
color: markers[0]?.color,
|
|
154
|
+
icon: markers[0]?.icon,
|
|
155
|
+
iconFill,
|
|
156
|
+
size
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: hasMultiple && !shouldFan && /* @__PURE__ */ jsxs(
|
|
160
|
+
m.g,
|
|
161
|
+
{
|
|
162
|
+
animate: { scale: 1, opacity: 1 },
|
|
163
|
+
exit: { scale: 0, opacity: 0 },
|
|
164
|
+
initial: { scale: 0, opacity: 0 },
|
|
165
|
+
transition: { type: "spring", stiffness: 400, damping: 20 },
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx(
|
|
168
|
+
"circle",
|
|
169
|
+
{
|
|
170
|
+
cx: size / 2 + 2,
|
|
171
|
+
cy: -size / 2 - 2,
|
|
172
|
+
r: 9,
|
|
173
|
+
style: { fill: chartCssVars.badgeBackground }
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ jsx(
|
|
177
|
+
"text",
|
|
178
|
+
{
|
|
179
|
+
dominantBaseline: "central",
|
|
180
|
+
fontSize: 11,
|
|
181
|
+
fontWeight: 600,
|
|
182
|
+
style: { fill: chartCssVars.badgeForeground },
|
|
183
|
+
textAnchor: "middle",
|
|
184
|
+
x: size / 2 + 2,
|
|
185
|
+
y: -size / 2 - 2,
|
|
186
|
+
children: markers.length
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
) })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
] }),
|
|
198
|
+
portalContainer && createPortal(
|
|
199
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: Marker hover portal
|
|
200
|
+
// biome-ignore lint/a11y/noNoninteractiveElementInteractions: Marker hover portal
|
|
201
|
+
/* @__PURE__ */ jsx(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
className: "absolute",
|
|
205
|
+
onMouseEnter: handleMouseEnter,
|
|
206
|
+
onMouseLeave: handleMouseLeave,
|
|
207
|
+
onMouseMove: handleMouseMove,
|
|
208
|
+
style: {
|
|
209
|
+
// Position the div so its center is at the marker position
|
|
210
|
+
// The div covers the entire fan area to prevent mouseLeave when moving between markers
|
|
211
|
+
left: portalX - (FAN_RADIUS + size / 2),
|
|
212
|
+
top: portalY - (FAN_RADIUS + size / 2),
|
|
213
|
+
width: FAN_RADIUS * 2 + size,
|
|
214
|
+
height: FAN_RADIUS * 2 + size,
|
|
215
|
+
zIndex: 100,
|
|
216
|
+
pointerEvents: shouldFan ? "auto" : "none"
|
|
217
|
+
},
|
|
218
|
+
children: /* @__PURE__ */ jsxs(
|
|
219
|
+
"div",
|
|
220
|
+
{
|
|
221
|
+
className: "absolute",
|
|
222
|
+
style: {
|
|
223
|
+
left: FAN_RADIUS + size / 2,
|
|
224
|
+
top: FAN_RADIUS + size / 2
|
|
225
|
+
},
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ jsx(AnimatePresence, { mode: "sync", children: shouldFan && fannedMarkers.map((marker, index) => {
|
|
228
|
+
const position = getCirclePosition(
|
|
229
|
+
index,
|
|
230
|
+
fannedMarkers.length
|
|
231
|
+
);
|
|
232
|
+
return /* @__PURE__ */ jsx(
|
|
233
|
+
m.div,
|
|
234
|
+
{
|
|
235
|
+
animate: {
|
|
236
|
+
x: position.x,
|
|
237
|
+
y: position.y,
|
|
238
|
+
scale: 1,
|
|
239
|
+
opacity: 1
|
|
240
|
+
},
|
|
241
|
+
className: "absolute",
|
|
242
|
+
exit: { x: 0, y: 0, scale: 0, opacity: 0 },
|
|
243
|
+
initial: { x: 0, y: 0, scale: 0, opacity: 0 },
|
|
244
|
+
style: {
|
|
245
|
+
width: size,
|
|
246
|
+
height: size,
|
|
247
|
+
left: -size / 2,
|
|
248
|
+
top: -size / 2
|
|
249
|
+
},
|
|
250
|
+
transition: {
|
|
251
|
+
type: "spring",
|
|
252
|
+
stiffness: 400,
|
|
253
|
+
damping: 22,
|
|
254
|
+
delay: index * 0.04
|
|
255
|
+
},
|
|
256
|
+
children: /* @__PURE__ */ jsx(
|
|
257
|
+
MarkerCircleHTML,
|
|
258
|
+
{
|
|
259
|
+
borderColor,
|
|
260
|
+
borderWidth,
|
|
261
|
+
color: marker.color,
|
|
262
|
+
href: marker.href,
|
|
263
|
+
icon: marker.icon,
|
|
264
|
+
iconFill,
|
|
265
|
+
isClickable: !!(marker.onClick || marker.href),
|
|
266
|
+
onClick: marker.onClick,
|
|
267
|
+
size,
|
|
268
|
+
target: marker.target
|
|
269
|
+
}
|
|
270
|
+
)
|
|
271
|
+
},
|
|
272
|
+
`fan-${marker.title}`
|
|
273
|
+
);
|
|
274
|
+
}) }),
|
|
275
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: shouldFan && /* @__PURE__ */ jsx(
|
|
276
|
+
m.div,
|
|
277
|
+
{
|
|
278
|
+
animate: { scale: 1, opacity: 0.5 },
|
|
279
|
+
className: "absolute",
|
|
280
|
+
exit: { scale: 0, opacity: 0 },
|
|
281
|
+
initial: { scale: 0, opacity: 0 },
|
|
282
|
+
style: {
|
|
283
|
+
width: size * 0.5,
|
|
284
|
+
height: size * 0.5,
|
|
285
|
+
left: -size * 0.25,
|
|
286
|
+
top: -size * 0.25
|
|
287
|
+
},
|
|
288
|
+
transition: { type: "spring", stiffness: 400, damping: 20 },
|
|
289
|
+
children: /* @__PURE__ */ jsx(
|
|
290
|
+
"div",
|
|
291
|
+
{
|
|
292
|
+
className: "h-full w-full rounded-full",
|
|
293
|
+
style: { backgroundColor: chartCssVars.markerBorder }
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
) })
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
),
|
|
303
|
+
portalContainer
|
|
304
|
+
)
|
|
305
|
+
] });
|
|
306
|
+
}
|
|
307
|
+
function MarkerCircle({
|
|
308
|
+
icon,
|
|
309
|
+
size,
|
|
310
|
+
color,
|
|
311
|
+
iconFill = false,
|
|
312
|
+
borderColor,
|
|
313
|
+
borderWidth = 1.5
|
|
314
|
+
}) {
|
|
315
|
+
const inset = iconFill ? 0 : 4;
|
|
316
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
317
|
+
/* @__PURE__ */ jsx("circle", { cx: 0, cy: 2, fill: "black", opacity: 0.15, r: size / 2 }),
|
|
318
|
+
/* @__PURE__ */ jsx(
|
|
319
|
+
"circle",
|
|
320
|
+
{
|
|
321
|
+
cx: 0,
|
|
322
|
+
cy: 0,
|
|
323
|
+
fill: color || chartCssVars.markerBackground,
|
|
324
|
+
r: size / 2,
|
|
325
|
+
stroke: borderColor ?? chartCssVars.markerBorder,
|
|
326
|
+
strokeWidth: borderWidth
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsx(
|
|
330
|
+
"foreignObject",
|
|
331
|
+
{
|
|
332
|
+
height: size - inset * 2,
|
|
333
|
+
width: size - inset * 2,
|
|
334
|
+
x: -size / 2 + inset,
|
|
335
|
+
y: -size / 2 + inset,
|
|
336
|
+
children: /* @__PURE__ */ jsx(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
style: {
|
|
340
|
+
width: "100%",
|
|
341
|
+
height: "100%",
|
|
342
|
+
display: "flex",
|
|
343
|
+
alignItems: "center",
|
|
344
|
+
justifyContent: "center",
|
|
345
|
+
color: chartCssVars.markerForeground,
|
|
346
|
+
fontSize: size * 0.5,
|
|
347
|
+
overflow: "hidden",
|
|
348
|
+
borderRadius: "50%"
|
|
349
|
+
},
|
|
350
|
+
children: icon
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
] });
|
|
356
|
+
}
|
|
357
|
+
function MarkerCircleHTML({
|
|
358
|
+
icon,
|
|
359
|
+
size,
|
|
360
|
+
color,
|
|
361
|
+
onClick,
|
|
362
|
+
href,
|
|
363
|
+
target = "_self",
|
|
364
|
+
isClickable = false,
|
|
365
|
+
iconFill = false,
|
|
366
|
+
borderColor,
|
|
367
|
+
borderWidth = 1.5
|
|
368
|
+
}) {
|
|
369
|
+
const hasAction = isClickable || onClick || href;
|
|
370
|
+
const inset = iconFill ? 0 : 4;
|
|
371
|
+
const handleClick = (e) => {
|
|
372
|
+
e.stopPropagation();
|
|
373
|
+
if (onClick) {
|
|
374
|
+
onClick();
|
|
375
|
+
} else if (href) {
|
|
376
|
+
if (target === "_blank") {
|
|
377
|
+
window.open(href, "_blank", "noopener,noreferrer");
|
|
378
|
+
} else {
|
|
379
|
+
window.location.href = href;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
return /* @__PURE__ */ jsx(
|
|
384
|
+
m.div,
|
|
385
|
+
{
|
|
386
|
+
className: cn(
|
|
387
|
+
"relative flex h-full w-full items-center justify-center rounded-full shadow-lg",
|
|
388
|
+
hasAction && "cursor-pointer"
|
|
389
|
+
),
|
|
390
|
+
onClick: hasAction ? handleClick : void 0,
|
|
391
|
+
style: {
|
|
392
|
+
backgroundColor: color || chartCssVars.markerBackground,
|
|
393
|
+
border: `${borderWidth}px solid ${borderColor ?? chartCssVars.markerBorder}`,
|
|
394
|
+
fontSize: size * 0.5,
|
|
395
|
+
color: chartCssVars.markerForeground,
|
|
396
|
+
padding: inset,
|
|
397
|
+
overflow: "hidden"
|
|
398
|
+
},
|
|
399
|
+
transition: { type: "spring", stiffness: 400, damping: 17 },
|
|
400
|
+
whileHover: hasAction ? { scale: 1.15, boxShadow: "0 4px 20px rgba(0,0,0,0.25)" } : void 0,
|
|
401
|
+
whileTap: hasAction ? { scale: 0.95 } : void 0,
|
|
402
|
+
children: icon
|
|
403
|
+
}
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
MarkerGroup.displayName = "MarkerGroup";
|
|
407
|
+
var marker_group_default = MarkerGroup;
|
|
408
|
+
export {
|
|
409
|
+
MarkerGroup,
|
|
410
|
+
marker_group_default as default
|
|
411
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DEFAULT_CHART_ENTER_TRANSITION } from "./animation";
|
|
2
|
+
function transitionWithDelay(transition, delaySeconds, fallback = DEFAULT_CHART_ENTER_TRANSITION) {
|
|
3
|
+
const base = transition ?? fallback;
|
|
4
|
+
return { ...base, delay: delaySeconds };
|
|
5
|
+
}
|
|
6
|
+
function springOptionsFromTransition(transition, fallback = { stiffness: 60, damping: 20 }) {
|
|
7
|
+
if (!transition) {
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
10
|
+
if (transition.type === "spring") {
|
|
11
|
+
const bounce = typeof transition.bounce === "number" ? transition.bounce : void 0;
|
|
12
|
+
const baseStiffness = typeof transition.stiffness === "number" ? transition.stiffness : fallback.stiffness;
|
|
13
|
+
const baseDamping = typeof transition.damping === "number" ? transition.damping : fallback.damping;
|
|
14
|
+
return {
|
|
15
|
+
stiffness: bounce == null ? baseStiffness : Math.min(400, Math.max(80, baseStiffness * (1 + bounce * 0.35))),
|
|
16
|
+
damping: bounce == null ? baseDamping : Math.max(8, baseDamping * (1 - bounce * 0.25)),
|
|
17
|
+
mass: typeof transition.mass === "number" ? transition.mass : fallback.mass
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const duration = "duration" in transition && typeof transition.duration === "number" ? transition.duration : 0.8;
|
|
21
|
+
return {
|
|
22
|
+
stiffness: Math.min(500, Math.max(40, 280 / duration)),
|
|
23
|
+
damping: Math.min(40, Math.max(12, 18 + duration * 4))
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
springOptionsFromTransition,
|
|
28
|
+
transitionWithDelay
|
|
29
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
Fragment,
|
|
4
|
+
isValidElement
|
|
5
|
+
} from "react";
|
|
6
|
+
const DEFAULT_ACTIVE_GRADIENT = [
|
|
7
|
+
"#bef264",
|
|
8
|
+
"#10b981"
|
|
9
|
+
];
|
|
10
|
+
const DEFAULT_ACTIVE_FILL_OPACITY = 1;
|
|
11
|
+
const DEFAULT_INACTIVE_FILL_OPACITY = 0.8;
|
|
12
|
+
const DEFAULT_LINEAR_GAUGE_HEIGHT = 24;
|
|
13
|
+
function isDefsComponent(child) {
|
|
14
|
+
const typeLabel = child.type?.displayName || child.type?.name || "";
|
|
15
|
+
return typeLabel.includes("Gradient") || typeLabel.includes("Pattern") || typeLabel === "LinearGradient" || typeLabel === "RadialGradient" || typeLabel === "Lines" || typeLabel === "PatternLines" || typeLabel === "Circles" || typeLabel === "Hexagons" || typeLabel === "Waves";
|
|
16
|
+
}
|
|
17
|
+
function collectGaugeDefsElements(nodes) {
|
|
18
|
+
const out = [];
|
|
19
|
+
Children.forEach(nodes, (child) => {
|
|
20
|
+
if (!isValidElement(child)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (child.type === Fragment) {
|
|
24
|
+
out.push(
|
|
25
|
+
...collectGaugeDefsElements(
|
|
26
|
+
child.props.children
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (isDefsComponent(child)) {
|
|
32
|
+
out.push(child);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function interpolateGaugeHex(color1, color2, factor) {
|
|
38
|
+
const hex = (c) => Number.parseInt(c, 16);
|
|
39
|
+
const r1 = hex(color1.slice(1, 3));
|
|
40
|
+
const g1 = hex(color1.slice(3, 5));
|
|
41
|
+
const b1 = hex(color1.slice(5, 7));
|
|
42
|
+
const r2 = hex(color2.slice(1, 3));
|
|
43
|
+
const g2 = hex(color2.slice(3, 5));
|
|
44
|
+
const b2 = hex(color2.slice(5, 7));
|
|
45
|
+
const r = Math.round(r1 + (r2 - r1) * factor);
|
|
46
|
+
const g = Math.round(g1 + (g2 - g1) * factor);
|
|
47
|
+
const b = Math.round(b1 + (b2 - b1) * factor);
|
|
48
|
+
return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
|
|
49
|
+
}
|
|
50
|
+
function createNotchPath(points, cornerRadiusPx, verticalDepth) {
|
|
51
|
+
const { x1, y1, x2, y2, x3, y3, x4, y4 } = points;
|
|
52
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
53
|
+
const dist = (ax, ay, bx, by) => Math.hypot(bx - ax, by - ay);
|
|
54
|
+
const d12 = dist(x1, y1, x2, y2);
|
|
55
|
+
const d23 = dist(x2, y2, x3, y3);
|
|
56
|
+
const d34 = dist(x3, y3, x4, y4);
|
|
57
|
+
const d41 = dist(x4, y4, x1, y1);
|
|
58
|
+
if (cornerRadiusPx <= 0) {
|
|
59
|
+
return `M ${x1} ${y1} L ${x2} ${y2} L ${x3} ${y3} L ${x4} ${y4} Z`;
|
|
60
|
+
}
|
|
61
|
+
const minEdge = Math.min(d12, d23, d34, d41);
|
|
62
|
+
const cr = Math.min(
|
|
63
|
+
cornerRadiusPx,
|
|
64
|
+
verticalDepth * 0.48,
|
|
65
|
+
d12 * 0.49,
|
|
66
|
+
d23 * 0.49,
|
|
67
|
+
d34 * 0.49,
|
|
68
|
+
d41 * 0.49,
|
|
69
|
+
minEdge * 0.49
|
|
70
|
+
);
|
|
71
|
+
const r1 = Math.min(cr / d12, 0.49);
|
|
72
|
+
const r2 = Math.min(cr / d23, 0.49);
|
|
73
|
+
const r3 = Math.min(cr / d34, 0.49);
|
|
74
|
+
const r4 = Math.min(cr / d41, 0.49);
|
|
75
|
+
const p1a = { x: lerp(x1, x4, r4), y: lerp(y1, y4, r4) };
|
|
76
|
+
const p1b = { x: lerp(x1, x2, r1), y: lerp(y1, y2, r1) };
|
|
77
|
+
const p2a = { x: lerp(x2, x1, r1), y: lerp(y2, y1, r1) };
|
|
78
|
+
const p2b = { x: lerp(x2, x3, r2), y: lerp(y2, y3, r2) };
|
|
79
|
+
const p3a = { x: lerp(x3, x2, r2), y: lerp(y3, y2, r2) };
|
|
80
|
+
const p3b = { x: lerp(x3, x4, r3), y: lerp(y3, y4, r3) };
|
|
81
|
+
const p4a = { x: lerp(x4, x3, r3), y: lerp(y4, y3, r3) };
|
|
82
|
+
const p4b = { x: lerp(x4, x1, r4), y: lerp(y4, y1, r4) };
|
|
83
|
+
return `M ${p1a.x} ${p1a.y} Q ${x1} ${y1} ${p1b.x} ${p1b.y} L ${p2a.x} ${p2a.y} Q ${x2} ${y2} ${p2b.x} ${p2b.y} L ${p3a.x} ${p3a.y} Q ${x3} ${y3} ${p3b.x} ${p3b.y} L ${p4a.x} ${p4a.y} Q ${x4} ${y4} ${p4b.x} ${p4b.y} Z`;
|
|
84
|
+
}
|
|
85
|
+
function resolveGaugeBgFill(options) {
|
|
86
|
+
const {
|
|
87
|
+
notchIndex,
|
|
88
|
+
totalNotches,
|
|
89
|
+
hasCustomInactive,
|
|
90
|
+
inactiveFill,
|
|
91
|
+
useThemePaletteGradient,
|
|
92
|
+
useGradient,
|
|
93
|
+
inactiveGrad0,
|
|
94
|
+
inactiveGrad1,
|
|
95
|
+
arcTrackFill,
|
|
96
|
+
linearTrackFill,
|
|
97
|
+
linearMode
|
|
98
|
+
} = options;
|
|
99
|
+
if (hasCustomInactive) {
|
|
100
|
+
return inactiveFill;
|
|
101
|
+
}
|
|
102
|
+
if (useThemePaletteGradient) {
|
|
103
|
+
return linearMode ? "var(--chart-1)" : arcTrackFill;
|
|
104
|
+
}
|
|
105
|
+
if (useGradient) {
|
|
106
|
+
const denom = totalNotches > 1 ? totalNotches - 1 : 1;
|
|
107
|
+
return interpolateGaugeHex(
|
|
108
|
+
inactiveGrad0,
|
|
109
|
+
inactiveGrad1,
|
|
110
|
+
notchIndex / denom
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return linearMode ? linearTrackFill : arcTrackFill;
|
|
114
|
+
}
|
|
115
|
+
function resolveGaugeActiveFill(options) {
|
|
116
|
+
const {
|
|
117
|
+
notch,
|
|
118
|
+
hasCustomActive,
|
|
119
|
+
activeFill,
|
|
120
|
+
useThemePaletteGradient,
|
|
121
|
+
themeActiveGradientId,
|
|
122
|
+
useGradient,
|
|
123
|
+
activeFillSolid
|
|
124
|
+
} = options;
|
|
125
|
+
if (hasCustomActive) {
|
|
126
|
+
return activeFill;
|
|
127
|
+
}
|
|
128
|
+
if (useThemePaletteGradient) {
|
|
129
|
+
return `url(#${themeActiveGradientId})`;
|
|
130
|
+
}
|
|
131
|
+
if (useGradient) {
|
|
132
|
+
return notch.gradientColor;
|
|
133
|
+
}
|
|
134
|
+
return activeFillSolid;
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
DEFAULT_ACTIVE_FILL_OPACITY,
|
|
138
|
+
DEFAULT_ACTIVE_GRADIENT,
|
|
139
|
+
DEFAULT_INACTIVE_FILL_OPACITY,
|
|
140
|
+
DEFAULT_LINEAR_GAUGE_HEIGHT,
|
|
141
|
+
collectGaugeDefsElements,
|
|
142
|
+
createNotchPath,
|
|
143
|
+
interpolateGaugeHex,
|
|
144
|
+
resolveGaugeActiveFill,
|
|
145
|
+
resolveGaugeBgFill
|
|
146
|
+
};
|