@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.
Files changed (267) hide show
  1. package/ALTERACOES.md +57 -0
  2. package/LICENSE-BKLIT +21 -0
  3. package/LICENSE-visx-pattern +21 -0
  4. package/README.md +189 -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,68 @@
1
+ import { createRadialScale, polarToCartesian, TAU } from "./radial-geometry";
2
+ function radialDotRowRadius(baseRadius, spacing, row) {
3
+ return baseRadius + spacing * (row + 0.5);
4
+ }
5
+ function computeRadialDotGrid({
6
+ binCount,
7
+ baseRadius,
8
+ spacing,
9
+ rows,
10
+ layout = "grid"
11
+ }) {
12
+ const byBin = Array.from({ length: binCount }, () => []);
13
+ if (binCount <= 0 || spacing <= 0 || rows <= 0) {
14
+ return byBin;
15
+ }
16
+ for (let row = 0; row < rows; row++) {
17
+ const radius = radialDotRowRadius(baseRadius, spacing, row);
18
+ const count = layout === "columns" ? binCount : Math.max(1, Math.round(TAU * radius / spacing));
19
+ for (let j = 0; j < count; j++) {
20
+ const angle = (j + 0.5) / count * TAU;
21
+ const bin = Math.min(binCount - 1, Math.floor(angle / TAU * binCount));
22
+ const { x, y } = polarToCartesian(angle, radius);
23
+ byBin[bin]?.push({ row, bin, angle, radius, x, y });
24
+ }
25
+ }
26
+ return byBin;
27
+ }
28
+ function createRadialRowScale({
29
+ maxValue,
30
+ baseRadius,
31
+ spacing,
32
+ rows
33
+ }) {
34
+ const radial = createRadialScale({
35
+ maxValue,
36
+ innerRadius: baseRadius,
37
+ outerRadius: baseRadius + rows * spacing
38
+ });
39
+ return (value) => {
40
+ if (!(value > 0)) {
41
+ return 0;
42
+ }
43
+ return Math.max(0, Math.round((radial(value) - baseRadius) / spacing));
44
+ };
45
+ }
46
+ function stackRadialRows(values, toRows, maxRows) {
47
+ const ends = [];
48
+ let cumulative = 0;
49
+ let previousEnd = 0;
50
+ for (const value of values) {
51
+ const v = value > 0 ? value : 0;
52
+ cumulative += v;
53
+ let end = toRows(cumulative);
54
+ if (v > 0) {
55
+ end = Math.max(end, previousEnd + 1);
56
+ }
57
+ end = Math.min(maxRows, Math.max(previousEnd, end));
58
+ ends.push(end);
59
+ previousEnd = end;
60
+ }
61
+ return ends;
62
+ }
63
+ export {
64
+ computeRadialDotGrid,
65
+ createRadialRowScale,
66
+ radialDotRowRadius,
67
+ stackRadialRows
68
+ };
@@ -0,0 +1,387 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { memo, useId, useMemo } from "react";
4
+ import {
5
+ patternPresetTileSize,
6
+ renderPatternPreset
7
+ } from "./pattern-preset";
8
+ import { radialLabelFontSize } from "./radial-axis";
9
+ import {
10
+ radialNumberAt,
11
+ useRadialChart
12
+ } from "./radial-chart";
13
+ import {
14
+ computeRadialDotGrid,
15
+ createRadialRowScale,
16
+ radialDotRowRadius,
17
+ stackRadialRows
18
+ } from "./radial-dot-bar-layout";
19
+ import { polarToCartesian } from "./radial-geometry";
20
+ import { radialSeriesColor } from "./radial-series-color";
21
+ const ENTER_SPREAD_S = 0.75;
22
+ const ENTER_ROW_STEP_S = 0.03;
23
+ const ENTER_DURATION_S = 0.36;
24
+ function fitTileCount(diameter, tile) {
25
+ return Math.max(1, Math.round(diameter / Math.max(0.5, tile)));
26
+ }
27
+ function resolveDotFill({
28
+ pattern,
29
+ color,
30
+ id,
31
+ diameter
32
+ }) {
33
+ if (pattern === void 0 || pattern === "none") {
34
+ return { fill: color, inset: 0, defs: null };
35
+ }
36
+ const spec = typeof pattern === "string" ? { preset: pattern } : pattern;
37
+ const patternColor = spec.color ?? color;
38
+ const stroke = spec.stroke ?? patternColor;
39
+ const ringWidth = stroke === "none" ? 0 : spec.ringWidth ?? 1;
40
+ const ring = {
41
+ stroke: ringWidth > 0 ? stroke : void 0,
42
+ strokeWidth: ringWidth > 0 ? ringWidth : void 0,
43
+ inset: ringWidth / 2
44
+ };
45
+ if (spec.fill) {
46
+ return { fill: spec.fill, defs: null, ...ring };
47
+ }
48
+ const preset = spec.preset ?? "diagonal-up";
49
+ if (preset === "none") {
50
+ return { fill: patternColor, defs: null, ...ring };
51
+ }
52
+ const baseScale = spec.scale ?? 1;
53
+ const options = {
54
+ color: patternColor,
55
+ strokeWidth: spec.strokeWidth,
56
+ tileBackground: spec.background
57
+ };
58
+ if ((spec.units ?? "dot") === "chart" || diameter <= 0) {
59
+ return {
60
+ fill: `url(#${id})`,
61
+ defs: renderPatternPreset(preset, id, { ...options, scale: baseScale }),
62
+ ...ring
63
+ };
64
+ }
65
+ const tile = patternPresetTileSize(preset, baseScale).width;
66
+ const count = fitTileCount(diameter, tile);
67
+ const scale = baseScale * diameter / (count * tile);
68
+ const baseId = `${id}-base`;
69
+ return {
70
+ fill: `url(#${id})`,
71
+ defs: /* @__PURE__ */ jsxs(Fragment, { children: [
72
+ renderPatternPreset(preset, baseId, { ...options, scale }),
73
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
74
+ "pattern",
75
+ {
76
+ height: 1 / count,
77
+ href: `#${baseId}`,
78
+ id,
79
+ patternUnits: "objectBoundingBox",
80
+ width: 1 / count,
81
+ x: 0,
82
+ y: 0
83
+ }
84
+ ) })
85
+ ] }),
86
+ ...ring
87
+ };
88
+ }
89
+ const DotGroups = memo(function DotGroups2({
90
+ groups,
91
+ revealed,
92
+ animate,
93
+ hoveredSeries,
94
+ fadedOpacity
95
+ }) {
96
+ return /* @__PURE__ */ jsx("g", { pointerEvents: "none", children: groups.map((group) => {
97
+ const dimmed = hoveredSeries !== null && hoveredSeries !== group.seriesIndex;
98
+ return /* @__PURE__ */ jsx(
99
+ "g",
100
+ {
101
+ fill: group.fill,
102
+ stroke: group.stroke,
103
+ strokeWidth: group.strokeWidth,
104
+ style: {
105
+ opacity: dimmed ? fadedOpacity : 1,
106
+ transition: "opacity 0.15s ease-out"
107
+ },
108
+ children: group.dots.map((dot) => /* @__PURE__ */ jsx(
109
+ "circle",
110
+ {
111
+ cx: dot.x,
112
+ cy: dot.y,
113
+ r: dot.r,
114
+ style: {
115
+ opacity: revealed ? dot.opacity : 0,
116
+ transform: revealed ? void 0 : "scale(0)",
117
+ transformBox: "fill-box",
118
+ transformOrigin: "center",
119
+ transition: animate ? `opacity ${ENTER_DURATION_S}s ease-out ${dot.delay}s, transform ${ENTER_DURATION_S}s cubic-bezier(0.2, 0.8, 0.2, 1) ${dot.delay}s` : void 0
120
+ }
121
+ },
122
+ dot.key
123
+ ))
124
+ },
125
+ group.key
126
+ );
127
+ }) });
128
+ });
129
+ function annotationSeriesColor(series, ends) {
130
+ let index = series.findIndex((s) => s.emphasize);
131
+ if (index < 0 && ends) {
132
+ for (let i = ends.length - 1; i >= 0; i--) {
133
+ if ((ends[i] ?? 0) > (i > 0 ? ends[i - 1] ?? 0 : 0)) {
134
+ index = i;
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ return radialSeriesColor(series[index], Math.max(0, index));
140
+ }
141
+ function RadialDotBar({
142
+ ghostDataKey,
143
+ ghostColor = "var(--chart-foreground)",
144
+ ghostOpacity = 0.22,
145
+ maxValue: maxValueProp,
146
+ rows = 14,
147
+ layout = "grid",
148
+ dotSize = 0.44,
149
+ ghostDotSize = 0.26,
150
+ rampExtent = 0.5,
151
+ annotations,
152
+ fadedOpacity = 0.2,
153
+ patterns
154
+ }) {
155
+ const patternIdBase = `radial-dot-pattern-${useId().replace(/:/g, "")}`;
156
+ const {
157
+ data,
158
+ series,
159
+ binCount,
160
+ radius,
161
+ layout: ringLayout,
162
+ innerRadius,
163
+ outerRadius,
164
+ futureBins,
165
+ hoveredSeries,
166
+ revealed,
167
+ animate,
168
+ binAngle
169
+ } = useRadialChart();
170
+ const maxValue = useMemo(() => {
171
+ if (maxValueProp !== void 0) {
172
+ return maxValueProp;
173
+ }
174
+ let max = 0;
175
+ data.forEach((d, i) => {
176
+ const value = futureBins[i] ? (ghostDataKey ? radialNumberAt(d, ghostDataKey) : 0) ?? 0 : series.reduce(
177
+ (sum, s) => sum + Math.max(0, radialNumberAt(d, s.dataKey) ?? 0),
178
+ 0
179
+ );
180
+ max = Math.max(max, value);
181
+ });
182
+ return max;
183
+ }, [maxValueProp, data, series, futureBins, ghostDataKey]);
184
+ const spacing = rows > 0 ? (outerRadius - innerRadius) / rows : 0;
185
+ const grid = useMemo(
186
+ () => computeRadialDotGrid({
187
+ binCount,
188
+ baseRadius: innerRadius,
189
+ spacing,
190
+ rows,
191
+ layout
192
+ }),
193
+ [binCount, innerRadius, spacing, rows, layout]
194
+ );
195
+ const toRows = useMemo(
196
+ () => createRadialRowScale({
197
+ maxValue,
198
+ baseRadius: innerRadius,
199
+ spacing,
200
+ rows
201
+ }),
202
+ [maxValue, innerRadius, spacing, rows]
203
+ );
204
+ const stackEnds = useMemo(
205
+ () => data.map((d, i) => {
206
+ if (futureBins[i]) {
207
+ const ghost = ghostDataKey ? radialNumberAt(d, ghostDataKey) ?? 0 : 0;
208
+ return stackRadialRows([ghost], toRows, rows);
209
+ }
210
+ return stackRadialRows(
211
+ series.map((s) => radialNumberAt(d, s.dataKey) ?? 0),
212
+ toRows,
213
+ rows
214
+ );
215
+ }),
216
+ [data, futureBins, ghostDataKey, series, toRows, rows]
217
+ );
218
+ const fills = useMemo(() => {
219
+ const dotDiameter = spacing * dotSize;
220
+ const seriesFills = series.map(
221
+ (s, seriesIndex) => resolveDotFill({
222
+ pattern: patterns?.[s.dataKey],
223
+ color: radialSeriesColor(s, seriesIndex),
224
+ id: `${patternIdBase}-${seriesIndex}`,
225
+ diameter: dotDiameter
226
+ })
227
+ );
228
+ const ghostFill = resolveDotFill({
229
+ pattern: patterns?.ghost,
230
+ color: ghostColor,
231
+ id: `${patternIdBase}-ghost`,
232
+ diameter: spacing * ghostDotSize
233
+ });
234
+ return { series: seriesFills, ghost: ghostFill };
235
+ }, [
236
+ spacing,
237
+ dotSize,
238
+ ghostDotSize,
239
+ series,
240
+ patterns,
241
+ ghostColor,
242
+ patternIdBase
243
+ ]);
244
+ const groups = useMemo(() => {
245
+ if (spacing <= 0) {
246
+ return [];
247
+ }
248
+ const seriesGroups = series.map((s, seriesIndex) => {
249
+ const f = fills.series[seriesIndex];
250
+ return {
251
+ key: `series-${s.dataKey}`,
252
+ seriesIndex,
253
+ fill: f?.fill ?? radialSeriesColor(s, seriesIndex),
254
+ stroke: f?.stroke,
255
+ strokeWidth: f?.strokeWidth,
256
+ dots: []
257
+ };
258
+ });
259
+ const ghostGroup = {
260
+ key: "ghost",
261
+ seriesIndex: -1,
262
+ fill: fills.ghost.fill,
263
+ stroke: fills.ghost.stroke,
264
+ strokeWidth: fills.ghost.strokeWidth,
265
+ dots: []
266
+ };
267
+ const seriesR = series.map(
268
+ (_, i) => Math.max(0, spacing * dotSize / 2 - (fills.series[i]?.inset ?? 0))
269
+ );
270
+ const ghostR = Math.max(
271
+ 0,
272
+ spacing * ghostDotSize / 2 - fills.ghost.inset
273
+ );
274
+ const rampRows = Math.max(1, rows * rampExtent);
275
+ const seriesDot = (slot, ends) => {
276
+ const seriesIndex = ends.findIndex((end) => slot.row < end);
277
+ const s = series[seriesIndex];
278
+ const group = seriesGroups[seriesIndex];
279
+ if (!(s && group)) {
280
+ return null;
281
+ }
282
+ const rampFrom = s.rampFrom ?? 1;
283
+ const ramp = rampFrom + (1 - rampFrom) * Math.min(1, slot.row / rampRows);
284
+ return {
285
+ group,
286
+ r: seriesR[seriesIndex] ?? 0,
287
+ opacity: (s.opacity ?? 1) * ramp
288
+ };
289
+ };
290
+ grid.forEach((slots, bin) => {
291
+ const ends = stackEnds[bin] ?? [];
292
+ const binDelay = bin / Math.max(1, binCount) * ENTER_SPREAD_S;
293
+ for (const slot of slots) {
294
+ let target = null;
295
+ if (futureBins[bin]) {
296
+ target = (ends[0] ?? 0) > slot.row ? { group: ghostGroup, r: ghostR, opacity: ghostOpacity } : null;
297
+ } else {
298
+ target = seriesDot(slot, ends);
299
+ }
300
+ target?.group.dots.push({
301
+ key: `${bin}-${slot.row}-${slot.angle.toFixed(4)}`,
302
+ x: slot.x,
303
+ y: slot.y,
304
+ r: target.r,
305
+ opacity: target.opacity,
306
+ delay: binDelay + slot.row * ENTER_ROW_STEP_S
307
+ });
308
+ }
309
+ });
310
+ return [ghostGroup, ...seriesGroups];
311
+ }, [
312
+ spacing,
313
+ series,
314
+ ghostColor,
315
+ dotSize,
316
+ ghostDotSize,
317
+ rows,
318
+ rampExtent,
319
+ grid,
320
+ stackEnds,
321
+ binCount,
322
+ futureBins,
323
+ ghostOpacity,
324
+ fills
325
+ ]);
326
+ const fontSize = radialLabelFontSize(radius);
327
+ return /* @__PURE__ */ jsxs("g", { children: [
328
+ fills.ghost.defs,
329
+ fills.series.map((f, i) => /* @__PURE__ */ jsx("g", { children: f.defs }, series[i]?.dataKey ?? i)),
330
+ /* @__PURE__ */ jsx(
331
+ DotGroups,
332
+ {
333
+ animate,
334
+ fadedOpacity,
335
+ groups,
336
+ hoveredSeries,
337
+ revealed
338
+ }
339
+ ),
340
+ annotations?.map((annotation) => {
341
+ const ends = stackEnds[annotation.index];
342
+ const annotationColor = annotation.color ?? annotationSeriesColor(series, ends);
343
+ const tipRow = Math.max(0, (ends?.at(-1) ?? 1) - 1);
344
+ const tipRadius = radialDotRowRadius(innerRadius, spacing, tipRow);
345
+ const angle = binAngle(annotation.index);
346
+ const p = polarToCartesian(
347
+ angle,
348
+ Math.max(
349
+ tipRadius + spacing * 2.5,
350
+ radius * ringLayout.axisLabel * 1.02
351
+ )
352
+ );
353
+ const sin = Math.sin(angle);
354
+ let anchor = "middle";
355
+ if (sin > 0.25) {
356
+ anchor = "start";
357
+ } else if (sin < -0.25) {
358
+ anchor = "end";
359
+ }
360
+ return /* @__PURE__ */ jsx(
361
+ "text",
362
+ {
363
+ className: "font-mono",
364
+ dominantBaseline: "central",
365
+ fill: annotationColor,
366
+ fontSize,
367
+ pointerEvents: "none",
368
+ style: {
369
+ opacity: revealed ? 1 : 0,
370
+ transition: animate ? `opacity 0.4s ease-out ${ENTER_SPREAD_S}s` : void 0
371
+ },
372
+ textAnchor: anchor,
373
+ x: p.x,
374
+ y: p.y,
375
+ children: annotation.label
376
+ },
377
+ `annotation-${annotation.index}-${annotation.label}`
378
+ );
379
+ })
380
+ ] });
381
+ }
382
+ RadialDotBar.displayName = "RadialDotBar";
383
+ var radial_dot_bar_default = RadialDotBar;
384
+ export {
385
+ RadialDotBar,
386
+ radial_dot_bar_default as default
387
+ };
@@ -0,0 +1,114 @@
1
+ import { scaleLinear, scaleRadial } from "d3-scale";
2
+ import {
3
+ isFullArc,
4
+ polarToCartesian,
5
+ radialArcPath,
6
+ TAU
7
+ } from "./arc-geometry";
8
+ import {
9
+ isFullArc as isFullArc2,
10
+ polarToCartesian as polarToCartesian2,
11
+ radialArcPath as radialArcPath2,
12
+ TAU as TAU2
13
+ } from "./arc-geometry";
14
+ const defaultRadialLayout = {
15
+ center: 0.37,
16
+ tickInner: 0.38,
17
+ tickMinorOuter: 0.393,
18
+ tickMajorOuter: 0.405,
19
+ bandInner: 0.408,
20
+ bandOuter: 0.83,
21
+ scrubberOuter: 0.895,
22
+ axisLabel: 0.955
23
+ };
24
+ function degreesToRadians(degrees) {
25
+ return degrees * Math.PI / 180;
26
+ }
27
+ function cartesianToAngle(dx, dy) {
28
+ const angle = Math.atan2(dx, -dy);
29
+ return angle < 0 ? angle + TAU : angle;
30
+ }
31
+ function radialBinStartAngle(index, binCount) {
32
+ return index / Math.max(1, binCount) * TAU;
33
+ }
34
+ function radialBinCenterAngle(index, binCount) {
35
+ return (index + 0.5) / Math.max(1, binCount) * TAU;
36
+ }
37
+ function radialAngleToBin(angle, binCount) {
38
+ const normalized = (angle % TAU + TAU) % TAU;
39
+ return Math.min(binCount - 1, Math.floor(normalized / TAU * binCount));
40
+ }
41
+ function radialArcFraction(angle, startAngle, endAngle) {
42
+ const span = endAngle - startAngle;
43
+ if (span === 0) {
44
+ return null;
45
+ }
46
+ const direction = Math.sign(span);
47
+ const offset = ((angle - startAngle) * direction % TAU + TAU) % TAU;
48
+ const length = Math.abs(span);
49
+ if (length >= TAU - 1e-6) {
50
+ return offset / TAU;
51
+ }
52
+ if (offset <= length) {
53
+ return offset / length;
54
+ }
55
+ return null;
56
+ }
57
+ function radialArcBounds(startAngle, endAngle) {
58
+ const lo = Math.min(startAngle, endAngle);
59
+ const hi = Math.max(startAngle, endAngle);
60
+ const points = [
61
+ { x: 0, y: 0 },
62
+ polarToCartesian(lo, 1),
63
+ polarToCartesian(hi, 1)
64
+ ];
65
+ const first = Math.ceil(lo / (Math.PI / 2));
66
+ for (let k = first; k * (Math.PI / 2) <= hi; k++) {
67
+ points.push(polarToCartesian(k * (Math.PI / 2), 1));
68
+ }
69
+ return {
70
+ minX: Math.min(...points.map((p) => p.x)),
71
+ maxX: Math.max(...points.map((p) => p.x)),
72
+ minY: Math.min(...points.map((p) => p.y)),
73
+ maxY: Math.max(...points.map((p) => p.y))
74
+ };
75
+ }
76
+ function radialWedgePath(radius, startAngle, endAngle) {
77
+ if (isFullArc(startAngle, endAngle)) {
78
+ return `${radialArcPath(radius, startAngle, endAngle)}`;
79
+ }
80
+ return `M0,0L${radialArcPath(radius, startAngle, endAngle).slice(1)}Z`;
81
+ }
82
+ function createRadialScale({
83
+ minValue = 0,
84
+ maxValue,
85
+ innerRadius,
86
+ outerRadius
87
+ }) {
88
+ return scaleRadial().domain([minValue, Math.max(maxValue, minValue + Number.EPSILON)]).range([innerRadius, outerRadius]).clamp(true);
89
+ }
90
+ function niceRadialDomain(domain, count = 5) {
91
+ const [min, max] = scaleLinear().domain(domain).nice(count).domain();
92
+ return [min ?? domain[0], max ?? domain[1]];
93
+ }
94
+ function radialValueTicks(domain, count = 5) {
95
+ return scaleLinear().domain(domain).ticks(count);
96
+ }
97
+ export {
98
+ TAU2 as TAU,
99
+ cartesianToAngle,
100
+ createRadialScale,
101
+ defaultRadialLayout,
102
+ degreesToRadians,
103
+ isFullArc2 as isFullArc,
104
+ niceRadialDomain,
105
+ polarToCartesian2 as polarToCartesian,
106
+ radialAngleToBin,
107
+ radialArcBounds,
108
+ radialArcFraction,
109
+ radialArcPath2 as radialArcPath,
110
+ radialBinCenterAngle,
111
+ radialBinStartAngle,
112
+ radialValueTicks,
113
+ radialWedgePath
114
+ };
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { cn } from "../lib/utils";
5
+ import { ChartDataOverrideExempt } from "./chart-data-override";
6
+ import { intFmt } from "./chart-formatters";
7
+ import { Legend } from "./legend/legend";
8
+ import { useLegendItem } from "./legend/legend-context";
9
+ import { LegendItem } from "./legend/legend-item";
10
+ import { LegendLabel } from "./legend/legend-label";
11
+ import { LegendMarker } from "./legend/legend-marker";
12
+ import { useRadialChart } from "./radial-chart";
13
+ import { radialSeriesColor } from "./radial-series-color";
14
+ function RadialLegendValue({
15
+ formatValue
16
+ }) {
17
+ const { series } = useRadialChart();
18
+ const { item, index } = useLegendItem();
19
+ const emphasize = series[index]?.emphasize;
20
+ return /* @__PURE__ */ jsx(
21
+ "span",
22
+ {
23
+ className: "font-semibold text-chart-foreground tabular-nums",
24
+ style: emphasize ? { color: item.color } : void 0,
25
+ children: formatValue(item.value)
26
+ }
27
+ );
28
+ }
29
+ function RadialLegend({
30
+ className,
31
+ formatValue = intFmt,
32
+ showValues = true
33
+ }) {
34
+ const { series, totals, hoveredSeries, setHoveredSeries } = useRadialChart();
35
+ const items = useMemo(
36
+ () => series.map((s, i) => ({
37
+ label: s.label ?? s.dataKey,
38
+ value: totals[s.dataKey] ?? 0,
39
+ color: radialSeriesColor(s, i)
40
+ })),
41
+ [series, totals]
42
+ );
43
+ return /* @__PURE__ */ jsx(ChartDataOverrideExempt, { children: /* @__PURE__ */ jsx(
44
+ Legend,
45
+ {
46
+ className: cn(
47
+ "mt-2 flex-row flex-wrap items-center justify-center gap-x-3 gap-y-1",
48
+ className
49
+ ),
50
+ hoveredIndex: hoveredSeries,
51
+ items,
52
+ onHoverChange: setHoveredSeries,
53
+ children: /* @__PURE__ */ jsxs(LegendItem, { className: "flex items-center gap-2", children: [
54
+ /* @__PURE__ */ jsx(LegendMarker, { className: "size-2" }),
55
+ /* @__PURE__ */ jsx(LegendLabel, { className: "text-chart-foreground-muted text-sm" }),
56
+ showValues ? /* @__PURE__ */ jsx(RadialLegendValue, { formatValue }) : null
57
+ ] })
58
+ }
59
+ ) });
60
+ }
61
+ RadialLegend.displayName = "RadialLegend";
62
+ var radial_legend_default = RadialLegend;
63
+ export {
64
+ RadialLegend,
65
+ radial_legend_default as default
66
+ };