@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,295 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { m } from "motion/react";
4
+ import { useId, useMemo } from "react";
5
+ import { useChartStable } from "./chart-context";
6
+ import { firstIndexOnOrAfter, toValidDate } from "./date-ranges";
7
+ import { renderPatternPreset } from "./pattern-preset";
8
+ import { useCategorySlots } from "./use-category-slots";
9
+ import { isReferenceAreaVisiblePhase } from "./y-domain-utils";
10
+ const DEFAULT_COLOR = "var(--chart-negative, var(--chart-negative))";
11
+ const ENTER_FADE_MS = 420;
12
+ const LABEL_INSET = 6;
13
+ const LABEL_FLIP_WIDTH = 96;
14
+ function defaultFillOpacity(fillType) {
15
+ if (fillType === "pattern") {
16
+ return 0.6;
17
+ }
18
+ if (fillType === "gradient") {
19
+ return 0.25;
20
+ }
21
+ return 0.12;
22
+ }
23
+ function resolveDeadlineRegion(startTime, endTime, {
24
+ innerWidth,
25
+ slots,
26
+ isBandScale,
27
+ xScale
28
+ }) {
29
+ if (startTime == null) {
30
+ return null;
31
+ }
32
+ if (slots) {
33
+ if (slots.axis !== "x") {
34
+ return null;
35
+ }
36
+ const startIndex = firstIndexOnOrAfter(slots.dates, new Date(startTime));
37
+ if (startIndex < 0) {
38
+ return null;
39
+ }
40
+ const endIndex = endTime == null ? -1 : firstIndexOnOrAfter(slots.dates, new Date(endTime));
41
+ return {
42
+ x0: slots.slotStart(startIndex),
43
+ x1: endIndex < 0 ? innerWidth : slots.slotStart(endIndex)
44
+ };
45
+ }
46
+ if (isBandScale) {
47
+ return null;
48
+ }
49
+ return {
50
+ x0: xScale(new Date(startTime)),
51
+ x1: endTime == null ? innerWidth : xScale(new Date(endTime))
52
+ };
53
+ }
54
+ function DeadlineRegionFill({
55
+ region,
56
+ clipX0,
57
+ clipX1,
58
+ innerHeight,
59
+ uid,
60
+ color,
61
+ fillType,
62
+ opacity,
63
+ gradientToOpacity,
64
+ patternNode,
65
+ patternId,
66
+ fade,
67
+ fadeLength
68
+ }) {
69
+ const fadeMaskId = `chart-deadline-fade-${uid}`;
70
+ const fillGradientId = `chart-deadline-fill-${uid}`;
71
+ const fadeStart = 1 - Math.min(1, Math.max(0, fadeLength));
72
+ const useFade = fade && fadeLength > 0;
73
+ let regionFill = color;
74
+ if (fillType === "gradient") {
75
+ regionFill = `url(#${fillGradientId})`;
76
+ } else if (patternNode) {
77
+ regionFill = `url(#${patternId})`;
78
+ }
79
+ const gradientAttrs = {
80
+ gradientUnits: "userSpaceOnUse",
81
+ x1: region.x0,
82
+ x2: region.x1,
83
+ y1: 0,
84
+ y2: 0
85
+ };
86
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
87
+ /* @__PURE__ */ jsxs("defs", { children: [
88
+ useFade ? /* @__PURE__ */ jsxs(Fragment, { children: [
89
+ /* @__PURE__ */ jsxs("linearGradient", { id: `${fadeMaskId}-gradient`, ...gradientAttrs, children: [
90
+ /* @__PURE__ */ jsx("stop", { offset: 0, stopColor: "white", stopOpacity: 1 }),
91
+ /* @__PURE__ */ jsx("stop", { offset: fadeStart, stopColor: "white", stopOpacity: 1 }),
92
+ /* @__PURE__ */ jsx("stop", { offset: 1, stopColor: "white", stopOpacity: 0 })
93
+ ] }),
94
+ /* @__PURE__ */ jsx("mask", { id: fadeMaskId, children: /* @__PURE__ */ jsx(
95
+ "rect",
96
+ {
97
+ fill: `url(#${fadeMaskId}-gradient)`,
98
+ height: innerHeight,
99
+ width: clipX1 - clipX0,
100
+ x: clipX0,
101
+ y: 0
102
+ }
103
+ ) })
104
+ ] }) : null,
105
+ fillType === "gradient" ? /* @__PURE__ */ jsxs("linearGradient", { id: fillGradientId, ...gradientAttrs, children: [
106
+ /* @__PURE__ */ jsx("stop", { offset: 0, stopColor: color, stopOpacity: 1 }),
107
+ /* @__PURE__ */ jsx(
108
+ "stop",
109
+ {
110
+ offset: 1,
111
+ stopColor: color,
112
+ stopOpacity: opacity > 0 ? gradientToOpacity / opacity : 0
113
+ }
114
+ )
115
+ ] }) : null
116
+ ] }),
117
+ patternNode,
118
+ /* @__PURE__ */ jsx(
119
+ "rect",
120
+ {
121
+ fill: regionFill,
122
+ height: innerHeight,
123
+ mask: useFade ? `url(#${fadeMaskId})` : void 0,
124
+ opacity,
125
+ width: clipX1 - clipX0,
126
+ x: clipX0,
127
+ y: 0
128
+ }
129
+ )
130
+ ] });
131
+ }
132
+ function DeadlineMarkerLine({
133
+ x,
134
+ innerHeight,
135
+ color,
136
+ stroke,
137
+ strokeWidth,
138
+ strokeDasharray,
139
+ strokeOpacity,
140
+ label,
141
+ labelColor,
142
+ labelPosition,
143
+ labelFlipped
144
+ }) {
145
+ const bottom = labelPosition === "bottom";
146
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
147
+ /* @__PURE__ */ jsx(
148
+ "line",
149
+ {
150
+ stroke: stroke ?? color,
151
+ strokeDasharray,
152
+ strokeOpacity,
153
+ strokeWidth,
154
+ x1: x,
155
+ x2: x,
156
+ y1: 0,
157
+ y2: innerHeight
158
+ }
159
+ ),
160
+ label ? /* @__PURE__ */ jsx(
161
+ "text",
162
+ {
163
+ dominantBaseline: bottom ? "auto" : "hanging",
164
+ fill: labelColor ?? color,
165
+ fontSize: 11,
166
+ fontWeight: 500,
167
+ textAnchor: labelFlipped ? "end" : "start",
168
+ x: labelFlipped ? x - LABEL_INSET : x + LABEL_INSET,
169
+ y: bottom ? innerHeight - LABEL_INSET : LABEL_INSET,
170
+ children: label
171
+ }
172
+ ) : null
173
+ ] });
174
+ }
175
+ function Deadline({
176
+ date,
177
+ endDate,
178
+ color = DEFAULT_COLOR,
179
+ fillType = "pattern",
180
+ fillOpacity,
181
+ gradientToOpacity = 0,
182
+ pattern = "diagonal-up",
183
+ patternScale = 1.5,
184
+ patternStrokeWidth = 1,
185
+ fade = true,
186
+ fadeLength = 0.5,
187
+ showLine = true,
188
+ stroke,
189
+ strokeWidth = 1,
190
+ strokeDasharray,
191
+ strokeOpacity = 1,
192
+ label,
193
+ labelPosition = "top",
194
+ labelColor,
195
+ dateKey,
196
+ className
197
+ }) {
198
+ const {
199
+ innerWidth,
200
+ innerHeight,
201
+ xScale,
202
+ barScale,
203
+ chartPhase,
204
+ enterTransition
205
+ } = useChartStable();
206
+ const slots = useCategorySlots(dateKey);
207
+ const uid = useId().replace(/:/g, "");
208
+ const patternId = `chart-deadline-pattern-${uid}`;
209
+ const startTime = toValidDate(date)?.getTime();
210
+ const endTime = endDate == null ? void 0 : toValidDate(endDate)?.getTime();
211
+ const isBandScale = barScale != null;
212
+ const region = useMemo(
213
+ () => innerWidth > 0 && innerHeight > 0 ? resolveDeadlineRegion(startTime, endTime, {
214
+ innerWidth,
215
+ slots,
216
+ isBandScale,
217
+ xScale
218
+ }) : null,
219
+ [startTime, endTime, innerWidth, innerHeight, slots, isBandScale, xScale]
220
+ );
221
+ const usesPattern = fillType === "pattern" && pattern !== "none";
222
+ const patternNode = useMemo(
223
+ () => usesPattern ? renderPatternPreset(pattern, patternId, {
224
+ color,
225
+ scale: patternScale,
226
+ strokeWidth: patternStrokeWidth
227
+ }) : null,
228
+ [usesPattern, pattern, patternId, color, patternScale, patternStrokeWidth]
229
+ );
230
+ if (!region || region.x1 <= region.x0) {
231
+ return null;
232
+ }
233
+ const { x0 } = region;
234
+ const clipX0 = Math.max(0, x0);
235
+ const clipX1 = Math.min(innerWidth, region.x1);
236
+ const lineVisible = showLine && x0 >= 0 && x0 <= innerWidth;
237
+ const hasFill = fillType !== "none" && clipX1 > clipX0;
238
+ if (!(lineVisible || hasFill)) {
239
+ return null;
240
+ }
241
+ const visible = isReferenceAreaVisiblePhase(chartPhase);
242
+ const fadeTransition = enterTransition && typeof enterTransition === "object" ? enterTransition : { duration: ENTER_FADE_MS / 1e3, ease: "easeOut" };
243
+ return /* @__PURE__ */ jsxs(
244
+ m.g,
245
+ {
246
+ animate: { opacity: visible ? 1 : 0 },
247
+ "aria-hidden": "true",
248
+ className: className ?? "chart-deadline",
249
+ initial: { opacity: 0 },
250
+ transition: fadeTransition,
251
+ children: [
252
+ hasFill ? /* @__PURE__ */ jsx(
253
+ DeadlineRegionFill,
254
+ {
255
+ clipX0,
256
+ clipX1,
257
+ color,
258
+ fade,
259
+ fadeLength,
260
+ fillType,
261
+ gradientToOpacity,
262
+ innerHeight,
263
+ opacity: fillOpacity ?? defaultFillOpacity(fillType),
264
+ patternId,
265
+ patternNode,
266
+ region,
267
+ uid
268
+ }
269
+ ) : null,
270
+ lineVisible ? /* @__PURE__ */ jsx(
271
+ DeadlineMarkerLine,
272
+ {
273
+ color,
274
+ innerHeight,
275
+ label,
276
+ labelColor,
277
+ labelFlipped: x0 > innerWidth - LABEL_FLIP_WIDTH,
278
+ labelPosition,
279
+ stroke,
280
+ strokeDasharray,
281
+ strokeOpacity,
282
+ strokeWidth,
283
+ x: x0
284
+ }
285
+ ) : null
286
+ ]
287
+ }
288
+ );
289
+ }
290
+ Deadline.displayName = "Deadline";
291
+ var deadline_default = Deadline;
292
+ export {
293
+ Deadline,
294
+ deadline_default as default
295
+ };
@@ -0,0 +1,112 @@
1
+ function decimateTimeSeries(data, maxPoints, valueKeys = []) {
2
+ const len = data.length;
3
+ if (maxPoints >= len || maxPoints < 3) {
4
+ return data;
5
+ }
6
+ const getY = (point, index) => {
7
+ if (valueKeys.length === 0) {
8
+ for (const val of Object.values(point)) {
9
+ if (typeof val === "number") {
10
+ return val;
11
+ }
12
+ }
13
+ return index;
14
+ }
15
+ let sum = 0;
16
+ let count = 0;
17
+ for (const key of valueKeys) {
18
+ const val = point[key];
19
+ if (typeof val === "number") {
20
+ sum += val;
21
+ count++;
22
+ }
23
+ }
24
+ return count > 0 ? sum / count : index;
25
+ };
26
+ const sampled = [data[0]];
27
+ const bucketSize = (len - 2) / (maxPoints - 2);
28
+ let previousIndex = 0;
29
+ for (let i = 0; i < maxPoints - 2; i++) {
30
+ const rangeStart = Math.floor((i + 1) * bucketSize) + 1;
31
+ const rangeEnd = Math.min(Math.floor((i + 2) * bucketSize) + 1, len - 1);
32
+ const nextRangeStart = Math.floor((i + 2) * bucketSize) + 1;
33
+ const nextRangeEnd = Math.min(Math.floor((i + 3) * bucketSize) + 1, len);
34
+ const nextCount = Math.max(0, nextRangeEnd - nextRangeStart);
35
+ let avgX = len - 1;
36
+ let avgY = getY(data[len - 1], len - 1);
37
+ if (nextCount > 0) {
38
+ avgX = 0;
39
+ avgY = 0;
40
+ for (let j = nextRangeStart; j < nextRangeEnd; j++) {
41
+ avgX += j;
42
+ avgY += getY(data[j], j);
43
+ }
44
+ avgX /= nextCount;
45
+ avgY /= nextCount;
46
+ }
47
+ const pointA = data[previousIndex];
48
+ const ax = previousIndex;
49
+ const ay = getY(pointA, previousIndex);
50
+ let maxArea = -1;
51
+ let maxIndex = rangeStart;
52
+ for (let j = rangeStart; j < rangeEnd; j++) {
53
+ const area = Math.abs(
54
+ (ax - avgX) * (getY(data[j], j) - ay) - (ax - j) * (avgY - ay)
55
+ ) * 0.5;
56
+ if (area > maxArea) {
57
+ maxArea = area;
58
+ maxIndex = j;
59
+ }
60
+ }
61
+ sampled.push(data[maxIndex]);
62
+ previousIndex = maxIndex;
63
+ }
64
+ sampled.push(data[len - 1]);
65
+ return sampled;
66
+ }
67
+ function maxRenderPointsForWidth(innerWidth) {
68
+ return Math.max(64, Math.ceil(innerWidth * 1.5));
69
+ }
70
+ function decimateOhlcData(data, maxPoints) {
71
+ const len = data.length;
72
+ if (maxPoints >= len || maxPoints < 2) {
73
+ return data;
74
+ }
75
+ const bucketSize = len / maxPoints;
76
+ const sampled = [];
77
+ for (let i = 0; i < maxPoints; i++) {
78
+ const start = Math.floor(i * bucketSize);
79
+ const end = Math.min(len, Math.floor((i + 1) * bucketSize));
80
+ if (start >= end) {
81
+ continue;
82
+ }
83
+ const bucket = data.slice(start, end);
84
+ const first = bucket[0];
85
+ const last = bucket.at(-1);
86
+ let high = Number.NEGATIVE_INFINITY;
87
+ let low = Number.POSITIVE_INFINITY;
88
+ for (const row of bucket) {
89
+ const rowHigh = row.high;
90
+ const rowLow = row.low;
91
+ if (typeof rowHigh === "number" && rowHigh > high) {
92
+ high = rowHigh;
93
+ }
94
+ if (typeof rowLow === "number" && rowLow < low) {
95
+ low = rowLow;
96
+ }
97
+ }
98
+ sampled.push({
99
+ ...last,
100
+ open: first.open,
101
+ high: Number.isFinite(high) ? high : last.high,
102
+ low: Number.isFinite(low) ? low : last.low,
103
+ close: last.close
104
+ });
105
+ }
106
+ return sampled;
107
+ }
108
+ export {
109
+ decimateOhlcData,
110
+ decimateTimeSeries,
111
+ maxRenderPointsForWidth
112
+ };
@@ -0,0 +1,171 @@
1
+ const DEFAULT_FADE_EDGES_LENGTH = 15;
2
+ function clampFadeEdgesLength(length) {
3
+ return Math.min(50, Math.max(0, length));
4
+ }
5
+ function fadeSides(leftLength, rightLength) {
6
+ const l = clampFadeEdgesLength(leftLength);
7
+ const r = clampFadeEdgesLength(rightLength);
8
+ return {
9
+ left: l > 0,
10
+ right: r > 0,
11
+ any: l > 0 || r > 0,
12
+ leftLength: l,
13
+ rightLength: r
14
+ };
15
+ }
16
+ function resolveFadeSides(fade) {
17
+ const d = DEFAULT_FADE_EDGES_LENGTH;
18
+ if (fade === false) {
19
+ return fadeSides(0, 0);
20
+ }
21
+ if (fade === "left") {
22
+ return fadeSides(d, 0);
23
+ }
24
+ if (fade === "right") {
25
+ return fadeSides(0, d);
26
+ }
27
+ if (typeof fade === "object" && fade !== null) {
28
+ return fadeSides(fade.left ?? 0, fade.right ?? 0);
29
+ }
30
+ return fadeSides(d, d);
31
+ }
32
+ function fadeGradientStops(sides) {
33
+ return dedupeStops([
34
+ { offset: "0%", opacity: sides.left ? 0 : 1 },
35
+ { offset: `${sides.left ? sides.leftLength : 0}%`, opacity: 1 },
36
+ { offset: `${100 - (sides.right ? sides.rightLength : 0)}%`, opacity: 1 },
37
+ { offset: "100%", opacity: sides.right ? 0 : 1 }
38
+ ]);
39
+ }
40
+ function dedupeStops(stops) {
41
+ return stops.filter(
42
+ (stop, i) => i === 0 || stop.offset !== stops[i - 1]?.offset || stop.opacity !== stops[i - 1]?.opacity
43
+ );
44
+ }
45
+ function areaVerticalFadeStops({
46
+ topOpacity,
47
+ fadeBottom,
48
+ gradientToOpacity,
49
+ gradientSpan = 1
50
+ }) {
51
+ if (fadeBottom !== void 0) {
52
+ const zone = Math.min(100, Math.max(0, fadeBottom)) / 100;
53
+ if (zone <= 0) {
54
+ return [
55
+ { offset: 0, opacity: topOpacity },
56
+ { offset: 1, opacity: topOpacity }
57
+ ];
58
+ }
59
+ return dedupeStops([
60
+ { offset: 0, opacity: topOpacity },
61
+ { offset: 1 - zone, opacity: topOpacity },
62
+ { offset: 1, opacity: 0 }
63
+ ]);
64
+ }
65
+ const span = Math.min(1, Math.max(0.01, gradientSpan));
66
+ const stops = [
67
+ { offset: 0, opacity: topOpacity },
68
+ { offset: span, opacity: gradientToOpacity }
69
+ ];
70
+ if (span < 1) {
71
+ stops.push({ offset: 1, opacity: gradientToOpacity });
72
+ }
73
+ return stops;
74
+ }
75
+ function resolveStrokeGradientStops(gradient) {
76
+ if (!gradient || gradient.length === 0) {
77
+ return null;
78
+ }
79
+ const last = Math.max(1, gradient.length - 1);
80
+ return gradient.map(
81
+ (stop, index) => typeof stop === "string" ? { offset: gradient.length === 1 ? 0 : index / last, color: stop } : {
82
+ offset: Math.min(1, Math.max(0, stop.offset)),
83
+ color: stop.color
84
+ }
85
+ ).sort((a, b) => a.offset - b.offset);
86
+ }
87
+ function percentToFraction(offset) {
88
+ return Number.parseFloat(offset) / 100;
89
+ }
90
+ function roundPercent(value) {
91
+ return Math.round(value * 1e4) / 100;
92
+ }
93
+ function colorAt(stops, t) {
94
+ const first = stops[0];
95
+ const last = stops.at(-1);
96
+ if (t <= first.offset) {
97
+ return first.color;
98
+ }
99
+ if (t >= last.offset) {
100
+ return last.color;
101
+ }
102
+ for (let i = 1; i < stops.length; i++) {
103
+ const b = stops[i];
104
+ if (t > b.offset) {
105
+ continue;
106
+ }
107
+ const a = stops[i - 1];
108
+ if (t === b.offset || b.offset === a.offset) {
109
+ return b.color;
110
+ }
111
+ const mix = roundPercent((t - a.offset) / (b.offset - a.offset));
112
+ return `color-mix(in srgb, ${b.color} ${mix}%, ${a.color})`;
113
+ }
114
+ return last.color;
115
+ }
116
+ function opacityAt(stops, t) {
117
+ let prev = stops[0];
118
+ for (const stop of stops) {
119
+ const offset = percentToFraction(stop.offset);
120
+ const prevOffset = percentToFraction(prev.offset);
121
+ if (t <= offset) {
122
+ if (offset === prevOffset) {
123
+ return stop.opacity;
124
+ }
125
+ const progress = (t - prevOffset) / (offset - prevOffset);
126
+ return prev.opacity + (stop.opacity - prev.opacity) * progress;
127
+ }
128
+ prev = stop;
129
+ }
130
+ return prev.opacity;
131
+ }
132
+ function horizontalPaintStops({
133
+ color,
134
+ colorStops,
135
+ fadeStops
136
+ }) {
137
+ const offsets = /* @__PURE__ */ new Set();
138
+ for (const stop of colorStops ?? []) {
139
+ offsets.add(stop.offset);
140
+ }
141
+ for (const stop of fadeStops ?? []) {
142
+ offsets.add(percentToFraction(stop.offset));
143
+ }
144
+ if (offsets.size === 0) {
145
+ offsets.add(0);
146
+ }
147
+ return [...offsets].sort((a, b) => a - b).map((t) => ({
148
+ offset: `${roundPercent(t)}%`,
149
+ color: colorStops ? colorAt(colorStops, t) : color,
150
+ opacity: fadeStops ? opacityAt(fadeStops, t) : 1
151
+ }));
152
+ }
153
+ function viewportFadeGradientAttrs(innerWidth) {
154
+ return {
155
+ gradientUnits: "userSpaceOnUse",
156
+ x1: 0,
157
+ x2: innerWidth,
158
+ y1: 0,
159
+ y2: 0
160
+ };
161
+ }
162
+ export {
163
+ DEFAULT_FADE_EDGES_LENGTH,
164
+ areaVerticalFadeStops,
165
+ clampFadeEdgesLength,
166
+ fadeGradientStops,
167
+ horizontalPaintStops,
168
+ resolveFadeSides,
169
+ resolveStrokeGradientStops,
170
+ viewportFadeGradientAttrs
171
+ };
@@ -0,0 +1,78 @@
1
+ function formatCoordinate(value) {
2
+ const scaled = Math.round(value * 1e3);
3
+ if (!(scaled > -1e12 && scaled < 1e12)) {
4
+ return String(scaled / 1e3);
5
+ }
6
+ if (scaled === 0) {
7
+ return "0";
8
+ }
9
+ const negative = scaled < 0;
10
+ const abs = negative ? -scaled : scaled;
11
+ const whole = Math.floor(abs / 1e3);
12
+ const fraction = abs - whole * 1e3;
13
+ const head = negative ? `-${whole}` : `${whole}`;
14
+ if (fraction === 0) {
15
+ return head;
16
+ }
17
+ if (fraction % 100 === 0) {
18
+ return `${head}.${fraction / 100}`;
19
+ }
20
+ if (fraction % 10 === 0) {
21
+ return `${head}.${fraction < 100 ? "0" : ""}${fraction / 10}`;
22
+ }
23
+ let pad = "";
24
+ if (fraction < 10) {
25
+ pad = "00";
26
+ } else if (fraction < 100) {
27
+ pad = "0";
28
+ }
29
+ return `${head}.${pad}${fraction}`;
30
+ }
31
+ class FastPath {
32
+ d = "";
33
+ unsupported = false;
34
+ open = false;
35
+ moveTo(x, y) {
36
+ this.d += `M${formatCoordinate(+x)},${formatCoordinate(+y)}`;
37
+ this.open = true;
38
+ }
39
+ lineTo(x, y) {
40
+ this.d += `L${formatCoordinate(+x)},${formatCoordinate(+y)}`;
41
+ this.open = true;
42
+ }
43
+ closePath() {
44
+ if (this.open) {
45
+ this.d += "Z";
46
+ }
47
+ }
48
+ quadraticCurveTo(x1, y1, x, y) {
49
+ this.d += `Q${formatCoordinate(+x1)},${formatCoordinate(+y1)},${formatCoordinate(+x)},${formatCoordinate(+y)}`;
50
+ this.open = true;
51
+ }
52
+ bezierCurveTo(x1, y1, x2, y2, x, y) {
53
+ this.d += `C${formatCoordinate(+x1)},${formatCoordinate(+y1)},${formatCoordinate(+x2)},${formatCoordinate(+y2)},${formatCoordinate(+x)},${formatCoordinate(+y)}`;
54
+ this.open = true;
55
+ }
56
+ arcTo() {
57
+ this.unsupported = true;
58
+ }
59
+ arc() {
60
+ this.unsupported = true;
61
+ }
62
+ rect() {
63
+ this.unsupported = true;
64
+ }
65
+ }
66
+ function fastShapePath(generator, data) {
67
+ const context = new FastPath();
68
+ generator.context(context);
69
+ generator(data);
70
+ generator.context(null);
71
+ if (context.unsupported) {
72
+ return (generator(data) ?? "") || "";
73
+ }
74
+ return context.d;
75
+ }
76
+ export {
77
+ fastShapePath
78
+ };
@@ -0,0 +1,45 @@
1
+ function filterDataByXDomain(data, xDomain, xAccessor) {
2
+ const start = xDomain[0].getTime();
3
+ const end = xDomain[1].getTime();
4
+ const minTime = Math.min(start, end);
5
+ const maxTime = Math.max(start, end);
6
+ return data.filter((d) => {
7
+ const time = xAccessor(d).getTime();
8
+ return time >= minTime && time <= maxTime;
9
+ });
10
+ }
11
+ function resolveDataXExtent(data, xAccessor) {
12
+ if (data.length === 0) {
13
+ return null;
14
+ }
15
+ let minTime = Number.POSITIVE_INFINITY;
16
+ let maxTime = Number.NEGATIVE_INFINITY;
17
+ for (const point of data) {
18
+ const time = xAccessor(point).getTime();
19
+ if (time < minTime) {
20
+ minTime = time;
21
+ }
22
+ if (time > maxTime) {
23
+ maxTime = time;
24
+ }
25
+ }
26
+ if (minTime === Number.POSITIVE_INFINITY) {
27
+ return null;
28
+ }
29
+ return [new Date(minTime), new Date(maxTime)];
30
+ }
31
+ function resolveBrushTrackXExtent(data, xAccessor, xExtentMax) {
32
+ const extent = resolveDataXExtent(data, xAccessor);
33
+ if (!extent) {
34
+ return null;
35
+ }
36
+ if (!xExtentMax || xExtentMax.getTime() <= extent[1].getTime()) {
37
+ return extent;
38
+ }
39
+ return [extent[0], xExtentMax];
40
+ }
41
+ export {
42
+ filterDataByXDomain,
43
+ resolveBrushTrackXExtent,
44
+ resolveDataXExtent
45
+ };