@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,688 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { bisector, extent } from "d3-array";
4
+ import { scaleLinear, scaleTime } from "d3-scale";
5
+ import {
6
+ Children,
7
+ cloneElement,
8
+ isValidElement,
9
+ memo,
10
+ useCallback,
11
+ useEffect,
12
+ useId,
13
+ useMemo,
14
+ useState
15
+ } from "react";
16
+ import {
17
+ DEFAULT_ANIMATION_EASING,
18
+ DEFAULT_CHART_ENTER_TRANSITION
19
+ } from "./animation";
20
+ import {
21
+ bandKeysByAxis,
22
+ extractBandConfigs
23
+ } from "./band-config";
24
+ import {
25
+ isClipExcludedComponent,
26
+ isPostOverlayComponent,
27
+ isUnderlayComponent,
28
+ isUnresolvedLazyChartChild,
29
+ renderableChartChild,
30
+ resolveChartChildElement
31
+ } from "./chart-child-passthrough";
32
+ import {
33
+ ChartHoverStoreProvider,
34
+ ChartStableContextProvider
35
+ } from "./chart-context";
36
+ import { isGradientDefComponent, isPatternDefComponent } from "./chart-defs";
37
+ import { lazyLabels, shortDateFmt } from "./chart-formatters";
38
+ import {
39
+ DEFAULT_CHART_STATUS,
40
+ DEFAULT_Y_DOMAIN_TWEEN_MS,
41
+ isChartInteractionPhase
42
+ } from "./chart-phase";
43
+ import { ChartRevealClip } from "./chart-reveal-clip";
44
+ import {
45
+ decimateTimeSeries,
46
+ maxRenderPointsForWidth
47
+ } from "./decimate-time-series";
48
+ import { filterDataByXDomain } from "./filter-data-by-x-domain";
49
+ import {
50
+ generateChartSkeletonData,
51
+ generateChartSkeletonFromTarget
52
+ } from "./generate-chart-skeleton-data";
53
+ import {
54
+ extractProjectionLineConfigs,
55
+ mergeProjectionXDomainMax,
56
+ mergeProjectionYDomain
57
+ } from "./projection-config";
58
+ import {
59
+ extractReferenceAreaConfigs
60
+ } from "./reference-area-config";
61
+ import { ReferenceAreaRegistrationContext } from "./reference-area-registration-context";
62
+ import {
63
+ computeSeriesBarRevealClipPadding,
64
+ computeSeriesBarWidth
65
+ } from "./series-bar-layout";
66
+ import { useStaticChartPreview } from "./static-chart-preview-context";
67
+ import { useAnimatedYDomains } from "./use-animated-y-domains";
68
+ import { useChartInteraction } from "./use-chart-interaction";
69
+ import { useInteracaoAic } from "../aic/interacao";
70
+ import { useChartPhaseOrchestrator } from "./use-chart-phase-orchestrator";
71
+ import {
72
+ buildYScalesFromDomains,
73
+ DEFAULT_Y_AXIS_ID,
74
+ getPrimaryYScale,
75
+ groupLinesByYAxisId
76
+ } from "./y-axis-scales";
77
+ import {
78
+ applyYDomainOverride,
79
+ collectBarValueExtents,
80
+ collectNumericExtents,
81
+ computeYDomainsByAxis,
82
+ resolveFloatingYDomain,
83
+ resolveTimeSeriesYDomain
84
+ } from "./y-domain-utils";
85
+ function resolveStackedComposedYDomain(data, barKeys, otherKeys) {
86
+ const bars = collectBarValueExtents(data, barKeys, true);
87
+ const others = otherKeys.length > 0 ? collectNumericExtents(data, otherKeys) : bars;
88
+ const minValue = Math.min(bars.minValue, others.minValue);
89
+ const maxValue = Math.max(bars.maxValue, others.maxValue);
90
+ if (minValue >= 0) {
91
+ return [0, maxValue <= 0 ? 100 : maxValue * 1.1];
92
+ }
93
+ const padding = (maxValue - minValue) * 0.05 || 1;
94
+ return [minValue - padding, maxValue + padding];
95
+ }
96
+ const SERIES_CLIP_EDGE_BLEED = 24;
97
+ function ensureChildKey(child, index) {
98
+ if (child.key != null) {
99
+ return child;
100
+ }
101
+ return cloneElement(child, { key: `chart-child-${index}` });
102
+ }
103
+ function OptionalDefs({ children }) {
104
+ return Children.toArray(children).length > 0 ? /* @__PURE__ */ jsx("defs", { children }) : null;
105
+ }
106
+ function classifyChartChildren(children) {
107
+ const layers = {
108
+ defsChildren: [],
109
+ clipExcludedChildren: [],
110
+ underlayChildren: [],
111
+ preOverlayChildren: [],
112
+ postOverlayChildren: [],
113
+ hasPendingLazyChild: false
114
+ };
115
+ Children.forEach(children, (child, index) => {
116
+ if (!isValidElement(child)) {
117
+ return;
118
+ }
119
+ const keyedChild = ensureChildKey(child, index);
120
+ const resolvedChild = resolveChartChildElement(keyedChild);
121
+ const renderChild = renderableChartChild(keyedChild);
122
+ if (isUnresolvedLazyChartChild(resolvedChild)) {
123
+ layers.hasPendingLazyChild = true;
124
+ }
125
+ if (isGradientDefComponent(resolvedChild)) {
126
+ layers.defsChildren.push(renderChild);
127
+ } else if (isPatternDefComponent(resolvedChild)) {
128
+ layers.preOverlayChildren.push(renderChild);
129
+ } else if (isPostOverlayComponent(resolvedChild)) {
130
+ layers.postOverlayChildren.push(renderChild);
131
+ } else if (isClipExcludedComponent(resolvedChild)) {
132
+ layers.clipExcludedChildren.push(renderChild);
133
+ } else if (isUnderlayComponent(resolvedChild)) {
134
+ layers.underlayChildren.push(renderChild);
135
+ } else {
136
+ layers.preOverlayChildren.push(renderChild);
137
+ }
138
+ });
139
+ return layers;
140
+ }
141
+ function timeSeriesChartHasRoom(width, height) {
142
+ return width >= 10 && height >= 10;
143
+ }
144
+ function resolveSlotCount(xDomain, xDomainSlotCount, visibleCount) {
145
+ return xDomain && xDomainSlotCount != null ? xDomainSlotCount : visibleCount;
146
+ }
147
+ function resolveXEdgeInset(enabled, innerWidth, slotCount) {
148
+ return enabled && slotCount >= 2 ? innerWidth / (2 * slotCount) : 0;
149
+ }
150
+ const TimeSeriesChartInner = memo(function TimeSeriesChartCore({
151
+ width,
152
+ height,
153
+ data,
154
+ xDataKey,
155
+ margin,
156
+ animationDuration,
157
+ animationEasing = DEFAULT_ANIMATION_EASING,
158
+ enterTransition,
159
+ revealSignature = "",
160
+ children,
161
+ containerRef,
162
+ lines,
163
+ clipPathId,
164
+ composedBarDataKeys,
165
+ composedBarSize,
166
+ composedMaxBarSize,
167
+ composedBarGap,
168
+ composedStacked,
169
+ composedStackOffsets,
170
+ composedStackGap,
171
+ composedBarEdgeInset = false,
172
+ yScaleDomainMax,
173
+ extraDomainKeysByAxis,
174
+ floatingYAxisIds,
175
+ yDomainOverrides,
176
+ chartStatus = DEFAULT_CHART_STATUS,
177
+ loadingLabel,
178
+ yDomainTween = true,
179
+ yDomainTweenDuration = DEFAULT_Y_DOMAIN_TWEEN_MS,
180
+ xDomain,
181
+ xDomainSlotCount,
182
+ tweenYDomainOnXDomainChange = false,
183
+ onPhaseChange
184
+ }) {
185
+ const uniqueClipPathId = `${clipPathId}-${useId().replace(/:/g, "")}`;
186
+ const staticPreview = useStaticChartPreview();
187
+ const innerWidth = width - margin.left - margin.right;
188
+ const innerHeight = height - margin.top - margin.bottom;
189
+ const resolveAutoYDomain = useCallback(
190
+ (sourceData, dataKeys, axisId) => {
191
+ if (floatingYAxisIds?.includes(axisId)) {
192
+ return resolveFloatingYDomain(sourceData, dataKeys);
193
+ }
194
+ const axisGroups = groupLinesByYAxisId(lines);
195
+ const usesDefaultOnly = axisGroups.size === 1 && axisGroups.has(DEFAULT_Y_AXIS_ID);
196
+ if (usesDefaultOnly && yScaleDomainMax != null) {
197
+ return resolveTimeSeriesYDomain(sourceData, dataKeys, yScaleDomainMax);
198
+ }
199
+ if (composedStacked && composedBarDataKeys?.length) {
200
+ const barKeys = dataKeys.filter(
201
+ (key) => composedBarDataKeys.includes(key)
202
+ );
203
+ if (barKeys.length > 0) {
204
+ return resolveStackedComposedYDomain(
205
+ sourceData,
206
+ barKeys,
207
+ dataKeys.filter((key) => !barKeys.includes(key))
208
+ );
209
+ }
210
+ }
211
+ return resolveTimeSeriesYDomain(sourceData, dataKeys, void 0);
212
+ },
213
+ [
214
+ composedBarDataKeys,
215
+ composedStacked,
216
+ floatingYAxisIds,
217
+ lines,
218
+ yScaleDomainMax
219
+ ]
220
+ );
221
+ const resolveYDomain = useCallback(
222
+ (sourceData, dataKeys, axisId) => applyYDomainOverride(
223
+ resolveAutoYDomain(sourceData, dataKeys, axisId),
224
+ yDomainOverrides?.[axisId]
225
+ ),
226
+ [resolveAutoYDomain, yDomainOverrides]
227
+ );
228
+ const skeletonData = useMemo(() => {
229
+ const primaryKey = lines[0]?.dataKey ?? "value";
230
+ if (data.length === 0) {
231
+ return generateChartSkeletonData({ dataKey: primaryKey });
232
+ }
233
+ return generateChartSkeletonFromTarget(data, primaryKey);
234
+ }, [data, lines]);
235
+ const {
236
+ chartPhase,
237
+ plotData,
238
+ revealEpoch,
239
+ concealEpoch,
240
+ isLoaded,
241
+ notifyLoadingPulseComplete,
242
+ notifyRevealConcealComplete,
243
+ notifyYDomainTweenComplete
244
+ } = useChartPhaseOrchestrator({
245
+ animationDuration,
246
+ chartStatus,
247
+ revealSignature,
248
+ skeletonData,
249
+ skipEnterReveal: staticPreview,
250
+ targetData: data,
251
+ yDomainTweenDuration
252
+ });
253
+ useEffect(() => {
254
+ onPhaseChange?.(chartPhase);
255
+ }, [chartPhase, onPhaseChange]);
256
+ const xAccessor = useCallback(
257
+ (d) => {
258
+ const value = d[xDataKey];
259
+ return value instanceof Date ? value : new Date(value);
260
+ },
261
+ [xDataKey]
262
+ );
263
+ const bisectDate = useMemo(
264
+ () => bisector((d) => xAccessor(d)).left,
265
+ [xAccessor]
266
+ );
267
+ const visiblePlotData = useMemo(() => {
268
+ if (!xDomain) {
269
+ return plotData;
270
+ }
271
+ return filterDataByXDomain(plotData, xDomain, xAccessor);
272
+ }, [plotData, xDomain, xAccessor]);
273
+ const projectionConfigs = useMemo(
274
+ () => extractProjectionLineConfigs(children),
275
+ [children]
276
+ );
277
+ const bandConfigsSignature = useMemo(
278
+ () => JSON.stringify(extractBandConfigs(children)),
279
+ [children]
280
+ );
281
+ const bandConfigs = useMemo(
282
+ () => JSON.parse(bandConfigsSignature),
283
+ [bandConfigsSignature]
284
+ );
285
+ const bandKeysByAxisId = useMemo(() => {
286
+ const byAxis = bandKeysByAxis(bandConfigs);
287
+ if (!extraDomainKeysByAxis) {
288
+ return byAxis;
289
+ }
290
+ const merged = { ...byAxis };
291
+ for (const [axisId, keys] of Object.entries(extraDomainKeysByAxis)) {
292
+ const existing = merged[axisId] ?? [];
293
+ merged[axisId] = [
294
+ ...existing,
295
+ ...keys.filter((key) => !existing.includes(key))
296
+ ];
297
+ }
298
+ return merged;
299
+ }, [bandConfigs, extraDomainKeysByAxis]);
300
+ const slotCount = resolveSlotCount(
301
+ xDomain,
302
+ xDomainSlotCount,
303
+ visiblePlotData.length
304
+ );
305
+ const xEdgeInset = resolveXEdgeInset(
306
+ composedBarEdgeInset && (composedBarDataKeys?.length ?? 0) > 0,
307
+ innerWidth,
308
+ slotCount
309
+ );
310
+ const xScale = useMemo(() => {
311
+ const minTime = xDomain ? xDomain[0].getTime() : extent(plotData, (d) => xAccessor(d).getTime())[0] ?? 0;
312
+ let maxTime = xDomain ? xDomain[1].getTime() : extent(plotData, (d) => xAccessor(d).getTime())[1] ?? minTime;
313
+ if (!xDomain) {
314
+ maxTime = mergeProjectionXDomainMax(maxTime, projectionConfigs);
315
+ }
316
+ return scaleTime().domain([minTime, maxTime]).range([xEdgeInset, innerWidth - xEdgeInset]);
317
+ }, [innerWidth, plotData, projectionConfigs, xAccessor, xDomain, xEdgeInset]);
318
+ const seriesSourceData = xDomain ? plotData : visiblePlotData;
319
+ const renderData = useMemo(() => {
320
+ const valueKeys = lines.map((line) => line.dataKey);
321
+ for (const keys of Object.values(bandKeysByAxisId)) {
322
+ for (const key of keys) {
323
+ if (!valueKeys.includes(key)) {
324
+ valueKeys.push(key);
325
+ }
326
+ }
327
+ }
328
+ return decimateTimeSeries(
329
+ seriesSourceData,
330
+ maxRenderPointsForWidth(innerWidth),
331
+ valueKeys
332
+ );
333
+ }, [seriesSourceData, innerWidth, lines, bandKeysByAxisId]);
334
+ const columnWidth = useMemo(() => {
335
+ if (slotCount < 2) {
336
+ return 0;
337
+ }
338
+ return (innerWidth - 2 * xEdgeInset) / (slotCount - 1);
339
+ }, [innerWidth, slotCount, xEdgeInset]);
340
+ const yDomainSkeletonByAxis = useMemo(
341
+ () => computeYDomainsByAxis({
342
+ lines,
343
+ resolveDomain: (dataKeys, axisId) => resolveYDomain(skeletonData, dataKeys, axisId)
344
+ }),
345
+ [lines, resolveYDomain, skeletonData]
346
+ );
347
+ const yDomainTargetByAxis = useMemo(() => {
348
+ const base = computeYDomainsByAxis({
349
+ extraKeysByAxis: bandKeysByAxisId,
350
+ lines,
351
+ resolveDomain: (dataKeys, axisId) => resolveYDomain(xDomain ? visiblePlotData : data, dataKeys, axisId)
352
+ });
353
+ if (projectionConfigs.length === 0) {
354
+ return base;
355
+ }
356
+ const merged = { ...base };
357
+ for (const axisId of Object.keys(base)) {
358
+ merged[axisId] = mergeProjectionYDomain(
359
+ base[axisId] ?? [0, 100],
360
+ projectionConfigs,
361
+ axisId
362
+ );
363
+ }
364
+ for (const config of projectionConfigs) {
365
+ if (!merged[config.yAxisId]) {
366
+ merged[config.yAxisId] = mergeProjectionYDomain(
367
+ [0, 100],
368
+ projectionConfigs,
369
+ config.yAxisId
370
+ );
371
+ }
372
+ }
373
+ return merged;
374
+ }, [
375
+ bandKeysByAxisId,
376
+ data,
377
+ lines,
378
+ projectionConfigs,
379
+ resolveYDomain,
380
+ visiblePlotData,
381
+ xDomain
382
+ ]);
383
+ const animatedYDomainsByAxis = useAnimatedYDomains({
384
+ chartPhase,
385
+ durationMs: yDomainTweenDuration,
386
+ enabled: yDomainTween,
387
+ onSettled: notifyYDomainTweenComplete,
388
+ skeletonByAxis: yDomainSkeletonByAxis,
389
+ targetByAxis: yDomainTargetByAxis,
390
+ tweenOnTargetChange: yDomainTween || tweenYDomainOnXDomainChange && xDomain != null
391
+ });
392
+ const yDomainsForScales = animatedYDomainsByAxis;
393
+ const yScales = useMemo(
394
+ () => buildYScalesFromDomains({
395
+ domainsByAxis: yDomainsForScales,
396
+ innerHeight,
397
+ lines
398
+ }),
399
+ [yDomainsForScales, innerHeight, lines]
400
+ );
401
+ const fallbackYScale = useMemo(
402
+ () => scaleLinear().domain([0, 100]).nice().range([innerHeight, 0]),
403
+ [innerHeight]
404
+ );
405
+ const yScale = getPrimaryYScale(yScales, fallbackYScale);
406
+ const dateLabels = useMemo(
407
+ () => lazyLabels(
408
+ visiblePlotData.length,
409
+ (index) => shortDateFmt.format(
410
+ xAccessor(visiblePlotData[index])
411
+ )
412
+ ),
413
+ [visiblePlotData, xAccessor]
414
+ );
415
+ const canInteract = isLoaded && isChartInteractionPhase(chartPhase);
416
+ const aic = useInteracaoAic();
417
+ const { hoverStore, interactionHandlers, interactionStyle } = useChartInteraction({
418
+ bisectDate,
419
+ canInteract,
420
+ bands: bandConfigs,
421
+ data: visiblePlotData,
422
+ lines,
423
+ margin,
424
+ xAccessor,
425
+ xScale,
426
+ yScale,
427
+ yScales
428
+ });
429
+ const memoizedLayers = useMemo(
430
+ () => classifyChartChildren(children),
431
+ [children]
432
+ );
433
+ const {
434
+ defsChildren,
435
+ clipExcludedChildren,
436
+ underlayChildren,
437
+ preOverlayChildren,
438
+ postOverlayChildren
439
+ } = memoizedLayers.hasPendingLazyChild ? classifyChartChildren(children) : memoizedLayers;
440
+ const [registeredReferenceAreas, setRegisteredReferenceAreas] = useState(
441
+ () => /* @__PURE__ */ new Map()
442
+ );
443
+ const registerReferenceArea = useCallback(
444
+ (id, config) => {
445
+ setRegisteredReferenceAreas((prev) => {
446
+ const existing = prev.get(id);
447
+ if (existing && existing.yAxisId === config.yAxisId && existing.y1 === config.y1 && existing.y2 === config.y2 && existing.axisLabelColor === config.axisLabelColor) {
448
+ return prev;
449
+ }
450
+ const next = new Map(prev);
451
+ next.set(id, config);
452
+ return next;
453
+ });
454
+ },
455
+ []
456
+ );
457
+ const unregisterReferenceArea = useCallback((id) => {
458
+ setRegisteredReferenceAreas((prev) => {
459
+ if (!prev.has(id)) {
460
+ return prev;
461
+ }
462
+ const next = new Map(prev);
463
+ next.delete(id);
464
+ return next;
465
+ });
466
+ }, []);
467
+ const referenceAreaRegistration = useMemo(
468
+ () => ({ registerReferenceArea, unregisterReferenceArea }),
469
+ [registerReferenceArea, unregisterReferenceArea]
470
+ );
471
+ const referenceAreas = useMemo(() => {
472
+ const extracted = extractReferenceAreaConfigs(children);
473
+ const registered = [...registeredReferenceAreas.values()];
474
+ if (registered.length === 0) {
475
+ return extracted;
476
+ }
477
+ if (extracted.length === 0) {
478
+ return registered;
479
+ }
480
+ return [...extracted, ...registered];
481
+ }, [children, registeredReferenceAreas]);
482
+ const contextValue = useMemo(
483
+ () => ({
484
+ data: visiblePlotData,
485
+ renderData,
486
+ xScale,
487
+ yScale,
488
+ yScales,
489
+ width,
490
+ height,
491
+ innerWidth,
492
+ innerHeight,
493
+ margin,
494
+ columnWidth,
495
+ containerRef,
496
+ lines,
497
+ bands: bandConfigs,
498
+ referenceAreas,
499
+ chartPhase,
500
+ chartStatus,
501
+ loadingLabel,
502
+ yDomainTweenDuration,
503
+ yDomainSkeletonByAxis,
504
+ yDomainTargetByAxis,
505
+ isLoaded,
506
+ animationDuration,
507
+ animationEasing,
508
+ enterTransition,
509
+ revealEpoch,
510
+ notifyLoadingPulseComplete,
511
+ xAccessor,
512
+ dateLabels,
513
+ xDomain,
514
+ xDomainSlotCount,
515
+ composedBarDataKeys,
516
+ composedBarSize,
517
+ composedMaxBarSize,
518
+ composedBarGap,
519
+ composedStacked,
520
+ composedStackOffsets,
521
+ composedStackGap
522
+ }),
523
+ [
524
+ visiblePlotData,
525
+ renderData,
526
+ xScale,
527
+ yScale,
528
+ yScales,
529
+ width,
530
+ height,
531
+ innerWidth,
532
+ innerHeight,
533
+ margin,
534
+ columnWidth,
535
+ containerRef,
536
+ lines,
537
+ bandConfigs,
538
+ referenceAreas,
539
+ chartPhase,
540
+ chartStatus,
541
+ loadingLabel,
542
+ yDomainTweenDuration,
543
+ yDomainSkeletonByAxis,
544
+ yDomainTargetByAxis,
545
+ isLoaded,
546
+ animationDuration,
547
+ animationEasing,
548
+ enterTransition,
549
+ revealEpoch,
550
+ notifyLoadingPulseComplete,
551
+ xAccessor,
552
+ dateLabels,
553
+ xDomain,
554
+ xDomainSlotCount,
555
+ composedBarDataKeys,
556
+ composedBarSize,
557
+ composedMaxBarSize,
558
+ composedBarGap,
559
+ composedStacked,
560
+ composedStackOffsets,
561
+ composedStackGap
562
+ ]
563
+ );
564
+ const useClipReveal = !staticPreview && renderData.length > 1 && innerWidth > 0 && animationDuration > 0;
565
+ const isRevealAnimating = chartPhase === "revealing";
566
+ const isRevealConcealing = chartPhase === "exitingReady" && animationDuration > 0;
567
+ const effectiveEnterTransition = useMemo(
568
+ () => enterTransition ?? {
569
+ ...DEFAULT_CHART_ENTER_TRANSITION,
570
+ duration: animationDuration / 1e3
571
+ },
572
+ [animationDuration, enterTransition]
573
+ );
574
+ const barRevealClipPadding = useMemo(() => {
575
+ if (!composedBarDataKeys?.length) {
576
+ return 0;
577
+ }
578
+ const barWidth = computeSeriesBarWidth({
579
+ columnWidth,
580
+ composedBarGap,
581
+ composedBarSize,
582
+ composedMaxBarSize,
583
+ dataLength: plotData.length,
584
+ innerWidth,
585
+ seriesCount: composedBarDataKeys.length,
586
+ stacked: composedStacked
587
+ });
588
+ return computeSeriesBarRevealClipPadding({
589
+ barWidth,
590
+ gap: composedBarGap,
591
+ seriesCount: composedBarDataKeys.length,
592
+ stacked: composedStacked
593
+ });
594
+ }, [
595
+ columnWidth,
596
+ composedBarDataKeys,
597
+ composedBarGap,
598
+ composedBarSize,
599
+ composedMaxBarSize,
600
+ composedStacked,
601
+ innerWidth,
602
+ plotData.length
603
+ ]);
604
+ const revealClipPadding = xDomain ? barRevealClipPadding : Math.max(barRevealClipPadding, SERIES_CLIP_EDGE_BLEED);
605
+ const revealClipPaddingY = Math.max(
606
+ barRevealClipPadding,
607
+ SERIES_CLIP_EDGE_BLEED
608
+ );
609
+ return /* @__PURE__ */ jsx(
610
+ ReferenceAreaRegistrationContext.Provider,
611
+ {
612
+ value: referenceAreaRegistration,
613
+ children: /* @__PURE__ */ jsx(ChartStableContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx(ChartHoverStoreProvider, { store: hoverStore, children: /* @__PURE__ */ jsxs(
614
+ "svg",
615
+ {
616
+ "aria-hidden": "true",
617
+ className: "overflow-visible",
618
+ height,
619
+ width,
620
+ children: [
621
+ /* @__PURE__ */ jsxs(OptionalDefs, { children: [
622
+ defsChildren,
623
+ useClipReveal ? /* @__PURE__ */ jsx(
624
+ ChartRevealClip,
625
+ {
626
+ animating: isRevealAnimating || isRevealConcealing,
627
+ clipPathId: uniqueClipPathId,
628
+ enterTransition: effectiveEnterTransition,
629
+ height: innerHeight,
630
+ mode: isRevealConcealing ? "conceal" : "reveal",
631
+ onComplete: isRevealConcealing ? notifyRevealConcealComplete : void 0,
632
+ padding: revealClipPadding,
633
+ paddingY: revealClipPaddingY,
634
+ revealEpoch: isRevealConcealing ? concealEpoch : revealEpoch,
635
+ targetWidth: innerWidth
636
+ }
637
+ ) : null
638
+ ] }),
639
+ /* @__PURE__ */ jsx(
640
+ "rect",
641
+ {
642
+ fill: "transparent",
643
+ height,
644
+ width,
645
+ x: 0,
646
+ y: 0
647
+ }
648
+ ),
649
+ /* @__PURE__ */ jsxs(
650
+ "g",
651
+ {
652
+ ...interactionHandlers,
653
+ onClick: aic.aoClicar ? () => {
654
+ const index = hoverStore.getSnapshot().tooltipData?.index;
655
+ if (index !== void 0) {
656
+ aic.aoClicar?.(index);
657
+ }
658
+ } : void 0,
659
+ style: aic.aoClicar ? { ...interactionStyle, cursor: "pointer" } : interactionStyle,
660
+ transform: `translate(${margin.left},${margin.top})`,
661
+ children: [
662
+ /* @__PURE__ */ jsx(
663
+ "rect",
664
+ {
665
+ fill: "transparent",
666
+ height: innerHeight,
667
+ width: innerWidth,
668
+ x: 0,
669
+ y: 0
670
+ }
671
+ ),
672
+ clipExcludedChildren,
673
+ underlayChildren,
674
+ useClipReveal ? /* @__PURE__ */ jsx("g", { clipPath: `url(#${uniqueClipPathId})`, children: preOverlayChildren }) : preOverlayChildren,
675
+ postOverlayChildren
676
+ ]
677
+ }
678
+ )
679
+ ]
680
+ }
681
+ ) }) })
682
+ }
683
+ );
684
+ });
685
+ export {
686
+ TimeSeriesChartInner,
687
+ timeSeriesChartHasRoom
688
+ };