@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.
Files changed (267) hide show
  1. package/ALTERACOES.md +53 -0
  2. package/LICENSE-BKLIT +21 -0
  3. package/LICENSE-visx-pattern +21 -0
  4. package/README.md +188 -2
  5. package/dist/aic/cores.js +83 -0
  6. package/dist/aic/index.js +22 -0
  7. package/dist/aic/interacao.js +55 -0
  8. package/dist/charts/animation.js +55 -0
  9. package/dist/charts/arc-geometry.js +58 -0
  10. package/dist/charts/arc-path.js +15 -0
  11. package/dist/charts/area-chart-loading.js +89 -0
  12. package/dist/charts/area-chart.js +149 -0
  13. package/dist/charts/area-gradient-defs.js +90 -0
  14. package/dist/charts/area-value-label-layout.js +70 -0
  15. package/dist/charts/area-value-labels.js +211 -0
  16. package/dist/charts/area.js +272 -0
  17. package/dist/charts/background.js +198 -0
  18. package/dist/charts/band-config.js +82 -0
  19. package/dist/charts/band-geometry.js +186 -0
  20. package/dist/charts/band.js +346 -0
  21. package/dist/charts/bar-chart-loading.js +27 -0
  22. package/dist/charts/bar-chart.js +545 -0
  23. package/dist/charts/bar-depth-geometry.js +18 -0
  24. package/dist/charts/bar-depth.js +608 -0
  25. package/dist/charts/bar-lollipop.js +278 -0
  26. package/dist/charts/bar-squares-layout.js +66 -0
  27. package/dist/charts/bar-squares.js +467 -0
  28. package/dist/charts/bar-value-label-layout.js +42 -0
  29. package/dist/charts/bar-x-axis.js +133 -0
  30. package/dist/charts/bar-y-axis.js +116 -0
  31. package/dist/charts/bar.js +457 -0
  32. package/dist/charts/bollinger.js +49 -0
  33. package/dist/charts/candlestick-chart.js +370 -0
  34. package/dist/charts/candlestick.js +368 -0
  35. package/dist/charts/chart-brush-handle.js +91 -0
  36. package/dist/charts/chart-brush-layout.js +91 -0
  37. package/dist/charts/chart-brush-selection-overlay.js +87 -0
  38. package/dist/charts/chart-brush-state.js +253 -0
  39. package/dist/charts/chart-brush-track-overlay.js +103 -0
  40. package/dist/charts/chart-brush.js +517 -0
  41. package/dist/charts/chart-center-typography.js +8 -0
  42. package/dist/charts/chart-child-passthrough.js +119 -0
  43. package/dist/charts/chart-config-context.js +56 -0
  44. package/dist/charts/chart-context.js +337 -0
  45. package/dist/charts/chart-crosshair.js +262 -0
  46. package/dist/charts/chart-data-override.js +186 -0
  47. package/dist/charts/chart-defs.js +56 -0
  48. package/dist/charts/chart-formatters.js +77 -0
  49. package/dist/charts/chart-legend-hover.js +27 -0
  50. package/dist/charts/chart-legend.js +163 -0
  51. package/dist/charts/chart-loading-label.js +52 -0
  52. package/dist/charts/chart-parent-size.js +138 -0
  53. package/dist/charts/chart-phase.js +29 -0
  54. package/dist/charts/chart-reveal-clip.js +62 -0
  55. package/dist/charts/chart-scale.js +19 -0
  56. package/dist/charts/chart-stat-flow.js +72 -0
  57. package/dist/charts/choropleth/choropleth-background.js +29 -0
  58. package/dist/charts/choropleth/choropleth-camera.js +379 -0
  59. package/dist/charts/choropleth/choropleth-chart.js +644 -0
  60. package/dist/charts/choropleth/choropleth-context.js +152 -0
  61. package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
  62. package/dist/charts/choropleth/choropleth-feature.js +291 -0
  63. package/dist/charts/choropleth/choropleth-graticule.js +40 -0
  64. package/dist/charts/choropleth/choropleth-marker.js +222 -0
  65. package/dist/charts/choropleth/choropleth-projection.js +37 -0
  66. package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
  67. package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
  68. package/dist/charts/choropleth/index.js +44 -0
  69. package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
  70. package/dist/charts/composed-chart.js +346 -0
  71. package/dist/charts/crosshair-store.js +49 -0
  72. package/dist/charts/dash-tail-stroke.js +58 -0
  73. package/dist/charts/date-pill-store.js +50 -0
  74. package/dist/charts/date-ranges.js +131 -0
  75. package/dist/charts/deadline.js +295 -0
  76. package/dist/charts/decimate-time-series.js +112 -0
  77. package/dist/charts/fade-edges.js +171 -0
  78. package/dist/charts/fast-path.js +78 -0
  79. package/dist/charts/filter-data-by-x-domain.js +45 -0
  80. package/dist/charts/funnel-chart.js +773 -0
  81. package/dist/charts/gauge-arc-layers.js +479 -0
  82. package/dist/charts/gauge-dial.js +329 -0
  83. package/dist/charts/gauge-label-layout.js +148 -0
  84. package/dist/charts/gauge.js +946 -0
  85. package/dist/charts/generate-chart-skeleton-data.js +27 -0
  86. package/dist/charts/gradients.js +158 -0
  87. package/dist/charts/grid-lines.js +114 -0
  88. package/dist/charts/grid.js +225 -0
  89. package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
  90. package/dist/charts/heatmap/heatmap-animation.js +128 -0
  91. package/dist/charts/heatmap/heatmap-cells.js +519 -0
  92. package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
  93. package/dist/charts/heatmap/heatmap-chart.js +548 -0
  94. package/dist/charts/heatmap/heatmap-colors.js +127 -0
  95. package/dist/charts/heatmap/heatmap-context.js +107 -0
  96. package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
  97. package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
  98. package/dist/charts/heatmap/heatmap-legend.js +165 -0
  99. package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
  100. package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
  101. package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
  102. package/dist/charts/heatmap/heatmap-separator.js +168 -0
  103. package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
  104. package/dist/charts/heatmap/heatmap-utils.js +633 -0
  105. package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
  106. package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
  107. package/dist/charts/heatmap/index.js +208 -0
  108. package/dist/charts/highlight-segment-bounds.js +34 -0
  109. package/dist/charts/highlight-segment.js +119 -0
  110. package/dist/charts/index.js +944 -0
  111. package/dist/charts/indicator-fade.js +44 -0
  112. package/dist/charts/legend/index.js +22 -0
  113. package/dist/charts/legend/legend-context.js +47 -0
  114. package/dist/charts/legend/legend-item.js +30 -0
  115. package/dist/charts/legend/legend-label.js +14 -0
  116. package/dist/charts/legend/legend-marker.js +18 -0
  117. package/dist/charts/legend/legend-progress.js +39 -0
  118. package/dist/charts/legend/legend-value.js +31 -0
  119. package/dist/charts/legend/legend.js +69 -0
  120. package/dist/charts/line-backdrop.js +129 -0
  121. package/dist/charts/line-chart-loading.js +85 -0
  122. package/dist/charts/line-chart.js +182 -0
  123. package/dist/charts/line-loading-pulse.js +185 -0
  124. package/dist/charts/line-loading-timing.js +12 -0
  125. package/dist/charts/line-path.js +58 -0
  126. package/dist/charts/line-series-terminal-marker.js +75 -0
  127. package/dist/charts/line.js +499 -0
  128. package/dist/charts/live-line-chart.js +494 -0
  129. package/dist/charts/live-line.js +277 -0
  130. package/dist/charts/live-x-axis.js +116 -0
  131. package/dist/charts/live-y-axis.js +164 -0
  132. package/dist/charts/loading-sweep.js +344 -0
  133. package/dist/charts/local-point.js +56 -0
  134. package/dist/charts/markers/chart-markers.js +149 -0
  135. package/dist/charts/markers/index.js +14 -0
  136. package/dist/charts/markers/marker-group.js +411 -0
  137. package/dist/charts/motion-utils.js +29 -0
  138. package/dist/charts/notch-gauge-shared.js +146 -0
  139. package/dist/charts/particle-line.js +1340 -0
  140. package/dist/charts/path-stroke-utils.js +51 -0
  141. package/dist/charts/pattern-area.js +127 -0
  142. package/dist/charts/pattern-preset.js +287 -0
  143. package/dist/charts/pattern-tile.js +31 -0
  144. package/dist/charts/patterns/circles.js +62 -0
  145. package/dist/charts/patterns/constants.js +9 -0
  146. package/dist/charts/patterns/hexagons.js +38 -0
  147. package/dist/charts/patterns/index.js +16 -0
  148. package/dist/charts/patterns/lines.js +65 -0
  149. package/dist/charts/patterns/path.js +37 -0
  150. package/dist/charts/patterns/pattern.js +16 -0
  151. package/dist/charts/patterns/waves.js +40 -0
  152. package/dist/charts/pie-center-shell.js +127 -0
  153. package/dist/charts/pie-center.js +87 -0
  154. package/dist/charts/pie-chart.js +377 -0
  155. package/dist/charts/pie-context.js +116 -0
  156. package/dist/charts/pie-slice.js +394 -0
  157. package/dist/charts/pie-ticks.js +332 -0
  158. package/dist/charts/profit-loss-legend-hover.js +18 -0
  159. package/dist/charts/profit-loss-legend.js +53 -0
  160. package/dist/charts/profit-loss-line.js +162 -0
  161. package/dist/charts/profit-loss-segments.js +88 -0
  162. package/dist/charts/projection-config.js +90 -0
  163. package/dist/charts/projection-line-end-marker.js +50 -0
  164. package/dist/charts/projection-line.js +466 -0
  165. package/dist/charts/projection-utils.js +303 -0
  166. package/dist/charts/radar-area.js +192 -0
  167. package/dist/charts/radar-axis.js +41 -0
  168. package/dist/charts/radar-chart.js +184 -0
  169. package/dist/charts/radar-context.js +104 -0
  170. package/dist/charts/radar-grid.js +121 -0
  171. package/dist/charts/radar-labels.js +62 -0
  172. package/dist/charts/radial-area.js +498 -0
  173. package/dist/charts/radial-axis.js +652 -0
  174. package/dist/charts/radial-bar.js +316 -0
  175. package/dist/charts/radial-center.js +67 -0
  176. package/dist/charts/radial-chart.js +740 -0
  177. package/dist/charts/radial-dot-bar-layout.js +68 -0
  178. package/dist/charts/radial-dot-bar.js +387 -0
  179. package/dist/charts/radial-geometry.js +114 -0
  180. package/dist/charts/radial-legend.js +66 -0
  181. package/dist/charts/radial-line.js +280 -0
  182. package/dist/charts/radial-ring-bar.js +255 -0
  183. package/dist/charts/radial-scrubber.js +120 -0
  184. package/dist/charts/radial-series-color.js +10 -0
  185. package/dist/charts/reference-area-config.js +43 -0
  186. package/dist/charts/reference-area-geometry.js +76 -0
  187. package/dist/charts/reference-area-registration-context.js +10 -0
  188. package/dist/charts/reference-area.js +241 -0
  189. package/dist/charts/responsive-chart-label-count.js +18 -0
  190. package/dist/charts/ring-center.js +78 -0
  191. package/dist/charts/ring-chart.js +362 -0
  192. package/dist/charts/ring-context.js +122 -0
  193. package/dist/charts/ring-grid.js +175 -0
  194. package/dist/charts/ring-labels.js +109 -0
  195. package/dist/charts/ring.js +237 -0
  196. package/dist/charts/sankey/index.js +22 -0
  197. package/dist/charts/sankey/sankey-chart.js +199 -0
  198. package/dist/charts/sankey/sankey-context.js +32 -0
  199. package/dist/charts/sankey/sankey-link.js +232 -0
  200. package/dist/charts/sankey/sankey-node.js +348 -0
  201. package/dist/charts/sankey/sankey-tooltip.js +94 -0
  202. package/dist/charts/scatter-chart-shell.js +279 -0
  203. package/dist/charts/scatter-chart.js +150 -0
  204. package/dist/charts/scatter-jitter.js +86 -0
  205. package/dist/charts/scatter-svg.js +17 -0
  206. package/dist/charts/scatter.js +92 -0
  207. package/dist/charts/segment.js +107 -0
  208. package/dist/charts/series-bar-layout.js +42 -0
  209. package/dist/charts/series-bar.js +241 -0
  210. package/dist/charts/series-dash-tail-overlay.js +53 -0
  211. package/dist/charts/series-highlight-layer.js +43 -0
  212. package/dist/charts/series-hover-dim.js +32 -0
  213. package/dist/charts/series-markers.js +239 -0
  214. package/dist/charts/series-path-utils.js +185 -0
  215. package/dist/charts/series-point-marker.js +150 -0
  216. package/dist/charts/sparkline-geometry.js +197 -0
  217. package/dist/charts/sparkline.js +910 -0
  218. package/dist/charts/static-chart-preview-context.js +16 -0
  219. package/dist/charts/sunburst-breadcrumb.js +33 -0
  220. package/dist/charts/sunburst-center.js +37 -0
  221. package/dist/charts/sunburst-chart.js +408 -0
  222. package/dist/charts/sunburst-context.js +140 -0
  223. package/dist/charts/sunburst-data.js +0 -0
  224. package/dist/charts/sunburst-hint.js +42 -0
  225. package/dist/charts/sunburst-labels.js +130 -0
  226. package/dist/charts/sunburst-segment.js +144 -0
  227. package/dist/charts/sunburst.js +419 -0
  228. package/dist/charts/time-series-chart-shell.js +688 -0
  229. package/dist/charts/tooltip/chart-tooltip.js +516 -0
  230. package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
  231. package/dist/charts/tooltip/date-ticker.js +376 -0
  232. package/dist/charts/tooltip/index.js +32 -0
  233. package/dist/charts/tooltip/liquid-glass.js +142 -0
  234. package/dist/charts/tooltip/tooltip-box.js +502 -0
  235. package/dist/charts/tooltip/tooltip-content.js +59 -0
  236. package/dist/charts/tooltip/tooltip-dot.js +170 -0
  237. package/dist/charts/tooltip/tooltip-indicator.js +175 -0
  238. package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
  239. package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
  240. package/dist/charts/trend-line-utils.js +64 -0
  241. package/dist/charts/trend-line.js +318 -0
  242. package/dist/charts/use-animated-band.js +175 -0
  243. package/dist/charts/use-animated-series-path.js +208 -0
  244. package/dist/charts/use-animated-y-domains.js +192 -0
  245. package/dist/charts/use-category-slots.js +29 -0
  246. package/dist/charts/use-chart-interaction.js +296 -0
  247. package/dist/charts/use-chart-phase-orchestrator.js +183 -0
  248. package/dist/charts/use-enter-complete.js +18 -0
  249. package/dist/charts/use-grid-shimmer.js +88 -0
  250. package/dist/charts/use-highlight-segment.js +65 -0
  251. package/dist/charts/use-mount-progress.js +23 -0
  252. package/dist/charts/use-scatter-chart-interaction.js +364 -0
  253. package/dist/charts/use-scheduled-tooltip.js +84 -0
  254. package/dist/charts/visx-pattern.js +30 -0
  255. package/dist/charts/weekends.js +174 -0
  256. package/dist/charts/x-axis-hover.js +46 -0
  257. package/dist/charts/x-axis.js +523 -0
  258. package/dist/charts/y-axis-scales.js +71 -0
  259. package/dist/charts/y-axis-ticks.js +22 -0
  260. package/dist/charts/y-axis.js +233 -0
  261. package/dist/charts/y-domain-utils.js +189 -0
  262. package/dist/index.d.ts +7346 -0
  263. package/dist/index.js +2 -0
  264. package/dist/lib/utils.js +8 -0
  265. package/dist/shimmering-text.js +54 -0
  266. package/package.json +78 -4
  267. package/tema.css +202 -0
@@ -0,0 +1,76 @@
1
+ function toDate(value) {
2
+ return value instanceof Date ? value : new Date(value);
3
+ }
4
+ function resolveXPixel(xScale, value, fallback) {
5
+ if (value == null) {
6
+ return fallback;
7
+ }
8
+ return xScale(toDate(value));
9
+ }
10
+ function resolveYPixel(yScale, value, fallback) {
11
+ if (value == null) {
12
+ return fallback;
13
+ }
14
+ return yScale(value);
15
+ }
16
+ function clampRectToPlot(rect, innerWidth, innerHeight) {
17
+ const x1 = Math.max(0, rect.x);
18
+ const y1 = Math.max(0, rect.y);
19
+ const x2 = Math.min(innerWidth, rect.x + rect.width);
20
+ const y2 = Math.min(innerHeight, rect.y + rect.height);
21
+ const width = x2 - x1;
22
+ const height = y2 - y1;
23
+ if (width <= 0 || height <= 0) {
24
+ return null;
25
+ }
26
+ return { x: x1, y: y1, width, height };
27
+ }
28
+ function isFullyInsidePlot(rect, innerWidth, innerHeight) {
29
+ return rect.x >= 0 && rect.y >= 0 && rect.x + rect.width <= innerWidth && rect.y + rect.height <= innerHeight;
30
+ }
31
+ function computeReferenceAreaRect(options) {
32
+ const {
33
+ innerWidth,
34
+ innerHeight,
35
+ x1,
36
+ x2,
37
+ y1,
38
+ y2,
39
+ ifOverflow = "hidden",
40
+ xScale,
41
+ yScale
42
+ } = options;
43
+ if (innerWidth <= 0 || innerHeight <= 0) {
44
+ return null;
45
+ }
46
+ const left = resolveXPixel(xScale, x1, 0);
47
+ const right = resolveXPixel(xScale, x2, innerWidth);
48
+ const top = resolveYPixel(yScale, y1, 0);
49
+ const bottom = resolveYPixel(yScale, y2, innerHeight);
50
+ const x = Math.min(left, right);
51
+ const y = Math.min(top, bottom);
52
+ const width = Math.abs(right - left);
53
+ const height = Math.abs(bottom - top);
54
+ if (width <= 0 || height <= 0) {
55
+ return null;
56
+ }
57
+ const rect = { x, y, width, height };
58
+ if (ifOverflow === "visible") {
59
+ return rect;
60
+ }
61
+ if (ifOverflow === "discard") {
62
+ return isFullyInsidePlot(rect, innerWidth, innerHeight) ? rect : null;
63
+ }
64
+ return clampRectToPlot(rect, innerWidth, innerHeight);
65
+ }
66
+ function resolveReferenceDataRange(y1, y2, domain) {
67
+ const dMin = Math.min(domain[0], domain[1]);
68
+ const dMax = Math.max(domain[0], domain[1]);
69
+ const low = y1 ?? dMin;
70
+ const high = y2 ?? dMax;
71
+ return [Math.min(low, high), Math.max(low, high)];
72
+ }
73
+ export {
74
+ computeReferenceAreaRect,
75
+ resolveReferenceDataRange
76
+ };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ const ReferenceAreaRegistrationContext = createContext(null);
4
+ function useReferenceAreaRegistration() {
5
+ return useContext(ReferenceAreaRegistrationContext);
6
+ }
7
+ export {
8
+ ReferenceAreaRegistrationContext,
9
+ useReferenceAreaRegistration
10
+ };
@@ -0,0 +1,241 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { m } from "motion/react";
4
+ import { useId, useLayoutEffect, useMemo } from "react";
5
+ import { chartCssVars, useChartStable, useYScale } from "./chart-context";
6
+ import { renderPatternPreset } from "./pattern-preset";
7
+ import {
8
+ computeReferenceAreaRect
9
+ } from "./reference-area-geometry";
10
+ import { useReferenceAreaRegistration } from "./reference-area-registration-context";
11
+ import { normalizeYAxisId } from "./y-axis-scales";
12
+ import { isReferenceAreaVisiblePhase } from "./y-domain-utils";
13
+ const DEFAULT_FILL = "color-mix(in oklch, var(--chart-foreground-muted) 12%, transparent)";
14
+ const ENTER_FADE_MS = 420;
15
+ function clampFadeLength(length) {
16
+ return Math.min(45, Math.max(0, length));
17
+ }
18
+ function bracketMarkerPath(centerX, edgeY, size, direction) {
19
+ const half = size / 2;
20
+ if (direction === "down") {
21
+ return `M ${centerX - half} ${edgeY} L ${centerX + half} ${edgeY} L ${centerX} ${edgeY + size} Z`;
22
+ }
23
+ return `M ${centerX - half} ${edgeY} L ${centerX + half} ${edgeY} L ${centerX} ${edgeY - size} Z`;
24
+ }
25
+ function ReferenceArea({
26
+ y1,
27
+ y2,
28
+ x1,
29
+ x2,
30
+ yAxisId,
31
+ fill = DEFAULT_FILL,
32
+ fillOpacity = 1,
33
+ pattern = "none",
34
+ patternColor = chartCssVars.foregroundMuted,
35
+ patternScale = 1,
36
+ patternStrokeWidth,
37
+ patternRadius,
38
+ patternComplement,
39
+ patternFill,
40
+ patternDotFill,
41
+ patternTileBackground,
42
+ stroke = chartCssVars.foregroundMuted,
43
+ strokeWidth = 1,
44
+ strokeStyle = "dashed",
45
+ strokeDasharray = "4,4",
46
+ fadeEdges = true,
47
+ fadeEdgesLength = 10,
48
+ axisLabelColor,
49
+ showMarkers = false,
50
+ markerColor = "var(--chart-1)",
51
+ markerSize = 6,
52
+ ifOverflow = "hidden",
53
+ className
54
+ }) {
55
+ const { innerWidth, innerHeight, xScale, chartPhase, enterTransition } = useChartStable();
56
+ const yScale = useYScale(yAxisId);
57
+ const uniqueId = useId().replace(/:/g, "");
58
+ const registration = useReferenceAreaRegistration();
59
+ useLayoutEffect(() => {
60
+ if (!registration) {
61
+ return;
62
+ }
63
+ registration.registerReferenceArea(uniqueId, {
64
+ yAxisId: normalizeYAxisId(yAxisId),
65
+ y1,
66
+ y2,
67
+ axisLabelColor
68
+ });
69
+ return () => registration.unregisterReferenceArea(uniqueId);
70
+ }, [registration, uniqueId, yAxisId, y1, y2, axisLabelColor]);
71
+ const patternId = `chart-reference-area-pattern-${uniqueId}`;
72
+ const hMaskId = `chart-reference-area-fade-${uniqueId}`;
73
+ const hGradientId = `${hMaskId}-gradient`;
74
+ const rect = useMemo(
75
+ () => computeReferenceAreaRect({
76
+ innerWidth,
77
+ innerHeight,
78
+ x1,
79
+ x2,
80
+ y1,
81
+ y2,
82
+ ifOverflow,
83
+ xScale,
84
+ yScale
85
+ }),
86
+ [innerWidth, innerHeight, x1, x2, y1, y2, ifOverflow, xScale, yScale]
87
+ );
88
+ const usesPattern = pattern !== "none";
89
+ const patternNode = useMemo(() => {
90
+ if (!usesPattern) {
91
+ return null;
92
+ }
93
+ return renderPatternPreset(pattern, patternId, {
94
+ color: patternColor,
95
+ scale: patternScale,
96
+ strokeWidth: patternStrokeWidth,
97
+ radius: patternRadius,
98
+ complement: patternComplement,
99
+ fill: patternFill,
100
+ dotFill: patternDotFill,
101
+ tileBackground: patternTileBackground
102
+ });
103
+ }, [
104
+ usesPattern,
105
+ pattern,
106
+ patternId,
107
+ patternColor,
108
+ patternScale,
109
+ patternStrokeWidth,
110
+ patternRadius,
111
+ patternComplement,
112
+ patternFill,
113
+ patternDotFill,
114
+ patternTileBackground
115
+ ]);
116
+ const fadeEdge = clampFadeLength(fadeEdgesLength);
117
+ const edgeMask = fadeEdges ? `url(#${hMaskId})` : void 0;
118
+ const lineDash = strokeStyle === "dashed" ? strokeDasharray : void 0;
119
+ if (!rect) {
120
+ return null;
121
+ }
122
+ const { x, y, width, height } = rect;
123
+ const topEdgeY = y;
124
+ const bottomEdgeY = y + height;
125
+ const centerX = x + width / 2;
126
+ const visible = isReferenceAreaVisiblePhase(chartPhase);
127
+ const fadeTransition = enterTransition && typeof enterTransition === "object" ? enterTransition : { duration: ENTER_FADE_MS / 1e3, ease: "easeOut" };
128
+ const areaFill = usesPattern && patternNode ? `url(#${patternId})` : fill;
129
+ return (
130
+ // biome-ignore lint/a11y/noAriaHiddenOnFocusable: decorative reference band
131
+ /* @__PURE__ */ jsxs(
132
+ m.g,
133
+ {
134
+ animate: { opacity: visible ? 1 : 0 },
135
+ "aria-hidden": "true",
136
+ className: className ?? "chart-reference-area",
137
+ initial: { opacity: 0 },
138
+ transition: fadeTransition,
139
+ children: [
140
+ edgeMask ? /* @__PURE__ */ jsxs("defs", { children: [
141
+ /* @__PURE__ */ jsxs("linearGradient", { id: hGradientId, x1: "0%", x2: "100%", y1: "0%", y2: "0%", children: [
142
+ /* @__PURE__ */ jsx("stop", { offset: "0%", style: { stopColor: "white", stopOpacity: 0 } }),
143
+ /* @__PURE__ */ jsx(
144
+ "stop",
145
+ {
146
+ offset: `${fadeEdge}%`,
147
+ style: { stopColor: "white", stopOpacity: 1 }
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsx(
151
+ "stop",
152
+ {
153
+ offset: `${100 - fadeEdge}%`,
154
+ style: { stopColor: "white", stopOpacity: 1 }
155
+ }
156
+ ),
157
+ /* @__PURE__ */ jsx(
158
+ "stop",
159
+ {
160
+ offset: "100%",
161
+ style: { stopColor: "white", stopOpacity: 0 }
162
+ }
163
+ )
164
+ ] }),
165
+ /* @__PURE__ */ jsx("mask", { id: hMaskId, children: /* @__PURE__ */ jsx(
166
+ "rect",
167
+ {
168
+ fill: `url(#${hGradientId})`,
169
+ height: innerHeight,
170
+ width: innerWidth,
171
+ x: 0,
172
+ y: 0
173
+ }
174
+ ) })
175
+ ] }) : null,
176
+ patternNode ? /* @__PURE__ */ jsx("defs", { children: patternNode }) : null,
177
+ /* @__PURE__ */ jsx(
178
+ "rect",
179
+ {
180
+ fill: areaFill,
181
+ fillOpacity,
182
+ height,
183
+ mask: edgeMask,
184
+ width,
185
+ x,
186
+ y
187
+ }
188
+ ),
189
+ /* @__PURE__ */ jsxs("g", { mask: edgeMask, children: [
190
+ /* @__PURE__ */ jsx(
191
+ "line",
192
+ {
193
+ stroke,
194
+ strokeDasharray: lineDash,
195
+ strokeWidth,
196
+ x1: x,
197
+ x2: x + width,
198
+ y1: topEdgeY,
199
+ y2: topEdgeY
200
+ }
201
+ ),
202
+ /* @__PURE__ */ jsx(
203
+ "line",
204
+ {
205
+ stroke,
206
+ strokeDasharray: lineDash,
207
+ strokeWidth,
208
+ x1: x,
209
+ x2: x + width,
210
+ y1: bottomEdgeY,
211
+ y2: bottomEdgeY
212
+ }
213
+ )
214
+ ] }),
215
+ showMarkers ? /* @__PURE__ */ jsxs(Fragment, { children: [
216
+ /* @__PURE__ */ jsx(
217
+ "path",
218
+ {
219
+ d: bracketMarkerPath(centerX, topEdgeY, markerSize, "down"),
220
+ fill: markerColor
221
+ }
222
+ ),
223
+ /* @__PURE__ */ jsx(
224
+ "path",
225
+ {
226
+ d: bracketMarkerPath(centerX, bottomEdgeY, markerSize, "up"),
227
+ fill: markerColor
228
+ }
229
+ )
230
+ ] }) : null
231
+ ]
232
+ }
233
+ )
234
+ );
235
+ }
236
+ ReferenceArea.displayName = "ReferenceArea";
237
+ var reference_area_default = ReferenceArea;
238
+ export {
239
+ ReferenceArea,
240
+ reference_area_default as default
241
+ };
@@ -0,0 +1,18 @@
1
+ function resolveResponsiveChartLabelCount(value, containerWidth, fallback) {
2
+ if (typeof value === "number") {
3
+ return value;
4
+ }
5
+ const candidates = [
6
+ [1280, value.xl],
7
+ [1024, value.lg],
8
+ [768, value.md],
9
+ [640, value.sm],
10
+ [0, value.base]
11
+ ];
12
+ return candidates.find(
13
+ ([minWidth, count]) => containerWidth >= minWidth && count != null
14
+ )?.[1] ?? fallback;
15
+ }
16
+ export {
17
+ resolveResponsiveChartLabelCount
18
+ };
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { cn } from "../lib/utils";
4
+ import {
5
+ chartCenterContainerClassName,
6
+ chartCenterLabelClassName,
7
+ chartCenterValueClassName
8
+ } from "./chart-center-typography";
9
+ import {
10
+ ChartStatFlow,
11
+ defaultChartStatFlowFormat
12
+ } from "./chart-stat-flow";
13
+ import { useRingHover, useRingStable } from "./ring-context";
14
+ function RingCenter({
15
+ defaultLabel = "Total",
16
+ formatOptions = defaultChartStatFlowFormat,
17
+ children,
18
+ className = "",
19
+ valueClassName = chartCenterValueClassName,
20
+ labelClassName = chartCenterLabelClassName,
21
+ prefix,
22
+ suffix
23
+ }) {
24
+ const { data, totalValue, baseInnerRadius } = useRingStable();
25
+ const { hoveredIndex } = useRingHover();
26
+ const hoveredData = hoveredIndex === null ? null : data[hoveredIndex];
27
+ const displayValue = hoveredData ? hoveredData.value : totalValue;
28
+ const displayLabel = hoveredData ? hoveredData.label : defaultLabel;
29
+ const centerSize = baseInnerRadius * 2 - 16;
30
+ if (children && hoveredData) {
31
+ return /* @__PURE__ */ jsx(
32
+ "div",
33
+ {
34
+ className: cn(
35
+ chartCenterContainerClassName,
36
+ "flex items-center justify-center",
37
+ className
38
+ ),
39
+ style: { width: centerSize, height: centerSize },
40
+ children: children({
41
+ value: displayValue,
42
+ label: displayLabel,
43
+ isHovered: hoveredIndex !== null,
44
+ data: hoveredData
45
+ })
46
+ }
47
+ );
48
+ }
49
+ return /* @__PURE__ */ jsx(
50
+ "div",
51
+ {
52
+ className: cn(
53
+ chartCenterContainerClassName,
54
+ "flex flex-col items-center justify-center text-center",
55
+ className
56
+ ),
57
+ style: { width: centerSize, height: centerSize },
58
+ children: /* @__PURE__ */ jsx(
59
+ ChartStatFlow,
60
+ {
61
+ formatOptions,
62
+ label: displayLabel,
63
+ labelClassName,
64
+ prefix,
65
+ suffix,
66
+ value: displayValue,
67
+ valueClassName
68
+ }
69
+ )
70
+ }
71
+ );
72
+ }
73
+ RingCenter.displayName = "RingCenter";
74
+ var ring_center_default = RingCenter;
75
+ export {
76
+ RingCenter,
77
+ ring_center_default as default
78
+ };