@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,27 @@
1
+ const DEFAULT_SKELETON_DATA_KEY = "value";
2
+ const DEFAULT_SKELETON_POINT_COUNT = 7;
3
+ function generateChartSkeletonData(options = {}) {
4
+ const dataKey = options.dataKey ?? DEFAULT_SKELETON_DATA_KEY;
5
+ const pointCount = options.pointCount ?? DEFAULT_SKELETON_POINT_COUNT;
6
+ const baseDate = options.baseDate ?? /* @__PURE__ */ new Date("2025-01-01");
7
+ return Array.from({ length: pointCount }, (_, index) => {
8
+ const date = new Date(baseDate);
9
+ date.setDate(baseDate.getDate() + index);
10
+ return {
11
+ date,
12
+ [dataKey]: Math.round(110 + Math.sin(index * 1.15) * 36 + index * 9)
13
+ };
14
+ });
15
+ }
16
+ function generateChartSkeletonFromTarget(targetData, dataKey) {
17
+ return targetData.map((row, index) => ({
18
+ ...row,
19
+ [dataKey]: Math.round(95 + Math.sin(index * 1.05) * 28 + index * 7)
20
+ }));
21
+ }
22
+ export {
23
+ DEFAULT_SKELETON_DATA_KEY,
24
+ DEFAULT_SKELETON_POINT_COUNT,
25
+ generateChartSkeletonData,
26
+ generateChartSkeletonFromTarget
27
+ };
@@ -0,0 +1,158 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ function LinearGradient({
3
+ children,
4
+ id,
5
+ from,
6
+ to,
7
+ x1: x1Prop,
8
+ y1: y1Prop,
9
+ x2: x2Prop,
10
+ y2: y2Prop,
11
+ fromOffset = "0%",
12
+ fromOpacity = 1,
13
+ toOffset = "100%",
14
+ toOpacity = 1,
15
+ rotate,
16
+ transform,
17
+ vertical = true,
18
+ ...restProps
19
+ }) {
20
+ let x1 = x1Prop;
21
+ let x2 = x2Prop;
22
+ let y1 = y1Prop;
23
+ let y2 = y2Prop;
24
+ if (vertical && !x1 && !x2 && !y1 && !y2) {
25
+ x1 = "0";
26
+ x2 = "0";
27
+ y1 = "0";
28
+ y2 = "1";
29
+ }
30
+ const props = {
31
+ id,
32
+ x1,
33
+ y1,
34
+ x2,
35
+ y2,
36
+ gradientTransform: rotate ? `rotate(${rotate})` : transform,
37
+ ...restProps
38
+ };
39
+ return /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { ...props, children: [
40
+ !!children && children,
41
+ !children && /* @__PURE__ */ jsx(
42
+ "stop",
43
+ {
44
+ offset: fromOffset,
45
+ stopColor: from,
46
+ stopOpacity: fromOpacity
47
+ }
48
+ ),
49
+ !children && /* @__PURE__ */ jsx("stop", { offset: toOffset, stopColor: to, stopOpacity: toOpacity })
50
+ ] }) });
51
+ }
52
+ function RadialGradient({
53
+ children,
54
+ id,
55
+ from,
56
+ to,
57
+ fromOffset = "0%",
58
+ fromOpacity = 1,
59
+ toOffset = "100%",
60
+ toOpacity = 1,
61
+ rotate,
62
+ transform,
63
+ ...restProps
64
+ }) {
65
+ const props = {
66
+ id,
67
+ gradientTransform: rotate ? `rotate(${rotate})` : transform,
68
+ ...restProps
69
+ };
70
+ return /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("radialGradient", { ...props, children: [
71
+ !!children && children,
72
+ !children && /* @__PURE__ */ jsx(
73
+ "stop",
74
+ {
75
+ offset: fromOffset,
76
+ stopColor: from,
77
+ stopOpacity: fromOpacity
78
+ }
79
+ ),
80
+ !children && /* @__PURE__ */ jsx("stop", { offset: toOffset, stopColor: to, stopOpacity: toOpacity })
81
+ ] }) });
82
+ }
83
+ function GradientDarkgreenGreen({
84
+ from = "#184E86",
85
+ to = "#57CA85",
86
+ ...restProps
87
+ }) {
88
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
89
+ }
90
+ function GradientLightgreenGreen({
91
+ from = "#42E695",
92
+ to = "#3BB2B8",
93
+ ...restProps
94
+ }) {
95
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
96
+ }
97
+ function GradientOrangeRed({
98
+ from = "#FCE38A",
99
+ to = "#F38181",
100
+ ...restProps
101
+ }) {
102
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
103
+ }
104
+ function GradientPinkBlue({
105
+ from = "#F02FC2",
106
+ to = "#6094EA",
107
+ ...restProps
108
+ }) {
109
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
110
+ }
111
+ function GradientPinkRed({
112
+ from = "#F54EA2",
113
+ to = "#FF7676",
114
+ ...restProps
115
+ }) {
116
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
117
+ }
118
+ function GradientPurpleOrange({
119
+ from = "#7117EA",
120
+ to = "#EA6060",
121
+ ...restProps
122
+ }) {
123
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
124
+ }
125
+ function GradientPurpleTeal({
126
+ from = "#5B247A",
127
+ to = "#1BCEDF",
128
+ ...restProps
129
+ }) {
130
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
131
+ }
132
+ function GradientSteelPurple({
133
+ from = "#65799B",
134
+ to = "#5E2563",
135
+ ...restProps
136
+ }) {
137
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
138
+ }
139
+ function GradientTealBlue({
140
+ from = "#17EAD9",
141
+ to = "#6078EA",
142
+ ...restProps
143
+ }) {
144
+ return /* @__PURE__ */ jsx(LinearGradient, { from, to, ...restProps });
145
+ }
146
+ export {
147
+ GradientDarkgreenGreen,
148
+ GradientLightgreenGreen,
149
+ GradientOrangeRed,
150
+ GradientPinkBlue,
151
+ GradientPinkRed,
152
+ GradientPurpleOrange,
153
+ GradientPurpleTeal,
154
+ GradientSteelPurple,
155
+ GradientTealBlue,
156
+ LinearGradient,
157
+ RadialGradient
158
+ };
@@ -0,0 +1,114 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ function gridTickValues(scale, numTicks = 10, tickValues) {
3
+ if (tickValues) {
4
+ return tickValues;
5
+ }
6
+ if ("ticks" in scale && scale.ticks) {
7
+ return scale.ticks(numTicks);
8
+ }
9
+ return scale.domain().filter(
10
+ (_, index, all) => numTicks == null || all.length <= numTicks || index % Math.round((all.length - 1) / numTicks) === 0
11
+ );
12
+ }
13
+ function gridLinePositions(scale, {
14
+ numTicks,
15
+ offset,
16
+ tickValues
17
+ } = {}) {
18
+ const bandOffset = "bandwidth" in scale && scale.bandwidth ? scale.bandwidth() / 2 : 0;
19
+ const scaleOffset = (offset ?? 0) + bandOffset;
20
+ return gridTickValues(scale, numTicks, tickValues).map((tick) => {
21
+ const mapped = scale(tick);
22
+ const value = mapped != null && typeof mapped === "object" ? mapped.valueOf() : mapped;
23
+ return (value ?? 0) + scaleOffset;
24
+ });
25
+ }
26
+ function gridLine(key, x1, y1, x2, y2, {
27
+ stroke,
28
+ strokeWidth,
29
+ strokeDasharray,
30
+ lineStyle,
31
+ rest
32
+ }) {
33
+ const rectilinear = x1 === x2 || y1 === y2;
34
+ const props = {
35
+ x1,
36
+ y1,
37
+ x2,
38
+ y2,
39
+ fill: "transparent",
40
+ shapeRendering: rectilinear ? "crispEdges" : "auto",
41
+ stroke,
42
+ strokeWidth,
43
+ strokeDasharray,
44
+ style: lineStyle,
45
+ ...rest
46
+ };
47
+ return /* @__PURE__ */ jsx("line", { ...props }, key);
48
+ }
49
+ function wrapGridLines(lines, { className, left, top }) {
50
+ if (left === 0 && top === 0 && !className) {
51
+ return /* @__PURE__ */ jsx(Fragment, { children: lines });
52
+ }
53
+ return /* @__PURE__ */ jsx("g", { className, transform: `translate(${left}, ${top})`, children: lines });
54
+ }
55
+ function GridRows({
56
+ top = 0,
57
+ left = 0,
58
+ scale,
59
+ width,
60
+ stroke = "#eaf0f6",
61
+ strokeWidth = 1,
62
+ strokeDasharray,
63
+ className,
64
+ numTicks = 10,
65
+ lineStyle,
66
+ offset,
67
+ tickValues,
68
+ ...rest
69
+ }) {
70
+ const positions = gridLinePositions(scale, { numTicks, offset, tickValues });
71
+ const lines = positions.map(
72
+ (y, index) => gridLine(`row-line-${index}`, 0, y, width, y, {
73
+ stroke,
74
+ strokeWidth,
75
+ strokeDasharray,
76
+ lineStyle,
77
+ rest
78
+ })
79
+ );
80
+ return wrapGridLines(lines, { className, left, top });
81
+ }
82
+ function GridColumns({
83
+ top = 0,
84
+ left = 0,
85
+ scale,
86
+ height,
87
+ stroke = "#eaf0f6",
88
+ strokeWidth = 1,
89
+ strokeDasharray,
90
+ className,
91
+ numTicks = 10,
92
+ lineStyle,
93
+ offset,
94
+ tickValues,
95
+ ...rest
96
+ }) {
97
+ const positions = gridLinePositions(scale, { numTicks, offset, tickValues });
98
+ const lines = positions.map(
99
+ (x, index) => gridLine(`column-line-${index}`, x, 0, x, height, {
100
+ stroke,
101
+ strokeWidth,
102
+ strokeDasharray,
103
+ lineStyle,
104
+ rest
105
+ })
106
+ );
107
+ return wrapGridLines(lines, { className, left, top });
108
+ }
109
+ export {
110
+ GridColumns,
111
+ GridRows,
112
+ gridLinePositions,
113
+ gridTickValues
114
+ };
@@ -0,0 +1,225 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { m } from "motion/react";
4
+ import { useId } from "react";
5
+ import { chartCssVars, useChartStable, useYScale } from "./chart-context";
6
+ import { GridColumns, GridRows } from "./grid-lines";
7
+ import { useGridShimmer } from "./use-grid-shimmer";
8
+ import {
9
+ isLoadingChromePhase,
10
+ isLoadingGridChromePhase
11
+ } from "./y-domain-utils";
12
+ const DEFAULT_SHIMMER_LENGTH_PX = 140;
13
+ const DEFAULT_SHIMMER_SPEED = 1;
14
+ const DEFAULT_SHIMMER_STROKE = "color-mix(in oklch, var(--chart-foreground) 68%, transparent)";
15
+ function hideEdgeTicks(ticks, hideEdgeLines) {
16
+ if (!hideEdgeLines || ticks.length <= 2) {
17
+ return ticks;
18
+ }
19
+ return ticks.slice(1, -1);
20
+ }
21
+ function resolveRowTickValues(options) {
22
+ const { hideHorizontalEdgeLines, numTicksRows, rowTickValues, yScale } = options;
23
+ const ticks = rowTickValues ?? (yScale.ticks ? yScale.ticks(numTicksRows) : []);
24
+ const filtered = hideEdgeTicks(ticks, hideHorizontalEdgeLines);
25
+ if (filtered === ticks && !rowTickValues && !hideHorizontalEdgeLines) {
26
+ return void 0;
27
+ }
28
+ return filtered.length > 0 ? filtered : void 0;
29
+ }
30
+ function Grid({
31
+ horizontal = true,
32
+ vertical = false,
33
+ numTicksRows = 5,
34
+ numTicksColumns = 10,
35
+ rowTickValues,
36
+ stroke = chartCssVars.grid,
37
+ loadingStroke,
38
+ strokeOpacity = 1,
39
+ strokeWidth = 1,
40
+ strokeDasharray = "4,4",
41
+ highlightRowValues,
42
+ highlightRowStroke = chartCssVars.foregroundMuted,
43
+ highlightRowStrokeOpacity = 1,
44
+ highlightRowStrokeWidth = 1,
45
+ highlightRowStrokeDasharray = "0",
46
+ fadeHorizontal = true,
47
+ fadeVertical = false,
48
+ hideHorizontalEdgeLines = false,
49
+ hideVerticalEdgeLines = false,
50
+ yAxisId,
51
+ shimmer = false,
52
+ shimmerStroke = DEFAULT_SHIMMER_STROKE,
53
+ shimmerLength = DEFAULT_SHIMMER_LENGTH_PX,
54
+ shimmerSpeed = DEFAULT_SHIMMER_SPEED,
55
+ shimmerSync = false
56
+ }) {
57
+ const { xScale, innerWidth, innerHeight, orientation, barScale, chartPhase } = useChartStable();
58
+ const yScale = useYScale(yAxisId);
59
+ const shimmerActive = shimmer && isLoadingChromePhase(chartPhase);
60
+ const gridStroke = isLoadingGridChromePhase(chartPhase) && loadingStroke != null ? loadingStroke : stroke;
61
+ const { shimmerEnabled, shimmerTransform } = useGridShimmer({
62
+ innerWidth,
63
+ shimmer,
64
+ shimmerLength,
65
+ shimmerSpeed,
66
+ shimmerSync,
67
+ active: shimmerActive
68
+ });
69
+ const isHorizontalBarChart = orientation === "horizontal" && barScale;
70
+ const columnScale = isHorizontalBarChart ? yScale : xScale;
71
+ const rowTickValuesResolved = resolveRowTickValues({
72
+ hideHorizontalEdgeLines,
73
+ numTicksRows,
74
+ rowTickValues,
75
+ yScale
76
+ });
77
+ const columnTickValuesResolved = vertical && columnScale && typeof columnScale === "function" && hideVerticalEdgeLines ? (() => {
78
+ const ticks = columnScale.ticks?.(numTicksColumns) ?? [];
79
+ const filtered = hideEdgeTicks(ticks, true);
80
+ return filtered.length > 0 ? filtered : void 0;
81
+ })() : void 0;
82
+ const uniqueId = useId();
83
+ const hMaskId = `grid-rows-fade-${uniqueId}`;
84
+ const hGradientId = `${hMaskId}-gradient`;
85
+ const shimmerGradientId = `grid-shimmer-${uniqueId}`;
86
+ const vMaskId = `grid-cols-fade-${uniqueId}`;
87
+ const vGradientId = `${vMaskId}-gradient`;
88
+ const horizontalFadeMask = fadeHorizontal ? `url(#${hMaskId})` : void 0;
89
+ return /* @__PURE__ */ jsxs("g", { className: "chart-grid", children: [
90
+ horizontal && fadeHorizontal && /* @__PURE__ */ jsxs("defs", { children: [
91
+ /* @__PURE__ */ jsxs("linearGradient", { id: hGradientId, x1: "0%", x2: "100%", y1: "0%", y2: "0%", children: [
92
+ /* @__PURE__ */ jsx("stop", { offset: "0%", style: { stopColor: "white", stopOpacity: 0 } }),
93
+ /* @__PURE__ */ jsx("stop", { offset: "10%", style: { stopColor: "white", stopOpacity: 1 } }),
94
+ /* @__PURE__ */ jsx("stop", { offset: "90%", style: { stopColor: "white", stopOpacity: 1 } }),
95
+ /* @__PURE__ */ jsx(
96
+ "stop",
97
+ {
98
+ offset: "100%",
99
+ style: { stopColor: "white", stopOpacity: 0 }
100
+ }
101
+ )
102
+ ] }),
103
+ /* @__PURE__ */ jsx("mask", { id: hMaskId, children: /* @__PURE__ */ jsx(
104
+ "rect",
105
+ {
106
+ fill: `url(#${hGradientId})`,
107
+ height: innerHeight,
108
+ width: innerWidth,
109
+ x: "0",
110
+ y: "0"
111
+ }
112
+ ) })
113
+ ] }),
114
+ horizontal && shimmerEnabled ? /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
115
+ m.linearGradient,
116
+ {
117
+ gradientTransform: shimmerTransform,
118
+ gradientUnits: "userSpaceOnUse",
119
+ id: shimmerGradientId,
120
+ x1: 0,
121
+ x2: shimmerLength,
122
+ y1: 0,
123
+ y2: 0,
124
+ children: [
125
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: shimmerStroke, stopOpacity: 0 }),
126
+ /* @__PURE__ */ jsx("stop", { offset: "35%", stopColor: shimmerStroke, stopOpacity: 0.45 }),
127
+ /* @__PURE__ */ jsx("stop", { offset: "50%", stopColor: shimmerStroke, stopOpacity: 1 }),
128
+ /* @__PURE__ */ jsx("stop", { offset: "65%", stopColor: shimmerStroke, stopOpacity: 0.45 }),
129
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: shimmerStroke, stopOpacity: 0 })
130
+ ]
131
+ }
132
+ ) }) : null,
133
+ vertical && fadeVertical && /* @__PURE__ */ jsxs("defs", { children: [
134
+ /* @__PURE__ */ jsxs("linearGradient", { id: vGradientId, x1: "0%", x2: "0%", y1: "0%", y2: "100%", children: [
135
+ /* @__PURE__ */ jsx("stop", { offset: "0%", style: { stopColor: "white", stopOpacity: 0 } }),
136
+ /* @__PURE__ */ jsx("stop", { offset: "10%", style: { stopColor: "white", stopOpacity: 1 } }),
137
+ /* @__PURE__ */ jsx("stop", { offset: "90%", style: { stopColor: "white", stopOpacity: 1 } }),
138
+ /* @__PURE__ */ jsx(
139
+ "stop",
140
+ {
141
+ offset: "100%",
142
+ style: { stopColor: "white", stopOpacity: 0 }
143
+ }
144
+ )
145
+ ] }),
146
+ /* @__PURE__ */ jsx("mask", { id: vMaskId, children: /* @__PURE__ */ jsx(
147
+ "rect",
148
+ {
149
+ fill: `url(#${vGradientId})`,
150
+ height: innerHeight,
151
+ width: innerWidth,
152
+ x: "0",
153
+ y: "0"
154
+ }
155
+ ) })
156
+ ] }),
157
+ horizontal && /* @__PURE__ */ jsxs("g", { mask: horizontalFadeMask, children: [
158
+ /* @__PURE__ */ jsx(
159
+ GridRows,
160
+ {
161
+ numTicks: rowTickValuesResolved ? void 0 : numTicksRows,
162
+ scale: yScale,
163
+ stroke: gridStroke,
164
+ strokeDasharray,
165
+ strokeOpacity,
166
+ strokeWidth,
167
+ tickValues: rowTickValuesResolved,
168
+ width: innerWidth
169
+ }
170
+ ),
171
+ shimmerEnabled ? /* @__PURE__ */ jsx(
172
+ GridRows,
173
+ {
174
+ numTicks: rowTickValuesResolved ? void 0 : numTicksRows,
175
+ scale: yScale,
176
+ stroke: `url(#${shimmerGradientId})`,
177
+ strokeDasharray,
178
+ strokeOpacity: 1,
179
+ strokeWidth,
180
+ tickValues: rowTickValuesResolved,
181
+ width: innerWidth
182
+ }
183
+ ) : null
184
+ ] }),
185
+ horizontal && highlightRowValues && highlightRowValues.length > 0 ? /* @__PURE__ */ jsx("g", { className: "chart-grid-highlight-rows", children: highlightRowValues.map((value) => {
186
+ const y = yScale(value);
187
+ if (y == null || !Number.isFinite(y)) {
188
+ return null;
189
+ }
190
+ return /* @__PURE__ */ jsx(
191
+ "line",
192
+ {
193
+ stroke: highlightRowStroke,
194
+ strokeDasharray: highlightRowStrokeDasharray,
195
+ strokeOpacity: highlightRowStrokeOpacity,
196
+ strokeWidth: highlightRowStrokeWidth,
197
+ x1: 0,
198
+ x2: innerWidth,
199
+ y1: y,
200
+ y2: y
201
+ },
202
+ value
203
+ );
204
+ }) }) : null,
205
+ vertical && columnScale && typeof columnScale === "function" && /* @__PURE__ */ jsx("g", { mask: fadeVertical ? `url(#${vMaskId})` : void 0, children: /* @__PURE__ */ jsx(
206
+ GridColumns,
207
+ {
208
+ height: innerHeight,
209
+ numTicks: columnTickValuesResolved ? void 0 : numTicksColumns,
210
+ scale: columnScale,
211
+ stroke,
212
+ strokeDasharray,
213
+ strokeOpacity,
214
+ strokeWidth,
215
+ tickValues: columnTickValuesResolved
216
+ }
217
+ ) })
218
+ ] });
219
+ }
220
+ Grid.displayName = "Grid";
221
+ var grid_default = Grid;
222
+ export {
223
+ Grid,
224
+ grid_default as default
225
+ };
@@ -0,0 +1,13 @@
1
+ function generateHeatmapSkeletonFromTarget(target) {
2
+ return target.map((column) => ({
3
+ bin: column.bin,
4
+ bins: column.bins.map((bin) => ({
5
+ bin: bin.bin,
6
+ count: 0,
7
+ date: bin.date
8
+ }))
9
+ }));
10
+ }
11
+ export {
12
+ generateHeatmapSkeletonFromTarget
13
+ };
@@ -0,0 +1,128 @@
1
+ import { cubicBezier } from "motion/react";
2
+ import {
3
+ clipRevealTransition,
4
+ DEFAULT_ANIMATION_DURATION_MS,
5
+ DEFAULT_CHART_ENTER_TRANSITION
6
+ } from "../animation";
7
+ import { getHeatmapContributionLevel } from "./heatmap-utils";
8
+ const HEATMAP_DEFAULT_ENTER_DURATION_MS = DEFAULT_ANIMATION_DURATION_MS;
9
+ const HEATMAP_DEFAULT_ENTER_TRANSITION = DEFAULT_CHART_ENTER_TRANSITION;
10
+ const HEATMAP_ENTER_FADE_MS = 450;
11
+ const HEATMAP_ENTER_FADE_EASE = [0.22, 1, 0.36, 1];
12
+ const HEATMAP_WAVE_ROW_LEAN_MS = 12;
13
+ const HEATMAP_LOADING_CHART_OPACITY = 1;
14
+ const HEATMAP_DEFAULT_LOADING_CELL_MAX_OPACITY = 0.85;
15
+ const HEATMAP_DEFAULT_LOADING_CELL_RANDOMNESS = 1;
16
+ const HEATMAP_LOADING_BASE_CELL_OPACITY = 0.2;
17
+ const HEATMAP_LOADING_CONCEAL_MS = 450;
18
+ function seededRandom(seed) {
19
+ let state = seed % 2147483647;
20
+ if (state <= 0) {
21
+ state += 2147483646;
22
+ }
23
+ return () => {
24
+ state = state * 16807 % 2147483647;
25
+ return (state - 1) / 2147483646;
26
+ };
27
+ }
28
+ function heatmapCellSeed(column, row) {
29
+ return column * 1009 + row * 9176;
30
+ }
31
+ function computeHeatmapLevelRange(data) {
32
+ let min = Number.POSITIVE_INFINITY;
33
+ let max = Number.NEGATIVE_INFINITY;
34
+ for (const column of data) {
35
+ for (const bin of column.bins) {
36
+ const level = getHeatmapContributionLevel(bin.count);
37
+ if (level < min) {
38
+ min = level;
39
+ }
40
+ if (level > max) {
41
+ max = level;
42
+ }
43
+ }
44
+ }
45
+ if (!(Number.isFinite(min) && Number.isFinite(max))) {
46
+ return { min: 0, max: 4 };
47
+ }
48
+ return { min, max };
49
+ }
50
+ function isBezierTuple(ease) {
51
+ return Array.isArray(ease) && ease.length === 4 && ease.every((n) => typeof n === "number");
52
+ }
53
+ function inverseBezier([x1, y1, x2, y2]) {
54
+ return cubicBezier(y1, x1, y2, x2);
55
+ }
56
+ const defaultSweepEase = inverseBezier(
57
+ DEFAULT_CHART_ENTER_TRANSITION.ease
58
+ );
59
+ const sweepEaseCache = /* @__PURE__ */ new Map();
60
+ function resolveSweepEase(ease) {
61
+ if (ease === "linear") {
62
+ return (t) => t;
63
+ }
64
+ if (!isBezierTuple(ease)) {
65
+ return defaultSweepEase;
66
+ }
67
+ const key = ease.join(",");
68
+ let fn = sweepEaseCache.get(key);
69
+ if (!fn) {
70
+ fn = inverseBezier(ease);
71
+ sweepEaseCache.set(key, fn);
72
+ }
73
+ return fn;
74
+ }
75
+ function resolveHeatmapWaveTiming({
76
+ animationDurationMs,
77
+ enterTransition,
78
+ enterStaggerScale,
79
+ columnCount,
80
+ rowCount
81
+ }) {
82
+ const sweep = clipRevealTransition(enterTransition);
83
+ const durationSec = enterTransition && typeof sweep.duration === "number" ? sweep.duration : animationDurationMs / 1e3;
84
+ const scale = Math.max(0, enterStaggerScale);
85
+ const sweepMs = Math.max(0, durationSec * 1e3) * scale;
86
+ const rowLeanMs = HEATMAP_WAVE_ROW_LEAN_MS * scale;
87
+ const fadeMs = HEATMAP_ENTER_FADE_MS;
88
+ return {
89
+ fadeMs,
90
+ fadeEasing: `cubic-bezier(${HEATMAP_ENTER_FADE_EASE.join(", ")})`,
91
+ sweepMs,
92
+ sweepEase: resolveSweepEase(sweep.ease),
93
+ rowLeanMs,
94
+ columnCount,
95
+ totalMs: sweepMs + rowLeanMs * Math.max(0, rowCount - 1) + fadeMs
96
+ };
97
+ }
98
+ function heatmapWaveDelayMs(column, row, timing) {
99
+ const t = timing.columnCount > 1 ? Math.min(1, Math.max(0, column / (timing.columnCount - 1))) : 0;
100
+ return timing.sweepEase(t) * timing.sweepMs + row * timing.rowLeanMs;
101
+ }
102
+ function heatmapLoadingCellParticipates(column, row, randomness) {
103
+ if (randomness >= 1) {
104
+ return true;
105
+ }
106
+ if (randomness <= 0) {
107
+ return false;
108
+ }
109
+ const random = seededRandom(heatmapCellSeed(column, row) + 73133);
110
+ return random() < randomness;
111
+ }
112
+ export {
113
+ HEATMAP_DEFAULT_ENTER_DURATION_MS,
114
+ HEATMAP_DEFAULT_ENTER_TRANSITION,
115
+ HEATMAP_DEFAULT_LOADING_CELL_MAX_OPACITY,
116
+ HEATMAP_DEFAULT_LOADING_CELL_RANDOMNESS,
117
+ HEATMAP_ENTER_FADE_EASE,
118
+ HEATMAP_ENTER_FADE_MS,
119
+ HEATMAP_LOADING_BASE_CELL_OPACITY,
120
+ HEATMAP_LOADING_CHART_OPACITY,
121
+ HEATMAP_LOADING_CONCEAL_MS,
122
+ HEATMAP_WAVE_ROW_LEAN_MS,
123
+ computeHeatmapLevelRange,
124
+ heatmapCellSeed,
125
+ heatmapLoadingCellParticipates,
126
+ heatmapWaveDelayMs,
127
+ resolveHeatmapWaveTiming
128
+ };