@lobehub/charts 5.6.0 → 5.7.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 (404) hide show
  1. package/es/AccuracyBarChart/index.d.mts +62 -0
  2. package/es/AccuracyBarChart/index.mjs +326 -0
  3. package/es/AccuracyBarChart/index.mjs.map +1 -0
  4. package/es/AccuracyBarChart/styles.d.mts +14 -0
  5. package/es/AccuracyBarChart/styles.mjs +71 -0
  6. package/es/AccuracyBarChart/styles.mjs.map +1 -0
  7. package/es/AreaChart/index.d.mts +13 -0
  8. package/es/AreaChart/index.mjs +308 -0
  9. package/es/AreaChart/index.mjs.map +1 -0
  10. package/es/AreaChart/styles.d.mts +9 -0
  11. package/es/AreaChart/styles.mjs +28 -0
  12. package/es/AreaChart/styles.mjs.map +1 -0
  13. package/es/BarChart/index.d.mts +11 -0
  14. package/es/BarChart/index.mjs +290 -0
  15. package/es/BarChart/index.mjs.map +1 -0
  16. package/es/BarChart/{renderShape.d.ts → renderShape.d.mts} +3 -1
  17. package/es/BarChart/renderShape.mjs +28 -0
  18. package/es/BarChart/renderShape.mjs.map +1 -0
  19. package/es/BarChart/styles.d.mts +9 -0
  20. package/es/BarChart/styles.mjs +28 -0
  21. package/es/BarChart/styles.mjs.map +1 -0
  22. package/es/BarList/index.d.mts +32 -0
  23. package/es/BarList/index.mjs +128 -0
  24. package/es/BarList/index.mjs.map +1 -0
  25. package/es/BarList/styles.d.mts +13 -0
  26. package/es/BarList/styles.mjs +63 -0
  27. package/es/BarList/styles.mjs.map +1 -0
  28. package/es/BenchmarkColumnChart/index.d.mts +144 -0
  29. package/es/BenchmarkColumnChart/index.mjs +514 -0
  30. package/es/BenchmarkColumnChart/index.mjs.map +1 -0
  31. package/es/BenchmarkColumnChart/styles.d.mts +19 -0
  32. package/es/BenchmarkColumnChart/styles.mjs +129 -0
  33. package/es/BenchmarkColumnChart/styles.mjs.map +1 -0
  34. package/es/BenchmarkRankingChart/index.d.mts +91 -0
  35. package/es/BenchmarkRankingChart/index.mjs +347 -0
  36. package/es/BenchmarkRankingChart/index.mjs.map +1 -0
  37. package/es/BenchmarkRankingChart/styles.d.mts +36 -0
  38. package/es/BenchmarkRankingChart/styles.mjs +265 -0
  39. package/es/BenchmarkRankingChart/styles.mjs.map +1 -0
  40. package/es/BenchmarkScatterChart/index.d.mts +148 -0
  41. package/es/BenchmarkScatterChart/index.mjs +668 -0
  42. package/es/BenchmarkScatterChart/index.mjs.map +1 -0
  43. package/es/BenchmarkScatterChart/styles.d.mts +28 -0
  44. package/es/BenchmarkScatterChart/styles.mjs +193 -0
  45. package/es/BenchmarkScatterChart/styles.mjs.map +1 -0
  46. package/es/BenchmarkScatterChart/{utils.d.ts → utils.d.mts} +32 -29
  47. package/es/BenchmarkScatterChart/utils.mjs +214 -0
  48. package/es/BenchmarkScatterChart/utils.mjs.map +1 -0
  49. package/es/ComposedChart/index.d.mts +6 -0
  50. package/es/ComposedChart/index.mjs +254 -0
  51. package/es/ComposedChart/index.mjs.map +1 -0
  52. package/es/ComposedChart/styles.d.mts +9 -0
  53. package/es/ComposedChart/styles.mjs +28 -0
  54. package/es/ComposedChart/styles.mjs.map +1 -0
  55. package/es/ComposedChart/types.d.mts +71 -0
  56. package/es/ComposedChart/types.mjs +0 -0
  57. package/es/DataBars/CategoryBar.d.mts +17 -0
  58. package/es/DataBars/CategoryBar.mjs +146 -0
  59. package/es/DataBars/CategoryBar.mjs.map +1 -0
  60. package/es/DataBars/DeltaBar.d.mts +16 -0
  61. package/es/DataBars/DeltaBar.mjs +102 -0
  62. package/es/DataBars/DeltaBar.mjs.map +1 -0
  63. package/es/DataBars/MarkerBar.d.mts +19 -0
  64. package/es/DataBars/MarkerBar.mjs +74 -0
  65. package/es/DataBars/MarkerBar.mjs.map +1 -0
  66. package/es/DataBars/ProgressBar.d.mts +15 -0
  67. package/es/DataBars/ProgressBar.mjs +53 -0
  68. package/es/DataBars/ProgressBar.mjs.map +1 -0
  69. package/es/DataBars/index.d.mts +5 -0
  70. package/es/DataBars/index.mjs +5 -0
  71. package/es/DataBars/styles.d.mts +10 -0
  72. package/es/DataBars/styles.mjs +31 -0
  73. package/es/DataBars/styles.mjs.map +1 -0
  74. package/es/DonutChart/DonutChartTooltip.d.mts +14 -0
  75. package/es/DonutChart/DonutChartTooltip.mjs +25 -0
  76. package/es/DonutChart/DonutChartTooltip.mjs.map +1 -0
  77. package/es/DonutChart/index.d.mts +33 -0
  78. package/es/DonutChart/index.mjs +160 -0
  79. package/es/DonutChart/index.mjs.map +1 -0
  80. package/es/DonutChart/inputParser.d.mts +5 -0
  81. package/es/DonutChart/inputParser.mjs +8 -0
  82. package/es/DonutChart/inputParser.mjs.map +1 -0
  83. package/es/DonutChart/renderInactiveShape.d.mts +4 -0
  84. package/es/DonutChart/renderInactiveShape.mjs +22 -0
  85. package/es/DonutChart/renderInactiveShape.mjs.map +1 -0
  86. package/es/DonutChart/styles.d.mts +9 -0
  87. package/es/DonutChart/styles.mjs +28 -0
  88. package/es/DonutChart/styles.mjs.map +1 -0
  89. package/es/FunnelChart/ArrowRightIcon.d.mts +8 -0
  90. package/es/FunnelChart/ArrowRightIcon.mjs +14 -0
  91. package/es/FunnelChart/ArrowRightIcon.mjs.map +1 -0
  92. package/es/FunnelChart/index.d.mts +21 -0
  93. package/es/FunnelChart/index.mjs +421 -0
  94. package/es/FunnelChart/index.mjs.map +1 -0
  95. package/es/FunnelChart/styles.d.mts +9 -0
  96. package/es/FunnelChart/styles.mjs +28 -0
  97. package/es/FunnelChart/styles.mjs.map +1 -0
  98. package/es/FunnelChart/types.d.mts +31 -0
  99. package/es/FunnelChart/types.mjs +0 -0
  100. package/es/Heatmaps/Calendar.d.mts +21 -0
  101. package/es/Heatmaps/Calendar.mjs +108 -0
  102. package/es/Heatmaps/Calendar.mjs.map +1 -0
  103. package/es/Heatmaps/ChartLabels.d.mts +17 -0
  104. package/es/Heatmaps/ChartLabels.mjs +84 -0
  105. package/es/Heatmaps/ChartLabels.mjs.map +1 -0
  106. package/es/Heatmaps/Footer.d.mts +24 -0
  107. package/es/Heatmaps/Footer.mjs +81 -0
  108. package/es/Heatmaps/Footer.mjs.map +1 -0
  109. package/es/Heatmaps/index.d.mts +31 -0
  110. package/es/Heatmaps/index.mjs +188 -0
  111. package/es/Heatmaps/index.mjs.map +1 -0
  112. package/es/Heatmaps/styles.d.mts +10 -0
  113. package/es/Heatmaps/styles.mjs +47 -0
  114. package/es/Heatmaps/styles.mjs.map +1 -0
  115. package/es/Legend/LegendItem.d.mts +12 -0
  116. package/es/Legend/LegendItem.mjs +65 -0
  117. package/es/Legend/LegendItem.mjs.map +1 -0
  118. package/es/Legend/ScrollButton.d.mts +11 -0
  119. package/es/Legend/ScrollButton.mjs +50 -0
  120. package/es/Legend/ScrollButton.mjs.map +1 -0
  121. package/es/Legend/index.d.mts +16 -0
  122. package/es/Legend/index.mjs +152 -0
  123. package/es/Legend/index.mjs.map +1 -0
  124. package/es/LineChart/index.d.mts +11 -0
  125. package/es/LineChart/index.mjs +271 -0
  126. package/es/LineChart/index.mjs.map +1 -0
  127. package/es/LineChart/styles.d.mts +9 -0
  128. package/es/LineChart/styles.mjs +28 -0
  129. package/es/LineChart/styles.mjs.map +1 -0
  130. package/es/RadarChart/index.d.mts +27 -0
  131. package/es/RadarChart/index.mjs +157 -0
  132. package/es/RadarChart/index.mjs.map +1 -0
  133. package/es/RadarChart/styles.d.mts +8 -0
  134. package/es/RadarChart/styles.mjs +23 -0
  135. package/es/RadarChart/styles.mjs.map +1 -0
  136. package/es/ScatterChart/ScatterChartTooltip.d.mts +19 -0
  137. package/es/ScatterChart/ScatterChartTooltip.mjs +52 -0
  138. package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -0
  139. package/es/ScatterChart/ScatterChartTooltipRow.d.mts +10 -0
  140. package/es/ScatterChart/ScatterChartTooltipRow.mjs +36 -0
  141. package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -0
  142. package/es/ScatterChart/index.d.mts +58 -0
  143. package/es/ScatterChart/index.mjs +241 -0
  144. package/es/ScatterChart/index.mjs.map +1 -0
  145. package/es/ScatterChart/{renderShape.d.ts → renderShape.d.mts} +4 -1
  146. package/es/ScatterChart/renderShape.mjs +18 -0
  147. package/es/ScatterChart/renderShape.mjs.map +1 -0
  148. package/es/ScatterChart/styles.d.mts +9 -0
  149. package/es/ScatterChart/styles.mjs +28 -0
  150. package/es/ScatterChart/styles.mjs.map +1 -0
  151. package/es/SparkChart/SparkAreaChart.d.mts +14 -0
  152. package/es/SparkChart/SparkAreaChart.mjs +109 -0
  153. package/es/SparkChart/SparkAreaChart.mjs.map +1 -0
  154. package/es/SparkChart/SparkBarChart.d.mts +11 -0
  155. package/es/SparkChart/SparkBarChart.mjs +69 -0
  156. package/es/SparkChart/SparkBarChart.mjs.map +1 -0
  157. package/es/SparkChart/SparkLineChart.d.mts +12 -0
  158. package/es/SparkChart/SparkLineChart.mjs +73 -0
  159. package/es/SparkChart/SparkLineChart.mjs.map +1 -0
  160. package/es/SparkChart/index.d.mts +4 -0
  161. package/es/SparkChart/index.mjs +4 -0
  162. package/es/Tracker/TrackerBlock.d.mts +11 -0
  163. package/es/Tracker/TrackerBlock.mjs +52 -0
  164. package/es/Tracker/TrackerBlock.mjs.map +1 -0
  165. package/es/Tracker/index.d.mts +21 -0
  166. package/es/Tracker/index.mjs +69 -0
  167. package/es/Tracker/index.mjs.map +1 -0
  168. package/es/Tracker/styles.d.mts +8 -0
  169. package/es/Tracker/styles.mjs +24 -0
  170. package/es/Tracker/styles.mjs.map +1 -0
  171. package/es/common/BaseAnimationTimingProps.d.mts +10 -0
  172. package/es/common/BaseAnimationTimingProps.mjs +0 -0
  173. package/es/common/BaseChartProps.d.mts +61 -0
  174. package/es/common/BaseChartProps.mjs +0 -0
  175. package/es/common/BaseSparkChartProps.d.mts +17 -0
  176. package/es/common/BaseSparkChartProps.mjs +0 -0
  177. package/es/common/ChartLegend.d.mts +8 -0
  178. package/es/common/ChartLegend.mjs +32 -0
  179. package/es/common/ChartLegend.mjs.map +1 -0
  180. package/es/common/ChartTooltip/ChartTooltipFrame.d.mts +8 -0
  181. package/es/common/ChartTooltip/ChartTooltipFrame.mjs +27 -0
  182. package/es/common/ChartTooltip/ChartTooltipFrame.mjs.map +1 -0
  183. package/es/common/ChartTooltip/ChartTooltipRow.d.mts +10 -0
  184. package/es/common/ChartTooltip/ChartTooltipRow.mjs +51 -0
  185. package/es/common/ChartTooltip/ChartTooltipRow.mjs.map +1 -0
  186. package/es/common/ChartTooltip/index.d.mts +18 -0
  187. package/es/common/ChartTooltip/index.mjs +50 -0
  188. package/es/common/ChartTooltip/index.mjs.map +1 -0
  189. package/es/common/CustomTooltipProps.d.mts +15 -0
  190. package/es/common/CustomTooltipProps.mjs +0 -0
  191. package/es/common/CustomYAxisTick.d.mts +18 -0
  192. package/es/common/CustomYAxisTick.mjs +24 -0
  193. package/es/common/CustomYAxisTick.mjs.map +1 -0
  194. package/es/common/NoData.d.mts +13 -0
  195. package/es/common/NoData.mjs +25 -0
  196. package/es/common/NoData.mjs.map +1 -0
  197. package/es/common/benchmark/index.d.mts +3 -0
  198. package/es/common/benchmark/{index.js → index.mjs} +1 -1
  199. package/es/common/benchmark/types.d.mts +125 -0
  200. package/es/common/benchmark/types.mjs +0 -0
  201. package/es/common/benchmark/{utils.d.ts → utils.d.mts} +38 -36
  202. package/es/common/benchmark/utils.mjs +115 -0
  203. package/es/common/benchmark/utils.mjs.map +1 -0
  204. package/es/common/{utils.d.ts → utils.d.mts} +3 -0
  205. package/es/common/utils.mjs +36 -0
  206. package/es/common/utils.mjs.map +1 -0
  207. package/es/hooks/useOnWindowResize.d.mts +6 -0
  208. package/es/hooks/useOnWindowResize.mjs +18 -0
  209. package/es/hooks/useOnWindowResize.mjs.map +1 -0
  210. package/es/hooks/usePrefersReducedMotion.d.mts +4 -0
  211. package/es/hooks/usePrefersReducedMotion.mjs +24 -0
  212. package/es/hooks/usePrefersReducedMotion.mjs.map +1 -0
  213. package/es/hooks/useThemeColorRange.d.mts +4 -0
  214. package/es/hooks/useThemeColorRange.mjs +28 -0
  215. package/es/hooks/useThemeColorRange.mjs.map +1 -0
  216. package/es/index.d.mts +34 -0
  217. package/es/index.mjs +28 -0
  218. package/es/types/{charts.d.ts → charts.d.mts} +26 -26
  219. package/es/types/charts.mjs +12 -0
  220. package/es/types/charts.mjs.map +1 -0
  221. package/es/utils/{calendar.d.ts → calendar.d.mts} +21 -18
  222. package/es/utils/calendar.mjs +154 -0
  223. package/es/utils/calendar.mjs.map +1 -0
  224. package/es/utils/getMaxLabelLength.d.mts +13 -0
  225. package/es/utils/getMaxLabelLength.mjs +48 -0
  226. package/es/utils/getMaxLabelLength.mjs.map +1 -0
  227. package/es/utils/{index.d.ts → index.d.mts} +4 -1
  228. package/es/utils/index.mjs +19 -0
  229. package/es/utils/index.mjs.map +1 -0
  230. package/es/utils/{theme.d.ts → theme.d.mts} +3 -0
  231. package/es/utils/theme.mjs +33 -0
  232. package/es/utils/theme.mjs.map +1 -0
  233. package/package.json +23 -5
  234. package/es/AccuracyBarChart/index.d.ts +0 -60
  235. package/es/AccuracyBarChart/index.js +0 -454
  236. package/es/AccuracyBarChart/index.mdx +0 -52
  237. package/es/AccuracyBarChart/styles.d.ts +0 -11
  238. package/es/AccuracyBarChart/styles.js +0 -18
  239. package/es/AreaChart/index.d.ts +0 -11
  240. package/es/AreaChart/index.js +0 -430
  241. package/es/AreaChart/index.mdx +0 -49
  242. package/es/AreaChart/styles.d.ts +0 -6
  243. package/es/AreaChart/styles.js +0 -13
  244. package/es/BarChart/index.d.ts +0 -9
  245. package/es/BarChart/index.js +0 -392
  246. package/es/BarChart/index.mdx +0 -73
  247. package/es/BarChart/renderShape.js +0 -34
  248. package/es/BarChart/styles.d.ts +0 -6
  249. package/es/BarChart/styles.js +0 -13
  250. package/es/BarList/index.d.ts +0 -29
  251. package/es/BarList/index.js +0 -174
  252. package/es/BarList/index.mdx +0 -34
  253. package/es/BarList/styles.d.ts +0 -10
  254. package/es/BarList/styles.js +0 -18
  255. package/es/BenchmarkColumnChart/index.d.ts +0 -140
  256. package/es/BenchmarkColumnChart/index.js +0 -686
  257. package/es/BenchmarkColumnChart/index.mdx +0 -66
  258. package/es/BenchmarkColumnChart/styles.d.ts +0 -16
  259. package/es/BenchmarkColumnChart/styles.js +0 -23
  260. package/es/BenchmarkRankingChart/index.d.ts +0 -87
  261. package/es/BenchmarkRankingChart/index.js +0 -448
  262. package/es/BenchmarkRankingChart/index.mdx +0 -59
  263. package/es/BenchmarkRankingChart/styles.d.ts +0 -33
  264. package/es/BenchmarkRankingChart/styles.js +0 -41
  265. package/es/BenchmarkScatterChart/index.d.ts +0 -145
  266. package/es/BenchmarkScatterChart/index.js +0 -850
  267. package/es/BenchmarkScatterChart/index.mdx +0 -61
  268. package/es/BenchmarkScatterChart/styles.d.ts +0 -25
  269. package/es/BenchmarkScatterChart/styles.js +0 -33
  270. package/es/BenchmarkScatterChart/utils.js +0 -353
  271. package/es/ComposedChart/index.d.ts +0 -5
  272. package/es/ComposedChart/index.js +0 -335
  273. package/es/ComposedChart/index.mdx +0 -43
  274. package/es/ComposedChart/styles.d.ts +0 -6
  275. package/es/ComposedChart/styles.js +0 -13
  276. package/es/ComposedChart/types.d.ts +0 -68
  277. package/es/ComposedChart/types.js +0 -1
  278. package/es/DataBars/CategoryBar.d.ts +0 -15
  279. package/es/DataBars/CategoryBar.js +0 -200
  280. package/es/DataBars/DeltaBar.d.ts +0 -13
  281. package/es/DataBars/DeltaBar.js +0 -116
  282. package/es/DataBars/MarkerBar.d.ts +0 -16
  283. package/es/DataBars/MarkerBar.js +0 -93
  284. package/es/DataBars/ProgressBar.d.ts +0 -12
  285. package/es/DataBars/ProgressBar.js +0 -70
  286. package/es/DataBars/index.d.ts +0 -4
  287. package/es/DataBars/index.js +0 -4
  288. package/es/DataBars/index.mdx +0 -36
  289. package/es/DataBars/styles.d.ts +0 -7
  290. package/es/DataBars/styles.js +0 -14
  291. package/es/DonutChart/DonutChartTooltip.d.ts +0 -11
  292. package/es/DonutChart/DonutChartTooltip.js +0 -26
  293. package/es/DonutChart/index.d.ts +0 -31
  294. package/es/DonutChart/index.js +0 -232
  295. package/es/DonutChart/index.mdx +0 -48
  296. package/es/DonutChart/inputParser.d.ts +0 -2
  297. package/es/DonutChart/inputParser.js +0 -9
  298. package/es/DonutChart/renderInactiveShape.d.ts +0 -2
  299. package/es/DonutChart/renderInactiveShape.js +0 -27
  300. package/es/DonutChart/styles.d.ts +0 -6
  301. package/es/DonutChart/styles.js +0 -13
  302. package/es/FunnelChart/ArrowRightIcon.d.ts +0 -5
  303. package/es/FunnelChart/ArrowRightIcon.js +0 -22
  304. package/es/FunnelChart/index.d.ts +0 -19
  305. package/es/FunnelChart/index.js +0 -499
  306. package/es/FunnelChart/index.mdx +0 -21
  307. package/es/FunnelChart/styles.d.ts +0 -6
  308. package/es/FunnelChart/styles.js +0 -13
  309. package/es/FunnelChart/types.d.ts +0 -28
  310. package/es/FunnelChart/types.js +0 -1
  311. package/es/Heatmaps/Calendar.d.ts +0 -18
  312. package/es/Heatmaps/Calendar.js +0 -155
  313. package/es/Heatmaps/ChartLabels.d.ts +0 -15
  314. package/es/Heatmaps/ChartLabels.js +0 -106
  315. package/es/Heatmaps/Footer.d.ts +0 -22
  316. package/es/Heatmaps/Footer.js +0 -105
  317. package/es/Heatmaps/index.d.ts +0 -28
  318. package/es/Heatmaps/index.js +0 -226
  319. package/es/Heatmaps/index.mdx +0 -70
  320. package/es/Heatmaps/styles.d.ts +0 -7
  321. package/es/Heatmaps/styles.js +0 -14
  322. package/es/Legend/LegendItem.d.ts +0 -10
  323. package/es/Legend/LegendItem.js +0 -58
  324. package/es/Legend/ScrollButton.d.ts +0 -9
  325. package/es/Legend/ScrollButton.js +0 -63
  326. package/es/Legend/index.d.ts +0 -14
  327. package/es/Legend/index.js +0 -184
  328. package/es/Legend/index.mdx +0 -13
  329. package/es/LineChart/index.d.ts +0 -9
  330. package/es/LineChart/index.js +0 -388
  331. package/es/LineChart/index.mdx +0 -49
  332. package/es/LineChart/styles.d.ts +0 -6
  333. package/es/LineChart/styles.js +0 -13
  334. package/es/RadarChart/index.d.ts +0 -24
  335. package/es/RadarChart/index.js +0 -254
  336. package/es/RadarChart/index.mdx +0 -52
  337. package/es/RadarChart/styles.d.ts +0 -5
  338. package/es/RadarChart/styles.js +0 -12
  339. package/es/ScatterChart/ScatterChartTooltip.d.ts +0 -16
  340. package/es/ScatterChart/ScatterChartTooltip.js +0 -76
  341. package/es/ScatterChart/ScatterChartTooltipRow.d.ts +0 -7
  342. package/es/ScatterChart/ScatterChartTooltipRow.js +0 -40
  343. package/es/ScatterChart/index.d.ts +0 -56
  344. package/es/ScatterChart/index.js +0 -342
  345. package/es/ScatterChart/index.mdx +0 -49
  346. package/es/ScatterChart/renderShape.js +0 -18
  347. package/es/ScatterChart/styles.d.ts +0 -6
  348. package/es/ScatterChart/styles.js +0 -13
  349. package/es/SparkChart/SparkAreaChart.d.ts +0 -12
  350. package/es/SparkChart/SparkAreaChart.js +0 -148
  351. package/es/SparkChart/SparkBarChart.d.ts +0 -9
  352. package/es/SparkChart/SparkBarChart.js +0 -106
  353. package/es/SparkChart/SparkLineChart.d.ts +0 -10
  354. package/es/SparkChart/SparkLineChart.js +0 -110
  355. package/es/SparkChart/index.d.ts +0 -3
  356. package/es/SparkChart/index.js +0 -3
  357. package/es/SparkChart/index.mdx +0 -29
  358. package/es/Tracker/TrackerBlock.d.ts +0 -8
  359. package/es/Tracker/TrackerBlock.js +0 -63
  360. package/es/Tracker/index.d.ts +0 -18
  361. package/es/Tracker/index.js +0 -104
  362. package/es/Tracker/index.mdx +0 -41
  363. package/es/Tracker/styles.d.ts +0 -5
  364. package/es/Tracker/styles.js +0 -12
  365. package/es/common/BaseAnimationTimingProps.d.ts +0 -7
  366. package/es/common/BaseAnimationTimingProps.js +0 -1
  367. package/es/common/BaseChartProps.d.ts +0 -58
  368. package/es/common/BaseChartProps.js +0 -1
  369. package/es/common/BaseSparkChartProps.d.ts +0 -14
  370. package/es/common/BaseSparkChartProps.js +0 -1
  371. package/es/common/ChartLegend.d.ts +0 -5
  372. package/es/common/ChartLegend.js +0 -40
  373. package/es/common/ChartTooltip/ChartTooltipFrame.d.ts +0 -6
  374. package/es/common/ChartTooltip/ChartTooltipFrame.js +0 -32
  375. package/es/common/ChartTooltip/ChartTooltipRow.d.ts +0 -8
  376. package/es/common/ChartTooltip/ChartTooltipRow.js +0 -55
  377. package/es/common/ChartTooltip/index.d.ts +0 -15
  378. package/es/common/ChartTooltip/index.js +0 -66
  379. package/es/common/CustomTooltipProps.d.ts +0 -12
  380. package/es/common/CustomTooltipProps.js +0 -1
  381. package/es/common/CustomYAxisTick.d.ts +0 -15
  382. package/es/common/CustomYAxisTick.js +0 -27
  383. package/es/common/NoData.d.ts +0 -10
  384. package/es/common/NoData.js +0 -41
  385. package/es/common/benchmark/index.d.ts +0 -2
  386. package/es/common/benchmark/types.d.ts +0 -122
  387. package/es/common/benchmark/types.js +0 -1
  388. package/es/common/benchmark/utils.js +0 -159
  389. package/es/common/utils.js +0 -85
  390. package/es/hooks/useOnWindowResize.d.ts +0 -3
  391. package/es/hooks/useOnWindowResize.js +0 -15
  392. package/es/hooks/usePrefersReducedMotion.d.ts +0 -1
  393. package/es/hooks/usePrefersReducedMotion.js +0 -28
  394. package/es/hooks/useThemeColorRange.d.ts +0 -1
  395. package/es/hooks/useThemeColorRange.js +0 -8
  396. package/es/index.d.ts +0 -24
  397. package/es/index.js +0 -22
  398. package/es/types/charts.js +0 -8
  399. package/es/types/global.d.ts +0 -9
  400. package/es/utils/calendar.js +0 -199
  401. package/es/utils/getMaxLabelLength.d.ts +0 -10
  402. package/es/utils/getMaxLabelLength.js +0 -110
  403. package/es/utils/index.js +0 -32
  404. package/es/utils/theme.js +0 -40
@@ -0,0 +1,36 @@
1
+ //#region src/common/utils.ts
2
+ const constructCategoryColors = (categories, colors) => {
3
+ const categoryColors = /* @__PURE__ */ new Map();
4
+ for (const [idx, category] of categories.entries()) categoryColors.set(category, colors[idx % colors.length]);
5
+ return categoryColors;
6
+ };
7
+ const getYAxisDomain = (autoMinValue, minValue, maxValue) => {
8
+ return [autoMinValue ? "auto" : minValue ?? 0, maxValue ?? "auto"];
9
+ };
10
+ const constructCategories = (data, color) => {
11
+ if (!color) return [];
12
+ const categories = /* @__PURE__ */ new Set();
13
+ for (const datum of data) categories.add(datum[color]);
14
+ return [...categories];
15
+ };
16
+ const deepEqual = (obj1, obj2) => {
17
+ if (obj1 === obj2) return true;
18
+ if (typeof obj1 !== "object" || typeof obj2 !== "object" || obj1 === null || obj2 === null) return false;
19
+ const keys1 = Object.keys(obj1);
20
+ const keys2 = Object.keys(obj2);
21
+ if (keys1.length !== keys2.length) return false;
22
+ for (const key of keys1) if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;
23
+ return true;
24
+ };
25
+ const hasOnlyOneValueForThisKey = (array, keyToCheck) => {
26
+ const val = [];
27
+ for (const obj of array) if (Object.prototype.hasOwnProperty.call(obj, keyToCheck)) {
28
+ val.push(obj[keyToCheck]);
29
+ if (val.length > 1) return false;
30
+ }
31
+ return true;
32
+ };
33
+ //#endregion
34
+ export { constructCategories, constructCategoryColors, deepEqual, getYAxisDomain, hasOnlyOneValueForThisKey };
35
+
36
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../src/common/utils.ts"],"sourcesContent":["export const constructCategoryColors = (\n categories: string[],\n colors: string[],\n): Map<string, string> => {\n const categoryColors = new Map<string, string>();\n for (const [idx, category] of categories.entries()) {\n categoryColors.set(category, colors[idx % colors.length]);\n }\n return categoryColors;\n};\n\nexport const getYAxisDomain = (\n autoMinValue: boolean,\n minValue: number | undefined,\n maxValue: number | undefined,\n) => {\n return [autoMinValue ? 'auto' : (minValue ?? 0), maxValue ?? 'auto'];\n};\n\nexport const constructCategories = (data: any[], color?: string): string[] => {\n if (!color) {\n return [];\n }\n\n const categories = new Set<string>();\n for (const datum of data) {\n categories.add(datum[color]);\n }\n return [...categories];\n};\n\nexport const deepEqual = (obj1: any, obj2: any) => {\n if (obj1 === obj2) return true;\n\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null)\n return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) return false;\n }\n\n return true;\n};\n\nexport const hasOnlyOneValueForThisKey = (array: any[], keyToCheck: string) => {\n const val = [];\n\n for (const obj of array) {\n if (Object.prototype.hasOwnProperty.call(obj, keyToCheck)) {\n val.push(obj[keyToCheck]);\n if (val.length > 1) {\n return false;\n }\n }\n }\n\n return true;\n};\n"],"mappings":";AAAA,MAAa,2BACX,YACA,WACwB;CACxB,MAAM,iCAAiB,IAAI,IAAoB;CAC/C,KAAK,MAAM,CAAC,KAAK,aAAa,WAAW,QAAQ,GAC/C,eAAe,IAAI,UAAU,OAAO,MAAM,OAAO,OAAO;CAE1D,OAAO;AACT;AAEA,MAAa,kBACX,cACA,UACA,aACG;CACH,OAAO,CAAC,eAAe,SAAU,YAAY,GAAI,YAAY,MAAM;AACrE;AAEA,MAAa,uBAAuB,MAAa,UAA6B;CAC5E,IAAI,CAAC,OACH,OAAO,CAAC;CAGV,MAAM,6BAAa,IAAI,IAAY;CACnC,KAAK,MAAM,SAAS,MAClB,WAAW,IAAI,MAAM,MAAM;CAE7B,OAAO,CAAC,GAAG,UAAU;AACvB;AAEA,MAAa,aAAa,MAAW,SAAc;CACjD,IAAI,SAAS,MAAM,OAAO;CAE1B,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY,SAAS,QAAQ,SAAS,MACpF,OAAO;CAET,MAAM,QAAQ,OAAO,KAAK,IAAI;CAC9B,MAAM,QAAQ,OAAO,KAAK,IAAI;CAE9B,IAAI,MAAM,WAAW,MAAM,QAAQ,OAAO;CAE1C,KAAK,MAAM,OAAO,OAChB,IAAI,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,KAAK,MAAM,KAAK,IAAI,GAAG,OAAO;CAGvE,OAAO;AACT;AAEA,MAAa,6BAA6B,OAAc,eAAuB;CAC7E,MAAM,MAAM,CAAC;CAEb,KAAK,MAAM,OAAO,OAChB,IAAI,OAAO,UAAU,eAAe,KAAK,KAAK,UAAU,GAAG;EACzD,IAAI,KAAK,IAAI,WAAW;EACxB,IAAI,IAAI,SAAS,GACf,OAAO;CAEX;CAGF,OAAO;AACT"}
@@ -0,0 +1,6 @@
1
+ //#region src/hooks/useOnWindowResize.d.ts
2
+ export declare const useOnWindowResize: (handler: {
3
+ (): void;
4
+ }) => void;
5
+ //#endregion
6
+ //# sourceMappingURL=useOnWindowResize.d.mts.map
@@ -0,0 +1,18 @@
1
+ import { isOnSeverSide } from "../utils/index.mjs";
2
+ import { useEffect } from "react";
3
+ //#region src/hooks/useOnWindowResize.ts
4
+ const useOnWindowResize = (handler) => {
5
+ useEffect(() => {
6
+ if (isOnSeverSide) return;
7
+ const handleResize = () => {
8
+ handler();
9
+ };
10
+ handleResize();
11
+ window.addEventListener("resize", handleResize);
12
+ return () => window.removeEventListener("resize", handleResize);
13
+ }, [handler]);
14
+ };
15
+ //#endregion
16
+ export { useOnWindowResize };
17
+
18
+ //# sourceMappingURL=useOnWindowResize.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnWindowResize.mjs","names":[],"sources":["../../src/hooks/useOnWindowResize.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { isOnSeverSide } from '@/utils';\n\nexport const useOnWindowResize = (handler: { (): void }) => {\n useEffect(() => {\n if (isOnSeverSide) return;\n const handleResize = () => {\n handler();\n };\n handleResize();\n window.addEventListener('resize', handleResize);\n\n return () => window.removeEventListener('resize', handleResize);\n }, [handler]);\n};\n"],"mappings":";;;AAIA,MAAa,qBAAqB,YAA0B;CAC1D,gBAAgB;EACd,IAAI,eAAe;EACnB,MAAM,qBAAqB;GACzB,QAAQ;EACV;EACA,aAAa;EACb,OAAO,iBAAiB,UAAU,YAAY;EAE9C,aAAa,OAAO,oBAAoB,UAAU,YAAY;CAChE,GAAG,CAAC,OAAO,CAAC;AACd"}
@@ -0,0 +1,4 @@
1
+ //#region src/hooks/usePrefersReducedMotion.d.ts
2
+ export declare const usePrefersReducedMotion: () => boolean;
3
+ //#endregion
4
+ //# sourceMappingURL=usePrefersReducedMotion.d.mts.map
@@ -0,0 +1,24 @@
1
+ import { isOnSeverSide } from "../utils/index.mjs";
2
+ import { useEffect, useState } from "react";
3
+ //#region src/hooks/usePrefersReducedMotion.ts
4
+ const query = "(prefers-reduced-motion: reduce)";
5
+ const usePrefersReducedMotion = () => {
6
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(true);
7
+ useEffect(() => {
8
+ if (isOnSeverSide) return;
9
+ const mediaQuery = window.matchMedia(query);
10
+ setPrefersReducedMotion(mediaQuery.matches);
11
+ const onChange = (event) => {
12
+ setPrefersReducedMotion(event.matches);
13
+ };
14
+ mediaQuery.addEventListener("change", onChange);
15
+ return () => {
16
+ mediaQuery.removeEventListener("change", onChange);
17
+ };
18
+ }, []);
19
+ return prefersReducedMotion;
20
+ };
21
+ //#endregion
22
+ export { usePrefersReducedMotion };
23
+
24
+ //# sourceMappingURL=usePrefersReducedMotion.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrefersReducedMotion.mjs","names":[],"sources":["../../src/hooks/usePrefersReducedMotion.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { isOnSeverSide } from '@/utils';\n\nconst query = '(prefers-reduced-motion: reduce)';\n\nexport const usePrefersReducedMotion = () => {\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(true);\n\n useEffect(() => {\n if (isOnSeverSide) return;\n const mediaQuery = window.matchMedia(query);\n setPrefersReducedMotion(mediaQuery.matches);\n\n const onChange = (event: MediaQueryListEvent) => {\n setPrefersReducedMotion(event.matches);\n };\n\n mediaQuery.addEventListener('change', onChange);\n\n return () => {\n mediaQuery.removeEventListener('change', onChange);\n };\n }, []);\n\n return prefersReducedMotion;\n};\n"],"mappings":";;;AAIA,MAAM,QAAQ;AAEd,MAAa,gCAAgC;CAC3C,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,IAAI;CAErE,gBAAgB;EACd,IAAI,eAAe;EACnB,MAAM,aAAa,OAAO,WAAW,KAAK;EAC1C,wBAAwB,WAAW,OAAO;EAE1C,MAAM,YAAY,UAA+B;GAC/C,wBAAwB,MAAM,OAAO;EACvC;EAEA,WAAW,iBAAiB,UAAU,QAAQ;EAE9C,aAAa;GACX,WAAW,oBAAoB,UAAU,QAAQ;EACnD;CACF,GAAG,CAAC,CAAC;CAEL,OAAO;AACT"}
@@ -0,0 +1,4 @@
1
+ //#region src/hooks/useThemeColorRange.d.ts
2
+ export declare const useThemeColorRange: () => any[];
3
+ //#endregion
4
+ //# sourceMappingURL=useThemeColorRange.d.mts.map
@@ -0,0 +1,28 @@
1
+ import { useTheme } from "antd-style";
2
+ import { useMemo } from "react";
3
+ //#region src/hooks/useThemeColorRange.ts
4
+ const useThemeColorRange = () => {
5
+ const theme = useTheme();
6
+ return useMemo(() => [
7
+ theme.geekblue,
8
+ theme.gold,
9
+ theme.green,
10
+ theme.cyan,
11
+ theme.purple,
12
+ theme.red,
13
+ theme.volcano,
14
+ theme.gray,
15
+ theme.geekblue7,
16
+ theme.gold7,
17
+ theme.green7,
18
+ theme.cyan7,
19
+ theme.purple7,
20
+ theme.red7,
21
+ theme.volcano7,
22
+ theme.gray7
23
+ ], [theme]);
24
+ };
25
+ //#endregion
26
+ export { useThemeColorRange };
27
+
28
+ //# sourceMappingURL=useThemeColorRange.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useThemeColorRange.mjs","names":[],"sources":["../../src/hooks/useThemeColorRange.ts"],"sourcesContent":["import { useTheme } from 'antd-style';\nimport { useMemo } from 'react';\n\nexport const useThemeColorRange = () => {\n const theme = useTheme();\n\n return useMemo(\n () => [\n theme.geekblue,\n theme.gold,\n theme.green,\n theme.cyan,\n theme.purple,\n theme.red,\n theme.volcano,\n theme.gray,\n theme.geekblue7,\n theme.gold7,\n theme.green7,\n theme.cyan7,\n theme.purple7,\n theme.red7,\n theme.volcano7,\n theme.gray7,\n ],\n [theme],\n );\n};\n"],"mappings":";;;AAGA,MAAa,2BAA2B;CACtC,MAAM,QAAQ,SAAS;CAEvB,OAAO,cACC;EACJ,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;EACN,MAAM;CACR,GACA,CAAC,KAAK,CACR;AACF"}
package/es/index.d.mts ADDED
@@ -0,0 +1,34 @@
1
+ import { Activity, BlockElement, CurveType, DeltaType, DeltaTypes, EventHandlerMap, EventProps, Interval, IntervalType, LabelFormatter, Labels, ReactEvent, SVGRectEventHandler, ScatterChartValueFormatter, ValueFormatter, Week } from "./types/charts.mjs";
2
+ import ScatterChart, { ScatterChartProps } from "./ScatterChart/index.mjs";
3
+ import AccuracyBarChart, { AccuracyBarChartProps } from "./AccuracyBarChart/index.mjs";
4
+ import AreaChart, { AreaChartProps } from "./AreaChart/index.mjs";
5
+ import BarChart, { BarChartProps } from "./BarChart/index.mjs";
6
+ import BarList, { Bar, BarListProps } from "./BarList/index.mjs";
7
+ import { BenchmarkEventProps, BenchmarkFieldKeys, BenchmarkPointShape, BenchmarkRecord, BenchmarkRenderIcon } from "./common/benchmark/types.mjs";
8
+ import "./common/benchmark/index.mjs";
9
+ import BenchmarkColumnChart, { BenchmarkColumnChartProps } from "./BenchmarkColumnChart/index.mjs";
10
+ import BenchmarkRankingChart, { BenchmarkRankingChartProps } from "./BenchmarkRankingChart/index.mjs";
11
+ import BenchmarkScatterChart, { BenchmarkScatterChartProps, BenchmarkScatterMetric } from "./BenchmarkScatterChart/index.mjs";
12
+ import { ComposedChartProps, SeriesItem, YAxisConfig } from "./ComposedChart/types.mjs";
13
+ import ComposedChart from "./ComposedChart/index.mjs";
14
+ import CategoryBar, { CategoryBarProps } from "./DataBars/CategoryBar.mjs";
15
+ import DeltaBar, { DeltaBarProps } from "./DataBars/DeltaBar.mjs";
16
+ import MarkerBar, { MarkerBarProps } from "./DataBars/MarkerBar.mjs";
17
+ import ProgressBar, { ProgressBarProps } from "./DataBars/ProgressBar.mjs";
18
+ import "./DataBars/index.mjs";
19
+ import DonutChart, { DonutChartProps } from "./DonutChart/index.mjs";
20
+ import FunnelChart, { FunnelChartProps } from "./FunnelChart/index.mjs";
21
+ import Heatmaps, { HeatmapsProps } from "./Heatmaps/index.mjs";
22
+ import Legend, { LegendProps } from "./Legend/index.mjs";
23
+ import LineChart, { LineChartProps } from "./LineChart/index.mjs";
24
+ import RadarChart, { RadarChartProps } from "./RadarChart/index.mjs";
25
+ import SparkAreaChart, { SparkAreaChartProps } from "./SparkChart/SparkAreaChart.mjs";
26
+ import SparkBarChart, { SparkBarChartProps } from "./SparkChart/SparkBarChart.mjs";
27
+ import SparkLineChart, { SparkLineChartProps } from "./SparkChart/SparkLineChart.mjs";
28
+ import "./SparkChart/index.mjs";
29
+ import Tracker, { TrackerProps } from "./Tracker/index.mjs";
30
+ import { ChartTooltipFrame } from "./common/ChartTooltip/ChartTooltipFrame.mjs";
31
+ import ChartTooltipRow from "./common/ChartTooltip/ChartTooltipRow.mjs";
32
+ import ChartTooltip, { ChartTooltipProps } from "./common/ChartTooltip/index.mjs";
33
+ import { useThemeColorRange } from "./hooks/useThemeColorRange.mjs";
34
+ export { AccuracyBarChart, type AccuracyBarChartProps, type Activity, AreaChart, type AreaChartProps, type Bar, BarChart, type BarChartProps, BarList, type BarListProps, BenchmarkColumnChart, type BenchmarkColumnChartProps, type BenchmarkEventProps, type BenchmarkFieldKeys, type BenchmarkPointShape, BenchmarkRankingChart, type BenchmarkRankingChartProps, type BenchmarkRecord, type BenchmarkRenderIcon, BenchmarkScatterChart, type BenchmarkScatterChartProps, type BenchmarkScatterMetric, type BlockElement, CategoryBar, type CategoryBarProps, ChartTooltip, ChartTooltipFrame, type ChartTooltipProps, ChartTooltipRow, ComposedChart, type ComposedChartProps, type CurveType, DeltaBar, type DeltaBarProps, type DeltaType, type DeltaTypes, DonutChart, type DonutChartProps, type EventHandlerMap, type EventProps, FunnelChart, type FunnelChartProps, Heatmaps, type HeatmapsProps, type Interval, type IntervalType, type LabelFormatter, type Labels, Legend, type LegendProps, LineChart, type LineChartProps, MarkerBar, type MarkerBarProps, ProgressBar, type ProgressBarProps, RadarChart, type RadarChartProps, type ReactEvent, type SVGRectEventHandler, ScatterChart, type ScatterChartProps, type ScatterChartValueFormatter, type SeriesItem, SparkAreaChart, type SparkAreaChartProps, SparkBarChart, type SparkBarChartProps, SparkLineChart, type SparkLineChartProps, Tracker, type TrackerProps, type ValueFormatter, type Week, type YAxisConfig, useThemeColorRange };
package/es/index.mjs ADDED
@@ -0,0 +1,28 @@
1
+ import { useThemeColorRange } from "./hooks/useThemeColorRange.mjs";
2
+ import Legend from "./Legend/index.mjs";
3
+ import { ChartTooltipFrame } from "./common/ChartTooltip/ChartTooltipFrame.mjs";
4
+ import ChartTooltipRow from "./common/ChartTooltip/ChartTooltipRow.mjs";
5
+ import ChartTooltip from "./common/ChartTooltip/index.mjs";
6
+ import AccuracyBarChart from "./AccuracyBarChart/index.mjs";
7
+ import AreaChart from "./AreaChart/index.mjs";
8
+ import BarChart from "./BarChart/index.mjs";
9
+ import BarList from "./BarList/index.mjs";
10
+ import BenchmarkColumnChart from "./BenchmarkColumnChart/index.mjs";
11
+ import BenchmarkRankingChart from "./BenchmarkRankingChart/index.mjs";
12
+ import BenchmarkScatterChart from "./BenchmarkScatterChart/index.mjs";
13
+ import ComposedChart from "./ComposedChart/index.mjs";
14
+ import CategoryBar from "./DataBars/CategoryBar.mjs";
15
+ import DeltaBar from "./DataBars/DeltaBar.mjs";
16
+ import MarkerBar from "./DataBars/MarkerBar.mjs";
17
+ import ProgressBar from "./DataBars/ProgressBar.mjs";
18
+ import DonutChart from "./DonutChart/index.mjs";
19
+ import FunnelChart from "./FunnelChart/index.mjs";
20
+ import Heatmaps from "./Heatmaps/index.mjs";
21
+ import LineChart from "./LineChart/index.mjs";
22
+ import RadarChart from "./RadarChart/index.mjs";
23
+ import ScatterChart from "./ScatterChart/index.mjs";
24
+ import SparkAreaChart from "./SparkChart/SparkAreaChart.mjs";
25
+ import SparkBarChart from "./SparkChart/SparkBarChart.mjs";
26
+ import SparkLineChart from "./SparkChart/SparkLineChart.mjs";
27
+ import Tracker from "./Tracker/index.mjs";
28
+ export { AccuracyBarChart, AreaChart, BarChart, BarList, BenchmarkColumnChart, BenchmarkRankingChart, BenchmarkScatterChart, CategoryBar, ChartTooltip, ChartTooltipFrame, ChartTooltipRow, ComposedChart, DeltaBar, DonutChart, FunnelChart, Heatmaps, Legend, LineChart, MarkerBar, ProgressBar, RadarChart, ScatterChart, SparkAreaChart, SparkBarChart, SparkLineChart, Tracker, useThemeColorRange };
@@ -1,53 +1,53 @@
1
- import type { AnimationEvent, ClipboardEvent, CompositionEvent, DOMAttributes, DragEvent, FocusEvent, FormEvent, HTMLAttributes, JSXElementConstructor, KeyboardEvent, MouseEvent, PointerEvent, ReactElement, SVGAttributes, SyntheticEvent, TouchEvent, TransitionEvent, UIEvent, WheelEvent } from 'react';
1
+ import { AnimationEvent, ClipboardEvent, CompositionEvent, DOMAttributes, DragEvent, FocusEvent, FormEvent, HTMLAttributes, JSXElementConstructor, KeyboardEvent, MouseEvent, PointerEvent, ReactElement, SVGAttributes, SyntheticEvent, TouchEvent, TransitionEvent, UIEvent, WheelEvent } from "react";
2
+ //#region src/types/charts.d.ts
2
3
  export interface Activity {
3
- count: number;
4
- date: string;
5
- level: number;
4
+ count: number;
5
+ date: string;
6
+ level: number;
6
7
  }
7
8
  export type Week = Array<Activity | undefined>;
8
9
  export type Labels = Partial<{
9
- legend: Partial<{
10
- less: string;
11
- more: string;
12
- }>;
13
- months: Array<string>;
14
- tooltip: string;
15
- totalCount: string;
16
- weekdays: Array<string>;
10
+ legend: Partial<{
11
+ less: string;
12
+ more: string;
13
+ }>;
14
+ months: Array<string>;
15
+ tooltip: string;
16
+ totalCount: string;
17
+ weekdays: Array<string>;
17
18
  }>;
18
- interface BlockAttributes extends SVGAttributes<SVGRectElement>, HTMLAttributes<SVGRectElement> {
19
- }
19
+ interface BlockAttributes extends SVGAttributes<SVGRectElement>, HTMLAttributes<SVGRectElement> {}
20
20
  export type BlockElement = ReactElement<BlockAttributes, JSXElementConstructor<SVGRectElement>>;
21
21
  export type SVGRectEventHandler = Omit<DOMAttributes<SVGRectElement>, 'css' | 'children' | 'dangerouslySetInnerHTML'>;
22
- export type EventHandlerMap = {
23
- [key in keyof SVGRectEventHandler]: (...event: Parameters<NonNullable<SVGRectEventHandler[keyof SVGRectEventHandler]>>) => (activity: Activity) => void;
24
- };
22
+ export type EventHandlerMap = { [key in keyof SVGRectEventHandler]: (...event: Parameters<NonNullable<SVGRectEventHandler[keyof SVGRectEventHandler]>>) => (activity: Activity) => void; };
25
23
  export type ReactEvent<E extends Element> = AnimationEvent<E> & ClipboardEvent<E> & CompositionEvent<E> & DragEvent<E> & FocusEvent<E> & FormEvent<E> & KeyboardEvent<E> & MouseEvent<E> & PointerEvent<E> & SyntheticEvent<E> & TouchEvent<E> & TransitionEvent<E> & UIEvent<E> & WheelEvent<E>;
26
24
  type FixedProps = {
27
- categoryClicked: string;
28
- eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';
25
+ categoryClicked: string;
26
+ eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';
29
27
  };
30
28
  type BaseEventProps = FixedProps & {
31
- [key: string]: number | string;
29
+ [key: string]: number | string;
32
30
  };
33
31
  export type EventProps = BaseEventProps | null | undefined;
34
32
  export type Interval = 'preserveStartEnd' | 'equidistantPreserveStart';
35
33
  export type IntervalType = 'preserveStartEnd' | Interval;
36
34
  export type CurveType = 'linear' | 'natural' | 'monotone' | 'step';
37
35
  export type ValueFormatter = {
38
- (value: number): string;
36
+ (value: number): string;
39
37
  };
40
38
  export type LabelFormatter = {
41
- (value: number | string): string;
39
+ (value: number | string): string;
42
40
  };
43
41
  export type ScatterChartValueFormatter = {
44
- size?: ValueFormatter;
45
- x?: ValueFormatter;
46
- y?: ValueFormatter;
42
+ size?: ValueFormatter;
43
+ x?: ValueFormatter;
44
+ y?: ValueFormatter;
47
45
  };
48
46
  declare const deltaTypeValues: readonly ["increase", "moderateIncrease", "decrease", "moderateDecrease", "unchanged"];
49
47
  export type DeltaType = (typeof deltaTypeValues)[number];
50
48
  export declare const DeltaTypes: {
51
- [key: string]: DeltaType;
49
+ [key: string]: DeltaType;
52
50
  };
51
+ //#endregion
53
52
  export {};
53
+ //# sourceMappingURL=charts.d.mts.map
@@ -0,0 +1,12 @@
1
+ //#region src/types/charts.ts
2
+ const DeltaTypes = {
3
+ Decrease: "decrease",
4
+ Increase: "increase",
5
+ ModerateDecrease: "moderateDecrease",
6
+ ModerateIncrease: "moderateIncrease",
7
+ Unchanged: "unchanged"
8
+ };
9
+ //#endregion
10
+ export { DeltaTypes };
11
+
12
+ //# sourceMappingURL=charts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"charts.mjs","names":[],"sources":["../../src/types/charts.ts"],"sourcesContent":["import type {\n AnimationEvent,\n ClipboardEvent,\n CompositionEvent,\n DOMAttributes,\n DragEvent,\n FocusEvent,\n FormEvent,\n HTMLAttributes,\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n PointerEvent,\n ReactElement,\n SVGAttributes,\n SyntheticEvent,\n TouchEvent,\n TransitionEvent,\n UIEvent,\n WheelEvent,\n} from 'react';\n\nexport interface Activity {\n count: number;\n date: string;\n level: number;\n}\n\nexport type Week = Array<Activity | undefined>;\n\nexport type Labels = Partial<{\n legend: Partial<{\n less: string;\n more: string;\n }>;\n months: Array<string>;\n tooltip: string;\n totalCount: string;\n weekdays: Array<string>;\n}>;\n\ninterface BlockAttributes extends SVGAttributes<SVGRectElement>, HTMLAttributes<SVGRectElement> {}\n\nexport type BlockElement = ReactElement<BlockAttributes, JSXElementConstructor<SVGRectElement>>;\n\nexport type SVGRectEventHandler = Omit<\n DOMAttributes<SVGRectElement>,\n 'css' | 'children' | 'dangerouslySetInnerHTML'\n>;\n\nexport type EventHandlerMap = {\n [key in keyof SVGRectEventHandler]: (\n ...event: Parameters<NonNullable<SVGRectEventHandler[keyof SVGRectEventHandler]>>\n ) => (activity: Activity) => void;\n};\n\nexport type ReactEvent<E extends Element> = AnimationEvent<E> &\n ClipboardEvent<E> &\n CompositionEvent<E> &\n DragEvent<E> &\n FocusEvent<E> &\n FormEvent<E> &\n KeyboardEvent<E> &\n MouseEvent<E> &\n PointerEvent<E> &\n SyntheticEvent<E> &\n TouchEvent<E> &\n TransitionEvent<E> &\n UIEvent<E> &\n WheelEvent<E>;\n\ntype FixedProps = {\n categoryClicked: string;\n eventType: 'dot' | 'category' | 'bar' | 'slice' | 'bubble';\n};\n\ntype BaseEventProps = FixedProps & {\n [key: string]: number | string;\n};\n\nexport type EventProps = BaseEventProps | null | undefined;\n\nexport type Interval = 'preserveStartEnd' | 'equidistantPreserveStart';\n\nexport type IntervalType = 'preserveStartEnd' | Interval;\n\nexport type CurveType = 'linear' | 'natural' | 'monotone' | 'step';\n\nexport type ValueFormatter = {\n (value: number): string;\n};\n\nexport type LabelFormatter = {\n (value: number | string): string;\n};\n\nexport type ScatterChartValueFormatter = {\n size?: ValueFormatter;\n x?: ValueFormatter;\n y?: ValueFormatter;\n};\n\nconst deltaTypeValues = [\n 'increase',\n 'moderateIncrease',\n 'decrease',\n 'moderateDecrease',\n 'unchanged',\n] as const;\n\nexport type DeltaType = (typeof deltaTypeValues)[number];\n\nexport const DeltaTypes: { [key: string]: DeltaType } = {\n Decrease: 'decrease',\n Increase: 'increase',\n ModerateDecrease: 'moderateDecrease',\n ModerateIncrease: 'moderateIncrease',\n Unchanged: 'unchanged',\n};\n"],"mappings":";AAgHA,MAAa,aAA2C;CACtD,UAAU;CACV,UAAU;CACV,kBAAkB;CAClB,kBAAkB;CAClB,WAAW;AACb"}
@@ -1,29 +1,32 @@
1
- import type { Day as WeekDay } from 'date-fns';
2
- import type { Activity, Week } from "../types/charts";
1
+ import { Activity, Week } from "../types/charts.mjs";
2
+ import { Day } from "date-fns";
3
+ //#region src/utils/calendar.d.ts
3
4
  export declare const DEFAULT_MONTH_LABELS: string[];
4
5
  export declare const DEFAULT_LABELS: {
5
- legend: {
6
- less: string;
7
- more: string;
8
- };
9
- months: string[];
10
- tooltip: string;
11
- totalCount: string;
12
- weekdays: string[];
6
+ legend: {
7
+ less: string;
8
+ more: string;
9
+ };
10
+ months: string[];
11
+ tooltip: string;
12
+ totalCount: string;
13
+ weekdays: string[];
13
14
  };
14
15
  interface MonthLabel {
15
- label: string;
16
- weekIndex: number;
16
+ label: string;
17
+ weekIndex: number;
17
18
  }
18
- export declare const groupByWeeks: (activities: Array<Activity>, weekStart?: WeekDay) => Array<Week>;
19
+ export declare const groupByWeeks: (activities: Array<Activity>, weekStart?: Day) => Array<Week>;
19
20
  export declare const getMonthLabels: (weeks: Array<Week>, monthNames?: Array<string>) => Array<MonthLabel>;
20
21
  export declare const generateEmptyData: () => Array<Activity>;
21
22
  export declare const generateTestData: (args: {
22
- interval?: {
23
- end: Date;
24
- start: Date;
25
- };
26
- maxLevel?: number;
23
+ interval?: {
24
+ end: Date;
25
+ start: Date;
26
+ };
27
+ maxLevel?: number;
27
28
  }) => Array<Activity>;
28
29
  export declare const maxWeekdayLabelLength: (firstWeek: Week, weekStart: number, labels: string[], fontSize: number) => number;
30
+ //#endregion
29
31
  export {};
32
+ //# sourceMappingURL=calendar.d.mts.map
@@ -0,0 +1,154 @@
1
+ import { isOnSeverSide } from "./index.mjs";
2
+ import { differenceInCalendarDays, eachDayOfInterval, endOfYear, formatISO, getDay, getMonth, nextDay, parseISO, startOfYear, subWeeks } from "date-fns";
3
+ //#region src/utils/calendar.ts
4
+ const DEFAULT_MONTH_LABELS = [
5
+ "Jan",
6
+ "Feb",
7
+ "Mar",
8
+ "Apr",
9
+ "May",
10
+ "Jun",
11
+ "Jul",
12
+ "Aug",
13
+ "Sep",
14
+ "Oct",
15
+ "Nov",
16
+ "Dec"
17
+ ];
18
+ const DEFAULT_LABELS = {
19
+ legend: {
20
+ less: "Less",
21
+ more: "More"
22
+ },
23
+ months: DEFAULT_MONTH_LABELS,
24
+ tooltip: "{{count}} activities on {{date}}",
25
+ totalCount: "{{count}} activities in {{year}}",
26
+ weekdays: [
27
+ "Sun",
28
+ "Mon",
29
+ "Tue",
30
+ "Wed",
31
+ "Thu",
32
+ "Fri",
33
+ "Sat"
34
+ ]
35
+ };
36
+ const fillHoles = (activities) => {
37
+ if (activities.length === 0) return [];
38
+ const calendar = new Map(activities.map((a) => [a.date, a]));
39
+ const firstActivity = activities[0];
40
+ const lastActivity = activities.at(-1);
41
+ return eachDayOfInterval({
42
+ end: parseISO(lastActivity.date),
43
+ start: parseISO(firstActivity.date)
44
+ }).map((day) => {
45
+ const date = formatISO(day, { representation: "date" });
46
+ if (calendar.has(date)) return calendar.get(date);
47
+ return {
48
+ count: 0,
49
+ date,
50
+ level: 0
51
+ };
52
+ });
53
+ };
54
+ const calcTextDimensions = (text, fontSize) => {
55
+ if (isOnSeverSide) return;
56
+ if (fontSize < 1) throw new RangeError("fontSize must be positive");
57
+ if (text.length === 0) return {
58
+ height: 0,
59
+ width: 0
60
+ };
61
+ const namespace = "http://www.w3.org/2000/svg";
62
+ const svg = document.createElementNS(namespace, "svg");
63
+ svg.style.position = "absolute";
64
+ svg.style.visibility = "hidden";
65
+ svg.style.fontFamily = window.getComputedStyle(document.body).fontFamily;
66
+ svg.style.fontSize = `${fontSize}px`;
67
+ const textNode = document.createElementNS(namespace, "text");
68
+ textNode.textContent = text;
69
+ svg.append(textNode);
70
+ document.body.append(svg);
71
+ const boundingBox = textNode.getBBox();
72
+ svg.remove();
73
+ return {
74
+ height: boundingBox.height,
75
+ width: boundingBox.width
76
+ };
77
+ };
78
+ const groupByWeeks = (activities, weekStart = 0) => {
79
+ if (activities.length === 0) return [];
80
+ const normalizedActivities = fillHoles(activities);
81
+ const firstActivity = normalizedActivities[0];
82
+ const firstDate = parseISO(firstActivity.date);
83
+ const firstCalendarDate = getDay(firstDate) === weekStart ? firstDate : subWeeks(nextDay(firstDate, weekStart), 1);
84
+ const paddedActivities = [...Array.from({ length: differenceInCalendarDays(firstDate, firstCalendarDate) }).fill(null), ...normalizedActivities];
85
+ const numberOfWeeks = Math.ceil(paddedActivities.length / 7);
86
+ return Array.from({ length: numberOfWeeks }).fill(null).map((_, weekIndex) => paddedActivities.slice(weekIndex * 7, weekIndex * 7 + 7));
87
+ };
88
+ const getMonthLabels = (weeks, monthNames = DEFAULT_MONTH_LABELS) => {
89
+ return weeks.reduce((labels, week, weekIndex) => {
90
+ const firstActivity = week.filter(Boolean).find((activity) => activity !== void 0);
91
+ if (!firstActivity) throw new Error(`Unexpected error: Week ${weekIndex + 1} is empty: [${week}].`);
92
+ const month = monthNames[getMonth(parseISO(firstActivity.date))];
93
+ if (!month) {
94
+ const monthName = new Date(firstActivity.date).toLocaleString("en-US", { month: "short" });
95
+ throw new Error(`Unexpected error: undefined month label for ${monthName}.`);
96
+ }
97
+ const prevLabel = labels.at(-1);
98
+ if (weekIndex === 0 || !prevLabel || prevLabel.label !== month) return [...labels, {
99
+ label: month,
100
+ weekIndex
101
+ }];
102
+ return labels;
103
+ }, []).filter(({ weekIndex }, index, labels) => {
104
+ const minWeeks = 3;
105
+ if (index === 0) return labels[1] && labels[1].weekIndex - weekIndex >= minWeeks;
106
+ if (index === labels.length - 1) return weeks.slice(weekIndex).length >= minWeeks;
107
+ return true;
108
+ });
109
+ };
110
+ const generateEmptyData = () => {
111
+ const year = (/* @__PURE__ */ new Date()).getFullYear();
112
+ return eachDayOfInterval({
113
+ end: new Date(year, 11, 31),
114
+ start: new Date(year, 0, 1)
115
+ }).map((date) => ({
116
+ count: 0,
117
+ date: formatISO(date, { representation: "date" }),
118
+ level: 0
119
+ }));
120
+ };
121
+ const generateTestData = (args) => {
122
+ const maxCount = 20;
123
+ const maxLevel = args.maxLevel ? Math.max(1, args.maxLevel) : 4;
124
+ const now = /* @__PURE__ */ new Date();
125
+ return eachDayOfInterval(args.interval ?? {
126
+ end: endOfYear(now),
127
+ start: startOfYear(now)
128
+ }).map((date) => {
129
+ const c = Math.round(Math.random() * maxCount - Math.random() * (.8 * maxCount));
130
+ const count = Math.max(0, c);
131
+ const level = Math.ceil(count / maxCount * maxLevel);
132
+ return {
133
+ count,
134
+ date: formatISO(date, { representation: "date" }),
135
+ level
136
+ };
137
+ });
138
+ };
139
+ const maxWeekdayLabelLength = (firstWeek, weekStart, labels, fontSize) => {
140
+ if (isOnSeverSide) return 0;
141
+ if (labels.length !== 7) throw new Error("Exactly 7 labels, one for each weekday must be passed.");
142
+ return firstWeek.reduce((maxLength, _, index) => {
143
+ if (index % 2 !== 0) {
144
+ const label = labels[(index + weekStart) % 7];
145
+ const curLength = Math.ceil(calcTextDimensions(label, fontSize).width);
146
+ return Math.max(maxLength, curLength);
147
+ }
148
+ return maxLength;
149
+ }, 0);
150
+ };
151
+ //#endregion
152
+ export { DEFAULT_LABELS, DEFAULT_MONTH_LABELS, generateEmptyData, generateTestData, getMonthLabels, groupByWeeks, maxWeekdayLabelLength };
153
+
154
+ //# sourceMappingURL=calendar.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.mjs","names":[],"sources":["../../src/utils/calendar.ts"],"sourcesContent":["import type { Day as WeekDay } from 'date-fns';\nimport {\n differenceInCalendarDays,\n eachDayOfInterval,\n endOfYear,\n formatISO,\n getDay,\n getMonth,\n nextDay,\n parseISO,\n startOfYear,\n subWeeks,\n} from 'date-fns';\n\nimport type { Activity, Week } from '@/types/charts';\nimport { isOnSeverSide } from '@/utils/index';\n\nexport const DEFAULT_MONTH_LABELS = [\n 'Jan',\n 'Feb',\n 'Mar',\n 'Apr',\n 'May',\n 'Jun',\n 'Jul',\n 'Aug',\n 'Sep',\n 'Oct',\n 'Nov',\n 'Dec',\n];\n\nexport const DEFAULT_LABELS = {\n legend: {\n less: 'Less',\n more: 'More',\n },\n months: DEFAULT_MONTH_LABELS,\n tooltip: '{{count}} activities on {{date}}',\n totalCount: '{{count}} activities in {{year}}',\n weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n};\n\ninterface MonthLabel {\n label: string;\n weekIndex: number;\n}\n\nconst fillHoles = (activities: Array<Activity>): Array<Activity> => {\n if (activities.length === 0) {\n return [];\n }\n\n const calendar = new Map<string, Activity>(activities.map((a) => [a.date, a]));\n const firstActivity = activities[0] as Activity;\n const lastActivity = activities.at(-1) as Activity;\n\n return eachDayOfInterval({\n end: parseISO(lastActivity.date),\n start: parseISO(firstActivity.date),\n }).map((day) => {\n const date = formatISO(day, { representation: 'date' });\n\n if (calendar.has(date)) {\n return calendar.get(date) as Activity;\n }\n\n return {\n count: 0,\n date,\n level: 0,\n };\n });\n};\n\nconst calcTextDimensions = (text: string, fontSize: number) => {\n if (isOnSeverSide) return;\n\n if (fontSize < 1) {\n throw new RangeError('fontSize must be positive');\n }\n\n if (text.length === 0) {\n return { height: 0, width: 0 };\n }\n\n const namespace = 'http://www.w3.org/2000/svg';\n const svg = document.createElementNS(namespace, 'svg');\n\n svg.style.position = 'absolute';\n svg.style.visibility = 'hidden';\n svg.style.fontFamily = window.getComputedStyle(document.body).fontFamily;\n svg.style.fontSize = `${fontSize}px`;\n\n const textNode = document.createElementNS(namespace, 'text');\n textNode.textContent = text;\n\n svg.append(textNode);\n document.body.append(svg);\n const boundingBox = textNode.getBBox();\n\n svg.remove();\n\n return { height: boundingBox.height, width: boundingBox.width };\n};\n\nexport const groupByWeeks = (\n activities: Array<Activity>,\n weekStart: WeekDay = 0, // 0 = Sunday\n): Array<Week> => {\n if (activities.length === 0) {\n return [];\n }\n\n const normalizedActivities = fillHoles(activities);\n\n // Determine the first date of the calendar. If the first date is not the\n // set start weekday, the selected weekday one week earlier is used.\n const firstActivity = normalizedActivities[0] as Activity;\n const firstDate = parseISO(firstActivity.date);\n const firstCalendarDate =\n getDay(firstDate) === weekStart ? firstDate : subWeeks(nextDay(firstDate, weekStart), 1);\n\n // To correctly group activities by week, it is necessary to left-pad the list\n // because the first date might not be set start weekday.\n const paddedActivities = [\n ...(Array.from({ length: differenceInCalendarDays(firstDate, firstCalendarDate) }).fill(\n null,\n ) as Array<Activity>),\n ...normalizedActivities,\n ];\n\n const numberOfWeeks = Math.ceil(paddedActivities.length / 7);\n\n // Finally, group activities by week\n return Array.from({ length: numberOfWeeks })\n .fill(null)\n .map((_, weekIndex) => paddedActivities.slice(weekIndex * 7, weekIndex * 7 + 7));\n};\n\nexport const getMonthLabels = (\n weeks: Array<Week>,\n monthNames: Array<string> = DEFAULT_MONTH_LABELS,\n): Array<MonthLabel> => {\n return weeks\n .reduce<Array<MonthLabel>>((labels, week, weekIndex) => {\n const firstActivity = week.filter(Boolean).find((activity) => activity !== undefined);\n\n if (!firstActivity) {\n throw new Error(`Unexpected error: Week ${weekIndex + 1} is empty: [${week}].`);\n }\n\n const month = monthNames[getMonth(parseISO(firstActivity.date))];\n\n if (!month) {\n const monthName = new Date(firstActivity.date).toLocaleString('en-US', { month: 'short' });\n throw new Error(`Unexpected error: undefined month label for ${monthName}.`);\n }\n\n const prevLabel = labels.at(-1);\n\n if (weekIndex === 0 || !prevLabel || prevLabel.label !== month) {\n return [...labels, { label: month, weekIndex }];\n }\n\n return labels;\n }, [])\n .filter(({ weekIndex }, index, labels) => {\n // Labels should only be shown if there is \"enough\" space (data).\n // This is a naive implementation that does not take the block size,\n // font size, etc. into account.\n const minWeeks = 3;\n\n // Skip the first month label if there is not enough space to the next one.\n if (index === 0) {\n return labels[1] && labels[1].weekIndex - weekIndex >= minWeeks;\n }\n\n // Skip the last month label if there is not enough data in that month\n // to avoid overflowing the calendar on the right.\n if (index === labels.length - 1) {\n return weeks.slice(weekIndex).length >= minWeeks;\n }\n\n return true;\n });\n};\n\nexport const generateEmptyData = (): Array<Activity> => {\n const year = new Date().getFullYear();\n const days = eachDayOfInterval({\n end: new Date(year, 11, 31),\n start: new Date(year, 0, 1),\n });\n\n return days.map((date) => ({\n count: 0,\n date: formatISO(date, { representation: 'date' }),\n level: 0,\n }));\n};\n\nexport const generateTestData = (args: {\n interval?: { end: Date; start: Date };\n maxLevel?: number;\n}): Array<Activity> => {\n const maxCount = 20;\n const maxLevel = args.maxLevel ? Math.max(1, args.maxLevel) : 4;\n const now = new Date();\n\n const days = eachDayOfInterval(\n args.interval ?? {\n end: endOfYear(now),\n start: startOfYear(now),\n },\n );\n\n return days.map((date) => {\n // The random activity count is shifted by up to 80% towards zero.\n const c = Math.round(Math.random() * maxCount - Math.random() * (0.8 * maxCount));\n const count = Math.max(0, c);\n const level = Math.ceil((count / maxCount) * maxLevel);\n\n return {\n count,\n date: formatISO(date, { representation: 'date' }),\n level,\n };\n });\n};\n\nexport const maxWeekdayLabelLength = (\n firstWeek: Week,\n weekStart: number,\n labels: string[],\n fontSize: number,\n): number => {\n if (isOnSeverSide) return 0;\n if (labels.length !== 7) {\n throw new Error('Exactly 7 labels, one for each weekday must be passed.');\n }\n\n return firstWeek.reduce((maxLength, _, index) => {\n if (index % 2 !== 0) {\n const dayIndex = (index + weekStart) % 7;\n const label = labels[dayIndex] as string;\n // @ts-ignore\n const curLength = Math.ceil(calcTextDimensions(label, fontSize).width);\n\n return Math.max(maxLength, curLength);\n }\n\n return maxLength;\n }, 0);\n};\n"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ import { ValueFormatter } from "../types/charts.mjs";
2
+ //#region src/utils/getMaxLabelLength.d.ts
3
+ export declare const getTextWidth: (text: string) => number;
4
+ export declare const getMaxLabelLength: ({ data, valueFormatter, index, layout, margin, isScatterChart }: {
5
+ data: Array<Record<string, any>>;
6
+ index: string;
7
+ isScatterChart?: boolean;
8
+ layout?: "vertical" | "horizontal";
9
+ margin?: number;
10
+ valueFormatter?: ValueFormatter;
11
+ }) => number;
12
+ //#endregion
13
+ //# sourceMappingURL=getMaxLabelLength.d.mts.map
@@ -0,0 +1,48 @@
1
+ import { defaultValueFormatter, isOnSeverSide } from "./index.mjs";
2
+ //#region src/utils/getMaxLabelLength.ts
3
+ const getTextWidth = (text) => {
4
+ if (isOnSeverSide) return 0;
5
+ const span = document.createElement("span");
6
+ span.style.fontSize = "12px";
7
+ span.style.position = "absolute";
8
+ span.style.visibility = "hidden";
9
+ span.style.whiteSpace = "nowrap";
10
+ span.textContent = text;
11
+ document.body.append(span);
12
+ const width = span.getBoundingClientRect().width;
13
+ span.remove();
14
+ return width;
15
+ };
16
+ const getMaxLabelLength = ({ data, valueFormatter = defaultValueFormatter, index, layout = "horizontal", margin = 24, isScatterChart }) => {
17
+ let maxLength = 0;
18
+ let maxLabel = "";
19
+ if (isScatterChart) for (const item of data) {
20
+ const formattedValue = valueFormatter(item[index]);
21
+ if (formattedValue.length > maxLength) {
22
+ maxLength = formattedValue.length;
23
+ maxLabel = formattedValue;
24
+ }
25
+ }
26
+ else if (layout === "vertical") {
27
+ for (const item of data) if (item[index].length > maxLength) {
28
+ maxLength = item[index].length;
29
+ maxLabel = item[index];
30
+ }
31
+ } else for (const item of data) {
32
+ const categories = Object.keys(item).filter((key) => key !== index);
33
+ for (const category of categories) {
34
+ const value = item[category];
35
+ if (value === void 0) continue;
36
+ const formattedValue = valueFormatter(value);
37
+ if (formattedValue.length > maxLength) {
38
+ maxLength = formattedValue.length;
39
+ maxLabel = formattedValue;
40
+ }
41
+ }
42
+ }
43
+ return getTextWidth(maxLabel) + margin;
44
+ };
45
+ //#endregion
46
+ export { getMaxLabelLength, getTextWidth };
47
+
48
+ //# sourceMappingURL=getMaxLabelLength.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMaxLabelLength.mjs","names":[],"sources":["../../src/utils/getMaxLabelLength.ts"],"sourcesContent":["import { ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter, isOnSeverSide } from '@/utils/index';\n\nexport const getTextWidth = (text: string) => {\n if (isOnSeverSide) return 0;\n\n // 创建临时 span 元素\n const span = document.createElement('span');\n\n // 设置样式使其不可见\n span.style.fontSize = '12px';\n span.style.position = 'absolute';\n span.style.visibility = 'hidden';\n span.style.whiteSpace = 'nowrap';\n\n // 设置文本内容\n span.textContent = text;\n\n // 添加到 body\n document.body.append(span);\n\n // 获取宽度\n const width = span.getBoundingClientRect().width;\n\n // 移除临时元素\n span.remove();\n\n return width;\n};\n\nexport const getMaxLabelLength = ({\n data,\n valueFormatter = defaultValueFormatter,\n index,\n layout = 'horizontal',\n margin = 24,\n isScatterChart,\n}: {\n data: Array<Record<string, any>>;\n index: string;\n isScatterChart?: boolean;\n layout?: 'vertical' | 'horizontal';\n margin?: number;\n valueFormatter?: ValueFormatter;\n}): number => {\n let maxLength = 0;\n let maxLabel = '';\n\n if (isScatterChart) {\n for (const item of data) {\n const formattedValue = valueFormatter(item[index]);\n if (formattedValue.length > maxLength) {\n maxLength = formattedValue.length;\n maxLabel = formattedValue;\n }\n }\n } else if (layout === 'vertical') {\n for (const item of data) {\n if (item[index].length > maxLength) {\n maxLength = item[index].length;\n maxLabel = item[index];\n }\n }\n } else {\n for (const item of data) {\n const categories = Object.keys(item).filter((key) => key !== index);\n for (const category of categories) {\n const value = item[category];\n if (value === undefined) continue; // Skip null or undefined values\n const formattedValue = valueFormatter(value);\n if (formattedValue.length > maxLength) {\n maxLength = formattedValue.length;\n maxLabel = formattedValue;\n }\n }\n }\n }\n\n return getTextWidth(maxLabel) + margin;\n};\n"],"mappings":";;AAGA,MAAa,gBAAgB,SAAiB;CAC5C,IAAI,eAAe,OAAO;CAG1B,MAAM,OAAO,SAAS,cAAc,MAAM;CAG1C,KAAK,MAAM,WAAW;CACtB,KAAK,MAAM,WAAW;CACtB,KAAK,MAAM,aAAa;CACxB,KAAK,MAAM,aAAa;CAGxB,KAAK,cAAc;CAGnB,SAAS,KAAK,OAAO,IAAI;CAGzB,MAAM,QAAQ,KAAK,sBAAsB,CAAC,CAAC;CAG3C,KAAK,OAAO;CAEZ,OAAO;AACT;AAEA,MAAa,qBAAqB,EAChC,MACA,iBAAiB,uBACjB,OACA,SAAS,cACT,SAAS,IACT,qBAQY;CACZ,IAAI,YAAY;CAChB,IAAI,WAAW;CAEf,IAAI,gBACF,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,iBAAiB,eAAe,KAAK,MAAM;EACjD,IAAI,eAAe,SAAS,WAAW;GACrC,YAAY,eAAe;GAC3B,WAAW;EACb;CACF;MACK,IAAI,WAAW,YACf;OAAA,MAAM,QAAQ,MACjB,IAAI,KAAK,MAAM,CAAC,SAAS,WAAW;GAClC,YAAY,KAAK,MAAM,CAAC;GACxB,WAAW,KAAK;EAClB;QAGF,KAAK,MAAM,QAAQ,MAAM;EACvB,MAAM,aAAa,OAAO,KAAK,IAAI,CAAC,CAAC,QAAQ,QAAQ,QAAQ,KAAK;EAClE,KAAK,MAAM,YAAY,YAAY;GACjC,MAAM,QAAQ,KAAK;GACnB,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,iBAAiB,eAAe,KAAK;GAC3C,IAAI,eAAe,SAAS,WAAW;IACrC,YAAY,eAAe;IAC3B,WAAW;GACb;EACF;CACF;CAGF,OAAO,aAAa,QAAQ,IAAI;AAClC"}
@@ -1,5 +1,8 @@
1
- import { ValueFormatter } from "../types/charts";
1
+ import { ValueFormatter } from "../types/charts.mjs";
2
+ //#region src/utils/index.d.ts
2
3
  export declare const defaultValueFormatter: ValueFormatter;
3
4
  export declare const sumNumericArray: (arr: number[]) => number;
4
5
  export declare const isOnSeverSide: boolean;
5
6
  export declare const mapInputsToDeltaType: (deltaType: string, isIncreasePositive: boolean) => string;
7
+ //#endregion
8
+ //# sourceMappingURL=index.d.mts.map