@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,239 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useMemo } from "react";
4
+ import { clipRevealTransition } from "./animation";
5
+ import {
6
+ defaultScatterColors,
7
+ useChartHover,
8
+ useChartHoverSelector,
9
+ useChartStable,
10
+ useYScale
11
+ } from "./chart-context";
12
+ import { useChartLegendHover } from "./chart-legend-hover";
13
+ import {
14
+ getSeriesMarkerVisualExtent,
15
+ SeriesPointMarker,
16
+ StaticSeriesPointMarker
17
+ } from "./series-point-marker";
18
+ function SeriesMarkers({
19
+ dataKey,
20
+ fill,
21
+ stroke,
22
+ strokeWidth = 2,
23
+ ringGap = 2,
24
+ outlineWidth = 0,
25
+ outlineColor,
26
+ radius = 5,
27
+ animate = true,
28
+ fadeOnHover = true,
29
+ inactiveOpacity = 0.5,
30
+ inactiveBlur = 2,
31
+ enterBlur = 2,
32
+ showActiveHighlight = true,
33
+ getPointOffset
34
+ }) {
35
+ const {
36
+ data,
37
+ xScale,
38
+ innerWidth,
39
+ enterTransition,
40
+ animationDuration,
41
+ revealEpoch,
42
+ isLoaded,
43
+ xAccessor,
44
+ lines
45
+ } = useChartStable();
46
+ const seriesIndex = useMemo(() => {
47
+ const index = lines.findIndex((line) => line.dataKey === dataKey);
48
+ return index >= 0 ? index : 0;
49
+ }, [lines, dataKey]);
50
+ const seriesConfig = lines[seriesIndex];
51
+ const yScale = useYScale(seriesConfig?.yAxisId);
52
+ const seriesColor = defaultScatterColors[seriesIndex % defaultScatterColors.length] ?? defaultScatterColors[0];
53
+ const resolvedFill = fill ?? seriesConfig?.stroke ?? seriesColor;
54
+ const resolvedStroke = stroke ?? resolvedFill;
55
+ const visualExtent = useMemo(
56
+ () => getSeriesMarkerVisualExtent({
57
+ radius,
58
+ strokeWidth,
59
+ ringGap,
60
+ outlineWidth,
61
+ showActiveHighlight
62
+ }),
63
+ [radius, strokeWidth, ringGap, outlineWidth, showActiveHighlight]
64
+ );
65
+ const revealDurationSec = clipRevealTransition(enterTransition).duration ?? animationDuration / 1e3;
66
+ const enterDuration = 0.5;
67
+ const isRevealing = animate && !isLoaded;
68
+ const getY = useCallback(
69
+ (d) => {
70
+ const value = d[dataKey];
71
+ return typeof value === "number" ? yScale(value) ?? 0 : null;
72
+ },
73
+ [dataKey, yScale]
74
+ );
75
+ const points = useMemo(
76
+ () => data.flatMap((d, index) => {
77
+ const cy = getY(d);
78
+ if (cy === null) {
79
+ return [];
80
+ }
81
+ const offset = getPointOffset?.(index, seriesIndex);
82
+ const cx = (xScale(xAccessor(d)) ?? 0) + (offset?.x ?? 0);
83
+ const leadingEdge = Math.max(0, cx - visualExtent);
84
+ const revealDelay = innerWidth > 0 && isRevealing ? leadingEdge / innerWidth * revealDurationSec : 0;
85
+ return [{ index, cx, cy: cy + (offset?.y ?? 0), revealDelay }];
86
+ }),
87
+ [
88
+ data,
89
+ getY,
90
+ xScale,
91
+ xAccessor,
92
+ innerWidth,
93
+ isRevealing,
94
+ revealDurationSec,
95
+ visualExtent,
96
+ getPointOffset,
97
+ seriesIndex
98
+ ]
99
+ );
100
+ const markerStyle = useMemo(
101
+ () => ({
102
+ fill: resolvedFill,
103
+ stroke: resolvedStroke,
104
+ strokeWidth,
105
+ ringGap,
106
+ outlineWidth,
107
+ outlineColor,
108
+ radius
109
+ }),
110
+ [
111
+ resolvedFill,
112
+ resolvedStroke,
113
+ strokeWidth,
114
+ ringGap,
115
+ outlineWidth,
116
+ outlineColor,
117
+ radius
118
+ ]
119
+ );
120
+ if (isRevealing) {
121
+ return /* @__PURE__ */ jsx("g", { children: points.map((point) => /* @__PURE__ */ jsx(
122
+ SeriesPointMarker,
123
+ {
124
+ cx: point.cx,
125
+ cy: point.cy,
126
+ dataKey,
127
+ enterBlur,
128
+ enterDuration,
129
+ index: point.index,
130
+ revealDelay: point.revealDelay,
131
+ revealEpoch: revealEpoch ?? 0,
132
+ ...markerStyle
133
+ },
134
+ `${dataKey}-${point.index}`
135
+ )) });
136
+ }
137
+ const plainDots = strokeWidth <= 0 && outlineWidth <= 0;
138
+ const baseMarkers = points.map(
139
+ (point) => plainDots ? /* @__PURE__ */ jsx(
140
+ "circle",
141
+ {
142
+ cx: point.cx,
143
+ cy: point.cy,
144
+ fill: resolvedFill,
145
+ r: radius
146
+ },
147
+ `${dataKey}-${point.index}`
148
+ ) : /* @__PURE__ */ jsx(
149
+ StaticSeriesPointMarker,
150
+ {
151
+ cx: point.cx,
152
+ cy: point.cy,
153
+ ...markerStyle
154
+ },
155
+ `${dataKey}-${point.index}`
156
+ )
157
+ );
158
+ const activeScale = showActiveHighlight ? 1.35 : 1;
159
+ return /* @__PURE__ */ jsxs("g", { children: [
160
+ /* @__PURE__ */ jsx(
161
+ SeriesMarkersDimWrapper,
162
+ {
163
+ enabled: fadeOnHover,
164
+ inactiveBlur,
165
+ inactiveOpacity,
166
+ seriesIndex,
167
+ children: baseMarkers
168
+ }
169
+ ),
170
+ /* @__PURE__ */ jsx(
171
+ SeriesMarkersActiveHighlight,
172
+ {
173
+ activeScale,
174
+ dataKey,
175
+ enabled: fadeOnHover,
176
+ markerStyle,
177
+ points
178
+ }
179
+ )
180
+ ] });
181
+ }
182
+ SeriesMarkers.displayName = "SeriesMarkers";
183
+ const selectIsTooltipShown = (hover) => hover.tooltipData !== null;
184
+ function SeriesMarkersDimWrapper({
185
+ enabled,
186
+ inactiveOpacity,
187
+ inactiveBlur,
188
+ seriesIndex,
189
+ children
190
+ }) {
191
+ const isHovered = useChartHoverSelector(selectIsTooltipShown);
192
+ const { hoveredIndex: legendHoveredIndex } = useChartLegendHover();
193
+ const isLegendDimmed = legendHoveredIndex !== null && legendHoveredIndex !== seriesIndex;
194
+ const dimBase = enabled && (isHovered || isLegendDimmed);
195
+ return /* @__PURE__ */ jsx(
196
+ "g",
197
+ {
198
+ opacity: dimBase ? inactiveOpacity : 1,
199
+ style: {
200
+ transition: "opacity 0.15s ease-in-out, filter 0.15s ease-in-out",
201
+ filter: dimBase && inactiveBlur > 0 ? `blur(${inactiveBlur}px)` : "none"
202
+ },
203
+ children
204
+ }
205
+ );
206
+ }
207
+ function SeriesMarkersActiveHighlight({
208
+ dataKey,
209
+ enabled,
210
+ points,
211
+ markerStyle,
212
+ activeScale
213
+ }) {
214
+ const { tooltipData } = useChartHover();
215
+ if (!enabled || tooltipData === null) {
216
+ return null;
217
+ }
218
+ if (tooltipData.activeDataKey !== void 0 && tooltipData.activeDataKey !== dataKey) {
219
+ return null;
220
+ }
221
+ const activePoint = points.find((point) => point.index === tooltipData.index);
222
+ if (!activePoint) {
223
+ return null;
224
+ }
225
+ return /* @__PURE__ */ jsx(
226
+ StaticSeriesPointMarker,
227
+ {
228
+ cx: activePoint.cx,
229
+ cy: activePoint.cy,
230
+ scale: activeScale,
231
+ ...markerStyle
232
+ }
233
+ );
234
+ }
235
+ var series_markers_default = SeriesMarkers;
236
+ export {
237
+ SeriesMarkers,
238
+ series_markers_default as default
239
+ };
@@ -0,0 +1,185 @@
1
+ import { line as d3Line } from "d3-shape";
2
+ import { fastShapePath } from "./fast-path";
3
+ function computeSeriesPathPoints(data, xAccessor, xScale, yScale, dataKey) {
4
+ return data.map((datum, index) => {
5
+ const xValue = xAccessor(datum);
6
+ const yValue = datum[dataKey];
7
+ return {
8
+ x: xScale(xValue) ?? 0,
9
+ y: typeof yValue === "number" ? yScale(yValue) ?? 0 : 0,
10
+ key: String(xValue.getTime?.() ?? index)
11
+ };
12
+ });
13
+ }
14
+ function interpolateSeriesPathPoints(from, to, progress) {
15
+ if (progress >= 1) {
16
+ return to;
17
+ }
18
+ if (progress <= 0) {
19
+ return from.length > 0 ? from : to;
20
+ }
21
+ const fromByKey = new Map(from.map((point) => [point.key, point]));
22
+ return to.map((target, index) => {
23
+ const source = fromByKey.get(target.key);
24
+ if (source) {
25
+ return {
26
+ key: target.key,
27
+ x: source.x + (target.x - source.x) * progress,
28
+ y: source.y + (target.y - source.y) * progress
29
+ };
30
+ }
31
+ const previousTarget = index > 0 ? to[index - 1] : void 0;
32
+ const previousSource = previousTarget ? fromByKey.get(previousTarget.key) : void 0;
33
+ const nextTarget = index < to.length - 1 ? to[index + 1] : void 0;
34
+ const nextSource = nextTarget ? fromByKey.get(nextTarget.key) : void 0;
35
+ const anchor = previousSource ?? nextSource ?? from[0] ?? target;
36
+ return {
37
+ key: target.key,
38
+ x: anchor.x + (target.x - anchor.x) * progress,
39
+ y: anchor.y + (target.y - anchor.y) * progress
40
+ };
41
+ });
42
+ }
43
+ function seriesPathFromPoints(points, curve) {
44
+ if (points.length === 0) {
45
+ return "";
46
+ }
47
+ const generator = d3Line().x((point) => point.x).y((point) => point.y).curve(curve);
48
+ return fastShapePath(generator, points);
49
+ }
50
+ const CURVE_SEGMENT_STEPS = 12;
51
+ class PolylineRecorder {
52
+ points = [];
53
+ x = 0;
54
+ y = 0;
55
+ push(x, y) {
56
+ this.points.push({ x, y, key: "" });
57
+ this.x = x;
58
+ this.y = y;
59
+ }
60
+ moveTo(x, y) {
61
+ this.push(x, y);
62
+ }
63
+ lineTo(x, y) {
64
+ this.push(x, y);
65
+ }
66
+ bezierCurveTo(x1, y1, x2, y2, x, y) {
67
+ const x0 = this.x;
68
+ const y0 = this.y;
69
+ for (let step = 1; step <= CURVE_SEGMENT_STEPS; step++) {
70
+ const t = step / CURVE_SEGMENT_STEPS;
71
+ const u = 1 - t;
72
+ const a = u * u * u;
73
+ const b = 3 * u * u * t;
74
+ const c = 3 * u * t * t;
75
+ const d = t * t * t;
76
+ this.push(
77
+ a * x0 + b * x1 + c * x2 + d * x,
78
+ a * y0 + b * y1 + c * y2 + d * y
79
+ );
80
+ }
81
+ }
82
+ quadraticCurveTo(x1, y1, x, y) {
83
+ const x0 = this.x;
84
+ const y0 = this.y;
85
+ for (let step = 1; step <= CURVE_SEGMENT_STEPS; step++) {
86
+ const t = step / CURVE_SEGMENT_STEPS;
87
+ const u = 1 - t;
88
+ this.push(
89
+ u * u * x0 + 2 * u * t * x1 + t * t * x,
90
+ u * u * y0 + 2 * u * t * y1 + t * t * y
91
+ );
92
+ }
93
+ }
94
+ closePath() {
95
+ }
96
+ }
97
+ function flattenSeriesPath(points, curve) {
98
+ if (points.length < 2) {
99
+ return points;
100
+ }
101
+ const recorder = new PolylineRecorder();
102
+ d3Line().x((point) => point.x).y((point) => point.y).curve(curve).context(recorder)(points);
103
+ return recorder.points.sort((a, b) => a.x - b.x);
104
+ }
105
+ function samplePolylineY(polyline, x) {
106
+ const first = polyline[0];
107
+ const last = polyline.at(-1);
108
+ if (!(first && last)) {
109
+ return 0;
110
+ }
111
+ if (x <= first.x) {
112
+ return first.y;
113
+ }
114
+ if (x >= last.x) {
115
+ return last.y;
116
+ }
117
+ let low = 0;
118
+ let high = polyline.length - 1;
119
+ while (high - low > 1) {
120
+ const mid = Math.floor((low + high) / 2);
121
+ if ((polyline[mid]?.x ?? 0) <= x) {
122
+ low = mid;
123
+ } else {
124
+ high = mid;
125
+ }
126
+ }
127
+ const a = polyline[low] ?? first;
128
+ const b = polyline[high] ?? last;
129
+ const span = b.x - a.x;
130
+ return span > 0 ? a.y + (b.y - a.y) * (x - a.x) / span : a.y;
131
+ }
132
+ function morphSeriesPolylines(from, to, progress, sampleSpacingPx = 2) {
133
+ const first = to[0];
134
+ const last = to.at(-1);
135
+ if (!(first && last) || from.length === 0) {
136
+ return to;
137
+ }
138
+ const span = last.x - first.x;
139
+ const count = Math.max(2, Math.ceil(span / sampleSpacingPx) + 1);
140
+ const result = new Array(count);
141
+ for (let index = 0; index < count; index++) {
142
+ const x = first.x + span * index / (count - 1);
143
+ const fromY = samplePolylineY(from, x);
144
+ const toY = samplePolylineY(to, x);
145
+ result[index] = { x, y: fromY + (toY - fromY) * progress, key: "" };
146
+ }
147
+ return result;
148
+ }
149
+ function seriesDataSignature(renderData, xAccessor, dataKey) {
150
+ return renderData.map((datum) => {
151
+ const yValue = datum[dataKey];
152
+ return `${xAccessor(datum).getTime()}:${typeof yValue === "number" ? yValue : ""}`;
153
+ }).join(",");
154
+ }
155
+ function seriesPathTransitionSignature({
156
+ renderData,
157
+ xAccessor,
158
+ dataKey,
159
+ innerWidth,
160
+ xDomainMin,
161
+ xDomainMax
162
+ }) {
163
+ return seriesPathTransitionSignatureFromData(
164
+ seriesDataSignature(renderData, xAccessor, dataKey),
165
+ { innerWidth, xDomainMin, xDomainMax }
166
+ );
167
+ }
168
+ function seriesPathTransitionSignatureFromData(dataSignature, {
169
+ innerWidth,
170
+ xDomainMin,
171
+ xDomainMax
172
+ }) {
173
+ return `${innerWidth}|${xDomainMin}|${xDomainMax}|${dataSignature}`;
174
+ }
175
+ export {
176
+ computeSeriesPathPoints,
177
+ flattenSeriesPath,
178
+ interpolateSeriesPathPoints,
179
+ morphSeriesPolylines,
180
+ samplePolylineY,
181
+ seriesDataSignature,
182
+ seriesPathFromPoints,
183
+ seriesPathTransitionSignature,
184
+ seriesPathTransitionSignatureFromData
185
+ };
@@ -0,0 +1,150 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { MotionGlobalConfig } from "motion/react";
4
+ import { memo, useLayoutEffect, useRef } from "react";
5
+ import { DEFAULT_ANIMATION_EASING } from "./animation";
6
+ function MarkerCircles({
7
+ fill,
8
+ stroke,
9
+ strokeWidth,
10
+ ringGap,
11
+ outlineWidth,
12
+ outlineColor,
13
+ radius
14
+ }) {
15
+ const resolvedStroke = stroke ?? fill ?? "currentColor";
16
+ const resolvedOutlineColor = outlineColor ?? resolvedStroke;
17
+ const ringOuter = strokeWidth > 0 ? radius + ringGap + strokeWidth : radius;
18
+ const outlineRadius = outlineWidth > 0 ? ringOuter + outlineWidth / 2 : 0;
19
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
20
+ outlineWidth > 0 ? /* @__PURE__ */ jsx(
21
+ "circle",
22
+ {
23
+ cx: 0,
24
+ cy: 0,
25
+ fill: "none",
26
+ r: outlineRadius,
27
+ stroke: resolvedOutlineColor,
28
+ strokeWidth: outlineWidth
29
+ }
30
+ ) : null,
31
+ /* @__PURE__ */ jsx("circle", { cx: 0, cy: 0, fill, r: radius }),
32
+ strokeWidth > 0 ? /* @__PURE__ */ jsx(
33
+ "circle",
34
+ {
35
+ cx: 0,
36
+ cy: 0,
37
+ fill: "none",
38
+ r: radius + ringGap + strokeWidth / 2,
39
+ stroke: resolvedStroke,
40
+ strokeWidth
41
+ }
42
+ ) : null
43
+ ] });
44
+ }
45
+ const StaticSeriesPointMarker = memo(function StaticSeriesPointMarker2({
46
+ cx,
47
+ cy,
48
+ scale = 1,
49
+ fill,
50
+ stroke,
51
+ strokeWidth = 2,
52
+ ringGap = 2,
53
+ outlineWidth = 0,
54
+ outlineColor,
55
+ radius = 5
56
+ }) {
57
+ if (strokeWidth <= 0 && outlineWidth <= 0) {
58
+ return /* @__PURE__ */ jsx("circle", { cx, cy, fill, r: radius * scale });
59
+ }
60
+ return /* @__PURE__ */ jsx("g", { transform: `translate(${cx}, ${cy}) scale(${scale})`, children: /* @__PURE__ */ jsx(
61
+ MarkerCircles,
62
+ {
63
+ fill,
64
+ outlineColor,
65
+ outlineWidth,
66
+ radius,
67
+ ringGap,
68
+ stroke,
69
+ strokeWidth
70
+ }
71
+ ) });
72
+ });
73
+ const MARKER_ENTERED_STYLE = { opacity: 1, filter: "blur(0px)" };
74
+ function SeriesPointMarker({
75
+ dataKey,
76
+ index,
77
+ cx,
78
+ cy,
79
+ enterBlur = 2,
80
+ revealDelay,
81
+ revealEpoch,
82
+ enterDuration,
83
+ fill,
84
+ stroke,
85
+ strokeWidth = 2,
86
+ ringGap = 2,
87
+ outlineWidth = 0,
88
+ outlineColor,
89
+ radius = 5
90
+ }) {
91
+ const enterRef = useRef(null);
92
+ const timingRef = useRef({ enterBlur, revealDelay, enterDuration });
93
+ timingRef.current = { enterBlur, revealDelay, enterDuration };
94
+ useLayoutEffect(() => {
95
+ const element = enterRef.current;
96
+ if (!element || typeof element.animate !== "function" || MotionGlobalConfig.skipAnimations || MotionGlobalConfig.instantAnimations) {
97
+ return;
98
+ }
99
+ const timing = timingRef.current;
100
+ const animation = element.animate(
101
+ [
102
+ { opacity: 0, filter: `blur(${timing.enterBlur}px)` },
103
+ MARKER_ENTERED_STYLE
104
+ ],
105
+ {
106
+ delay: timing.revealDelay * 1e3,
107
+ duration: timing.enterDuration * 1e3,
108
+ easing: DEFAULT_ANIMATION_EASING,
109
+ fill: "backwards"
110
+ }
111
+ );
112
+ return () => animation.cancel();
113
+ }, [revealEpoch]);
114
+ return /* @__PURE__ */ jsx("g", { transform: `translate(${cx}, ${cy})`, children: /* @__PURE__ */ jsx(
115
+ "g",
116
+ {
117
+ ref: enterRef,
118
+ style: MARKER_ENTERED_STYLE,
119
+ children: /* @__PURE__ */ jsx(
120
+ MarkerCircles,
121
+ {
122
+ fill,
123
+ outlineColor,
124
+ outlineWidth,
125
+ radius,
126
+ ringGap,
127
+ stroke,
128
+ strokeWidth
129
+ }
130
+ )
131
+ },
132
+ `${dataKey}-${index}-${revealEpoch}`
133
+ ) });
134
+ }
135
+ function getSeriesMarkerVisualExtent(style) {
136
+ const radius = style.radius ?? 5;
137
+ const strokeWidth = style.strokeWidth ?? 2;
138
+ const ringGap = style.ringGap ?? 2;
139
+ const outlineWidth = style.outlineWidth ?? 0;
140
+ const showActiveHighlight = style.showActiveHighlight ?? true;
141
+ const ring = strokeWidth > 0 ? ringGap + strokeWidth : 0;
142
+ const outline = outlineWidth > 0 ? outlineWidth : 0;
143
+ const highlightPad = showActiveHighlight ? radius * 0.35 : 0;
144
+ return radius + ring + outline + highlightPad + 2;
145
+ }
146
+ export {
147
+ SeriesPointMarker,
148
+ StaticSeriesPointMarker,
149
+ getSeriesMarkerVisualExtent
150
+ };