@lobehub/charts 6.0.0-beta.1 → 6.0.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/README.md +83 -72
  2. package/es/AccuracyBarChart/index.d.mts +62 -0
  3. package/es/AccuracyBarChart/index.mjs +324 -0
  4. package/es/AccuracyBarChart/index.mjs.map +1 -0
  5. package/es/AccuracyBarChart/styles.d.mts +14 -0
  6. package/es/AccuracyBarChart/styles.mjs +71 -0
  7. package/es/AccuracyBarChart/styles.mjs.map +1 -0
  8. package/es/AreaChart/index.d.mts +13 -0
  9. package/es/AreaChart/index.mjs +306 -0
  10. package/es/AreaChart/index.mjs.map +1 -0
  11. package/es/AreaChart/styles.d.mts +9 -0
  12. package/es/AreaChart/styles.mjs +28 -0
  13. package/es/AreaChart/styles.mjs.map +1 -0
  14. package/es/BarChart/index.d.mts +11 -0
  15. package/es/BarChart/index.mjs +288 -0
  16. package/es/BarChart/index.mjs.map +1 -0
  17. package/es/BarChart/{renderShape.d.ts → renderShape.d.mts} +3 -1
  18. package/es/BarChart/renderShape.mjs +28 -0
  19. package/es/BarChart/renderShape.mjs.map +1 -0
  20. package/es/BarChart/styles.d.mts +9 -0
  21. package/es/BarChart/styles.mjs +28 -0
  22. package/es/BarChart/styles.mjs.map +1 -0
  23. package/es/BarList/index.d.mts +32 -0
  24. package/es/BarList/index.mjs +126 -0
  25. package/es/BarList/index.mjs.map +1 -0
  26. package/es/BarList/styles.d.mts +13 -0
  27. package/es/BarList/styles.mjs +63 -0
  28. package/es/BarList/styles.mjs.map +1 -0
  29. package/es/BenchmarkColumnChart/index.d.mts +144 -0
  30. package/es/BenchmarkColumnChart/index.mjs +512 -0
  31. package/es/BenchmarkColumnChart/index.mjs.map +1 -0
  32. package/es/BenchmarkColumnChart/styles.d.mts +19 -0
  33. package/es/BenchmarkColumnChart/styles.mjs +129 -0
  34. package/es/BenchmarkColumnChart/styles.mjs.map +1 -0
  35. package/es/BenchmarkRankingChart/index.d.mts +91 -0
  36. package/es/BenchmarkRankingChart/index.mjs +345 -0
  37. package/es/BenchmarkRankingChart/index.mjs.map +1 -0
  38. package/es/BenchmarkRankingChart/styles.d.mts +36 -0
  39. package/es/BenchmarkRankingChart/styles.mjs +265 -0
  40. package/es/BenchmarkRankingChart/styles.mjs.map +1 -0
  41. package/es/BenchmarkScatterChart/index.d.mts +148 -0
  42. package/es/BenchmarkScatterChart/index.mjs +666 -0
  43. package/es/BenchmarkScatterChart/index.mjs.map +1 -0
  44. package/es/BenchmarkScatterChart/styles.d.mts +28 -0
  45. package/es/BenchmarkScatterChart/styles.mjs +193 -0
  46. package/es/BenchmarkScatterChart/styles.mjs.map +1 -0
  47. package/es/BenchmarkScatterChart/{utils.d.ts → utils.d.mts} +32 -29
  48. package/es/BenchmarkScatterChart/utils.mjs +214 -0
  49. package/es/BenchmarkScatterChart/utils.mjs.map +1 -0
  50. package/es/ComposedChart/index.d.mts +6 -0
  51. package/es/ComposedChart/index.mjs +252 -0
  52. package/es/ComposedChart/index.mjs.map +1 -0
  53. package/es/ComposedChart/styles.d.mts +9 -0
  54. package/es/ComposedChart/styles.mjs +28 -0
  55. package/es/ComposedChart/styles.mjs.map +1 -0
  56. package/es/ComposedChart/types.d.mts +71 -0
  57. package/es/ComposedChart/types.mjs +0 -0
  58. package/es/DataBars/CategoryBar.d.mts +17 -0
  59. package/es/DataBars/CategoryBar.mjs +144 -0
  60. package/es/DataBars/CategoryBar.mjs.map +1 -0
  61. package/es/DataBars/DeltaBar.d.mts +16 -0
  62. package/es/DataBars/DeltaBar.mjs +100 -0
  63. package/es/DataBars/DeltaBar.mjs.map +1 -0
  64. package/es/DataBars/MarkerBar.d.mts +19 -0
  65. package/es/DataBars/MarkerBar.mjs +72 -0
  66. package/es/DataBars/MarkerBar.mjs.map +1 -0
  67. package/es/DataBars/ProgressBar.d.mts +15 -0
  68. package/es/DataBars/ProgressBar.mjs +51 -0
  69. package/es/DataBars/ProgressBar.mjs.map +1 -0
  70. package/es/DataBars/index.d.mts +5 -0
  71. package/es/DataBars/index.mjs +5 -0
  72. package/es/DataBars/styles.d.mts +10 -0
  73. package/es/DataBars/styles.mjs +31 -0
  74. package/es/DataBars/styles.mjs.map +1 -0
  75. package/es/DonutChart/DonutChartTooltip.d.mts +14 -0
  76. package/es/DonutChart/DonutChartTooltip.mjs +25 -0
  77. package/es/DonutChart/DonutChartTooltip.mjs.map +1 -0
  78. package/es/DonutChart/index.d.mts +33 -0
  79. package/es/DonutChart/index.mjs +158 -0
  80. package/es/DonutChart/index.mjs.map +1 -0
  81. package/es/DonutChart/inputParser.d.mts +5 -0
  82. package/es/DonutChart/inputParser.mjs +8 -0
  83. package/es/DonutChart/inputParser.mjs.map +1 -0
  84. package/es/DonutChart/renderInactiveShape.d.mts +4 -0
  85. package/es/DonutChart/renderInactiveShape.mjs +22 -0
  86. package/es/DonutChart/renderInactiveShape.mjs.map +1 -0
  87. package/es/DonutChart/styles.d.mts +9 -0
  88. package/es/DonutChart/styles.mjs +28 -0
  89. package/es/DonutChart/styles.mjs.map +1 -0
  90. package/es/FunnelChart/ArrowRightIcon.d.mts +8 -0
  91. package/es/FunnelChart/ArrowRightIcon.mjs +14 -0
  92. package/es/FunnelChart/ArrowRightIcon.mjs.map +1 -0
  93. package/es/FunnelChart/index.d.mts +21 -0
  94. package/es/FunnelChart/index.mjs +419 -0
  95. package/es/FunnelChart/index.mjs.map +1 -0
  96. package/es/FunnelChart/styles.d.mts +9 -0
  97. package/es/FunnelChart/styles.mjs +28 -0
  98. package/es/FunnelChart/styles.mjs.map +1 -0
  99. package/es/FunnelChart/types.d.mts +31 -0
  100. package/es/FunnelChart/types.mjs +0 -0
  101. package/es/Heatmaps/Calendar.d.mts +21 -0
  102. package/es/Heatmaps/Calendar.mjs +107 -0
  103. package/es/Heatmaps/Calendar.mjs.map +1 -0
  104. package/es/Heatmaps/ChartLabels.d.mts +17 -0
  105. package/es/Heatmaps/ChartLabels.mjs +84 -0
  106. package/es/Heatmaps/ChartLabels.mjs.map +1 -0
  107. package/es/Heatmaps/Footer.d.mts +24 -0
  108. package/es/Heatmaps/Footer.mjs +81 -0
  109. package/es/Heatmaps/Footer.mjs.map +1 -0
  110. package/es/Heatmaps/index.d.mts +31 -0
  111. package/es/Heatmaps/index.mjs +186 -0
  112. package/es/Heatmaps/index.mjs.map +1 -0
  113. package/es/Heatmaps/styles.d.mts +10 -0
  114. package/es/Heatmaps/styles.mjs +47 -0
  115. package/es/Heatmaps/styles.mjs.map +1 -0
  116. package/es/Legend/LegendItem.d.mts +12 -0
  117. package/es/Legend/LegendItem.mjs +63 -0
  118. package/es/Legend/LegendItem.mjs.map +1 -0
  119. package/es/Legend/ScrollButton.d.mts +11 -0
  120. package/es/Legend/ScrollButton.mjs +49 -0
  121. package/es/Legend/ScrollButton.mjs.map +1 -0
  122. package/es/Legend/index.d.mts +16 -0
  123. package/es/Legend/index.mjs +151 -0
  124. package/es/Legend/index.mjs.map +1 -0
  125. package/es/LineChart/index.d.mts +11 -0
  126. package/es/LineChart/index.mjs +269 -0
  127. package/es/LineChart/index.mjs.map +1 -0
  128. package/es/LineChart/styles.d.mts +9 -0
  129. package/es/LineChart/styles.mjs +28 -0
  130. package/es/LineChart/styles.mjs.map +1 -0
  131. package/es/RadarChart/index.d.mts +27 -0
  132. package/es/RadarChart/index.mjs +155 -0
  133. package/es/RadarChart/index.mjs.map +1 -0
  134. package/es/RadarChart/styles.d.mts +8 -0
  135. package/es/RadarChart/styles.mjs +23 -0
  136. package/es/RadarChart/styles.mjs.map +1 -0
  137. package/es/ScatterChart/ScatterChartTooltip.d.mts +19 -0
  138. package/es/ScatterChart/ScatterChartTooltip.mjs +50 -0
  139. package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -0
  140. package/es/ScatterChart/ScatterChartTooltipRow.d.mts +10 -0
  141. package/es/ScatterChart/ScatterChartTooltipRow.mjs +34 -0
  142. package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -0
  143. package/es/ScatterChart/index.d.mts +58 -0
  144. package/es/ScatterChart/index.mjs +239 -0
  145. package/es/ScatterChart/index.mjs.map +1 -0
  146. package/es/ScatterChart/{renderShape.d.ts → renderShape.d.mts} +4 -1
  147. package/es/ScatterChart/renderShape.mjs +18 -0
  148. package/es/ScatterChart/renderShape.mjs.map +1 -0
  149. package/es/ScatterChart/styles.d.mts +9 -0
  150. package/es/ScatterChart/styles.mjs +28 -0
  151. package/es/ScatterChart/styles.mjs.map +1 -0
  152. package/es/SparkChart/SparkAreaChart.d.mts +14 -0
  153. package/es/SparkChart/SparkAreaChart.mjs +107 -0
  154. package/es/SparkChart/SparkAreaChart.mjs.map +1 -0
  155. package/es/SparkChart/SparkBarChart.d.mts +11 -0
  156. package/es/SparkChart/SparkBarChart.mjs +67 -0
  157. package/es/SparkChart/SparkBarChart.mjs.map +1 -0
  158. package/es/SparkChart/SparkLineChart.d.mts +12 -0
  159. package/es/SparkChart/SparkLineChart.mjs +71 -0
  160. package/es/SparkChart/SparkLineChart.mjs.map +1 -0
  161. package/es/SparkChart/index.d.mts +4 -0
  162. package/es/SparkChart/index.mjs +4 -0
  163. package/es/Tracker/TrackerBlock.d.mts +11 -0
  164. package/es/Tracker/TrackerBlock.mjs +50 -0
  165. package/es/Tracker/TrackerBlock.mjs.map +1 -0
  166. package/es/Tracker/index.d.mts +21 -0
  167. package/es/Tracker/index.mjs +67 -0
  168. package/es/Tracker/index.mjs.map +1 -0
  169. package/es/Tracker/styles.d.mts +8 -0
  170. package/es/Tracker/styles.mjs +24 -0
  171. package/es/Tracker/styles.mjs.map +1 -0
  172. package/es/common/BaseAnimationTimingProps.d.mts +10 -0
  173. package/es/common/BaseAnimationTimingProps.mjs +0 -0
  174. package/es/common/BaseChartProps.d.mts +61 -0
  175. package/es/common/BaseChartProps.mjs +0 -0
  176. package/es/common/BaseSparkChartProps.d.mts +17 -0
  177. package/es/common/BaseSparkChartProps.mjs +0 -0
  178. package/es/common/ChartLegend.d.mts +8 -0
  179. package/es/common/ChartLegend.mjs +32 -0
  180. package/es/common/ChartLegend.mjs.map +1 -0
  181. package/es/common/ChartTooltip/ChartTooltipFrame.d.mts +8 -0
  182. package/es/common/ChartTooltip/ChartTooltipFrame.mjs +26 -0
  183. package/es/common/ChartTooltip/ChartTooltipFrame.mjs.map +1 -0
  184. package/es/common/ChartTooltip/ChartTooltipRow.d.mts +10 -0
  185. package/es/common/ChartTooltip/ChartTooltipRow.mjs +49 -0
  186. package/es/common/ChartTooltip/ChartTooltipRow.mjs.map +1 -0
  187. package/es/common/ChartTooltip/index.d.mts +18 -0
  188. package/es/common/ChartTooltip/index.mjs +48 -0
  189. package/es/common/ChartTooltip/index.mjs.map +1 -0
  190. package/es/common/CustomTooltipProps.d.mts +15 -0
  191. package/es/common/CustomTooltipProps.mjs +0 -0
  192. package/es/common/CustomYAxisTick.d.mts +18 -0
  193. package/es/common/CustomYAxisTick.mjs +24 -0
  194. package/es/common/CustomYAxisTick.mjs.map +1 -0
  195. package/es/common/NoData.d.mts +13 -0
  196. package/es/common/NoData.mjs +25 -0
  197. package/es/common/NoData.mjs.map +1 -0
  198. package/es/common/benchmark/index.d.mts +3 -0
  199. package/es/common/benchmark/{index.js → index.mjs} +1 -1
  200. package/es/common/benchmark/types.d.mts +125 -0
  201. package/es/common/benchmark/types.mjs +0 -0
  202. package/es/common/benchmark/{utils.d.ts → utils.d.mts} +38 -36
  203. package/es/common/benchmark/utils.mjs +115 -0
  204. package/es/common/benchmark/utils.mjs.map +1 -0
  205. package/es/common/{utils.d.ts → utils.d.mts} +3 -0
  206. package/es/common/utils.mjs +36 -0
  207. package/es/common/utils.mjs.map +1 -0
  208. package/es/hooks/useOnWindowResize.d.mts +6 -0
  209. package/es/hooks/useOnWindowResize.mjs +18 -0
  210. package/es/hooks/useOnWindowResize.mjs.map +1 -0
  211. package/es/hooks/usePrefersReducedMotion.d.mts +4 -0
  212. package/es/hooks/usePrefersReducedMotion.mjs +24 -0
  213. package/es/hooks/usePrefersReducedMotion.mjs.map +1 -0
  214. package/es/hooks/useThemeColorRange.d.mts +4 -0
  215. package/es/hooks/useThemeColorRange.mjs +28 -0
  216. package/es/hooks/useThemeColorRange.mjs.map +1 -0
  217. package/es/index.d.mts +34 -0
  218. package/es/index.mjs +28 -0
  219. package/es/types/{charts.d.ts → charts.d.mts} +26 -26
  220. package/es/types/charts.mjs +12 -0
  221. package/es/types/charts.mjs.map +1 -0
  222. package/es/utils/{calendar.d.ts → calendar.d.mts} +21 -18
  223. package/es/utils/calendar.mjs +154 -0
  224. package/es/utils/calendar.mjs.map +1 -0
  225. package/es/utils/getMaxLabelLength.d.mts +13 -0
  226. package/es/utils/getMaxLabelLength.mjs +48 -0
  227. package/es/utils/getMaxLabelLength.mjs.map +1 -0
  228. package/es/utils/{index.d.ts → index.d.mts} +4 -1
  229. package/es/utils/index.mjs +19 -0
  230. package/es/utils/index.mjs.map +1 -0
  231. package/es/utils/{theme.d.ts → theme.d.mts} +3 -0
  232. package/es/utils/theme.mjs +33 -0
  233. package/es/utils/theme.mjs.map +1 -0
  234. package/package.json +144 -5
  235. package/es/AccuracyBarChart/index.d.ts +0 -60
  236. package/es/AccuracyBarChart/index.js +0 -452
  237. package/es/AccuracyBarChart/index.mdx +0 -52
  238. package/es/AccuracyBarChart/styles.d.ts +0 -11
  239. package/es/AccuracyBarChart/styles.js +0 -18
  240. package/es/AreaChart/index.d.ts +0 -11
  241. package/es/AreaChart/index.js +0 -428
  242. package/es/AreaChart/index.mdx +0 -49
  243. package/es/AreaChart/styles.d.ts +0 -6
  244. package/es/AreaChart/styles.js +0 -13
  245. package/es/BarChart/index.d.ts +0 -9
  246. package/es/BarChart/index.js +0 -390
  247. package/es/BarChart/index.mdx +0 -73
  248. package/es/BarChart/renderShape.js +0 -34
  249. package/es/BarChart/styles.d.ts +0 -6
  250. package/es/BarChart/styles.js +0 -13
  251. package/es/BarList/index.d.ts +0 -29
  252. package/es/BarList/index.js +0 -172
  253. package/es/BarList/index.mdx +0 -34
  254. package/es/BarList/styles.d.ts +0 -10
  255. package/es/BarList/styles.js +0 -18
  256. package/es/BenchmarkColumnChart/index.d.ts +0 -140
  257. package/es/BenchmarkColumnChart/index.js +0 -684
  258. package/es/BenchmarkColumnChart/index.mdx +0 -66
  259. package/es/BenchmarkColumnChart/styles.d.ts +0 -16
  260. package/es/BenchmarkColumnChart/styles.js +0 -23
  261. package/es/BenchmarkRankingChart/index.d.ts +0 -87
  262. package/es/BenchmarkRankingChart/index.js +0 -453
  263. package/es/BenchmarkRankingChart/index.mdx +0 -59
  264. package/es/BenchmarkRankingChart/styles.d.ts +0 -33
  265. package/es/BenchmarkRankingChart/styles.js +0 -41
  266. package/es/BenchmarkScatterChart/index.d.ts +0 -145
  267. package/es/BenchmarkScatterChart/index.js +0 -855
  268. package/es/BenchmarkScatterChart/index.mdx +0 -61
  269. package/es/BenchmarkScatterChart/styles.d.ts +0 -25
  270. package/es/BenchmarkScatterChart/styles.js +0 -33
  271. package/es/BenchmarkScatterChart/utils.js +0 -353
  272. package/es/ComposedChart/index.d.ts +0 -5
  273. package/es/ComposedChart/index.js +0 -333
  274. package/es/ComposedChart/index.mdx +0 -43
  275. package/es/ComposedChart/styles.d.ts +0 -6
  276. package/es/ComposedChart/styles.js +0 -13
  277. package/es/ComposedChart/types.d.ts +0 -68
  278. package/es/ComposedChart/types.js +0 -1
  279. package/es/DataBars/CategoryBar.d.ts +0 -15
  280. package/es/DataBars/CategoryBar.js +0 -199
  281. package/es/DataBars/DeltaBar.d.ts +0 -13
  282. package/es/DataBars/DeltaBar.js +0 -115
  283. package/es/DataBars/MarkerBar.d.ts +0 -16
  284. package/es/DataBars/MarkerBar.js +0 -92
  285. package/es/DataBars/ProgressBar.d.ts +0 -12
  286. package/es/DataBars/ProgressBar.js +0 -69
  287. package/es/DataBars/index.d.ts +0 -4
  288. package/es/DataBars/index.js +0 -4
  289. package/es/DataBars/index.mdx +0 -36
  290. package/es/DataBars/styles.d.ts +0 -7
  291. package/es/DataBars/styles.js +0 -14
  292. package/es/DonutChart/DonutChartTooltip.d.ts +0 -11
  293. package/es/DonutChart/DonutChartTooltip.js +0 -26
  294. package/es/DonutChart/index.d.ts +0 -31
  295. package/es/DonutChart/index.js +0 -230
  296. package/es/DonutChart/index.mdx +0 -48
  297. package/es/DonutChart/inputParser.d.ts +0 -2
  298. package/es/DonutChart/inputParser.js +0 -9
  299. package/es/DonutChart/renderInactiveShape.d.ts +0 -2
  300. package/es/DonutChart/renderInactiveShape.js +0 -27
  301. package/es/DonutChart/styles.d.ts +0 -6
  302. package/es/DonutChart/styles.js +0 -13
  303. package/es/FunnelChart/ArrowRightIcon.d.ts +0 -5
  304. package/es/FunnelChart/ArrowRightIcon.js +0 -22
  305. package/es/FunnelChart/index.d.ts +0 -19
  306. package/es/FunnelChart/index.js +0 -497
  307. package/es/FunnelChart/index.mdx +0 -21
  308. package/es/FunnelChart/styles.d.ts +0 -6
  309. package/es/FunnelChart/styles.js +0 -13
  310. package/es/FunnelChart/types.d.ts +0 -28
  311. package/es/FunnelChart/types.js +0 -1
  312. package/es/Heatmaps/Calendar.d.ts +0 -18
  313. package/es/Heatmaps/Calendar.js +0 -154
  314. package/es/Heatmaps/ChartLabels.d.ts +0 -15
  315. package/es/Heatmaps/ChartLabels.js +0 -106
  316. package/es/Heatmaps/Footer.d.ts +0 -22
  317. package/es/Heatmaps/Footer.js +0 -105
  318. package/es/Heatmaps/index.d.ts +0 -28
  319. package/es/Heatmaps/index.js +0 -225
  320. package/es/Heatmaps/index.mdx +0 -70
  321. package/es/Heatmaps/styles.d.ts +0 -7
  322. package/es/Heatmaps/styles.js +0 -14
  323. package/es/Legend/LegendItem.d.ts +0 -10
  324. package/es/Legend/LegendItem.js +0 -56
  325. package/es/Legend/ScrollButton.d.ts +0 -9
  326. package/es/Legend/ScrollButton.js +0 -62
  327. package/es/Legend/index.d.ts +0 -14
  328. package/es/Legend/index.js +0 -183
  329. package/es/Legend/index.mdx +0 -13
  330. package/es/LineChart/index.d.ts +0 -9
  331. package/es/LineChart/index.js +0 -386
  332. package/es/LineChart/index.mdx +0 -49
  333. package/es/LineChart/styles.d.ts +0 -6
  334. package/es/LineChart/styles.js +0 -13
  335. package/es/RadarChart/index.d.ts +0 -24
  336. package/es/RadarChart/index.js +0 -252
  337. package/es/RadarChart/index.mdx +0 -52
  338. package/es/RadarChart/styles.d.ts +0 -5
  339. package/es/RadarChart/styles.js +0 -12
  340. package/es/ScatterChart/ScatterChartTooltip.d.ts +0 -16
  341. package/es/ScatterChart/ScatterChartTooltip.js +0 -74
  342. package/es/ScatterChart/ScatterChartTooltipRow.d.ts +0 -7
  343. package/es/ScatterChart/ScatterChartTooltipRow.js +0 -38
  344. package/es/ScatterChart/index.d.ts +0 -56
  345. package/es/ScatterChart/index.js +0 -340
  346. package/es/ScatterChart/index.mdx +0 -49
  347. package/es/ScatterChart/renderShape.js +0 -18
  348. package/es/ScatterChart/styles.d.ts +0 -6
  349. package/es/ScatterChart/styles.js +0 -13
  350. package/es/SparkChart/SparkAreaChart.d.ts +0 -12
  351. package/es/SparkChart/SparkAreaChart.js +0 -146
  352. package/es/SparkChart/SparkBarChart.d.ts +0 -9
  353. package/es/SparkChart/SparkBarChart.js +0 -104
  354. package/es/SparkChart/SparkLineChart.d.ts +0 -10
  355. package/es/SparkChart/SparkLineChart.js +0 -108
  356. package/es/SparkChart/index.d.ts +0 -3
  357. package/es/SparkChart/index.js +0 -3
  358. package/es/SparkChart/index.mdx +0 -29
  359. package/es/Tracker/TrackerBlock.d.ts +0 -8
  360. package/es/Tracker/TrackerBlock.js +0 -62
  361. package/es/Tracker/index.d.ts +0 -18
  362. package/es/Tracker/index.js +0 -103
  363. package/es/Tracker/index.mdx +0 -41
  364. package/es/Tracker/styles.d.ts +0 -5
  365. package/es/Tracker/styles.js +0 -12
  366. package/es/common/BaseAnimationTimingProps.d.ts +0 -7
  367. package/es/common/BaseAnimationTimingProps.js +0 -1
  368. package/es/common/BaseChartProps.d.ts +0 -58
  369. package/es/common/BaseChartProps.js +0 -1
  370. package/es/common/BaseSparkChartProps.d.ts +0 -14
  371. package/es/common/BaseSparkChartProps.js +0 -1
  372. package/es/common/ChartLegend.d.ts +0 -5
  373. package/es/common/ChartLegend.js +0 -40
  374. package/es/common/ChartTooltip/ChartTooltipFrame.d.ts +0 -6
  375. package/es/common/ChartTooltip/ChartTooltipFrame.js +0 -31
  376. package/es/common/ChartTooltip/ChartTooltipRow.d.ts +0 -8
  377. package/es/common/ChartTooltip/ChartTooltipRow.js +0 -53
  378. package/es/common/ChartTooltip/index.d.ts +0 -15
  379. package/es/common/ChartTooltip/index.js +0 -64
  380. package/es/common/CustomTooltipProps.d.ts +0 -12
  381. package/es/common/CustomTooltipProps.js +0 -1
  382. package/es/common/CustomYAxisTick.d.ts +0 -15
  383. package/es/common/CustomYAxisTick.js +0 -27
  384. package/es/common/NoData.d.ts +0 -10
  385. package/es/common/NoData.js +0 -24
  386. package/es/common/benchmark/index.d.ts +0 -2
  387. package/es/common/benchmark/types.d.ts +0 -122
  388. package/es/common/benchmark/types.js +0 -1
  389. package/es/common/benchmark/utils.js +0 -159
  390. package/es/common/utils.js +0 -85
  391. package/es/hooks/useOnWindowResize.d.ts +0 -3
  392. package/es/hooks/useOnWindowResize.js +0 -15
  393. package/es/hooks/usePrefersReducedMotion.d.ts +0 -1
  394. package/es/hooks/usePrefersReducedMotion.js +0 -28
  395. package/es/hooks/useThemeColorRange.d.ts +0 -1
  396. package/es/hooks/useThemeColorRange.js +0 -8
  397. package/es/index.d.ts +0 -24
  398. package/es/index.js +0 -22
  399. package/es/types/charts.js +0 -8
  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
@@ -1,855 +0,0 @@
1
- 'use client';
2
-
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- var _excluded = ["data", "index", "valueKey", "providerKey", "iconKey", "colorKey", "errorKey", "renderIcon", "valueFormatter", "accuracyFormatter", "errorFormatter", "showError", "showErrorBars", "showAnimation", "onValueChange", "className", "style", "loading", "width", "height", "noDataText", "highlightColor", "frontierColor", "frontierWidth", "iconSize", "markerSize", "labelFontSize", "valueLabelFontSize", "metrics", "metric", "defaultMetric", "onMetricChange", "minX", "maxX", "minY", "maxY", "showDominatedArea", "showFrontier", "showGridLines", "showLabels", "showLegend", "showTooltip", "showValueLabel", "showXAxis", "showYAxis", "xAxisLabel", "xDirection", "xFormatter", "xKey", "xScale", "yAxisLabel"];
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
11
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
13
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
15
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
19
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
- import { A, Segmented, Skeleton, Tooltip, cssVar, cx, useTheme } from '@lobehub/ui';
24
- import { useSize } from 'ahooks';
25
- import { forwardRef, useMemo, useRef, useState } from 'react';
26
- import ChartTooltip from "../common/ChartTooltip";
27
- import NoData from "../common/NoData";
28
- import { defaultBenchmarkErrorFormatter, defaultBenchmarkValueFormatter, normalizeBenchmarkData } from "../common/benchmark";
29
- import { constructCategoryColors } from "../common/utils";
30
- import { useThemeColorRange } from "../hooks/useThemeColorRange";
31
- import { getTextWidth } from "../utils/getMaxLabelLength";
32
- import { styles } from "./styles";
33
- import { createScale, getParetoFrontier, placeLabels } from "./utils";
34
- import { jsx as _jsx } from "react/jsx-runtime";
35
- import { jsxs as _jsxs } from "react/jsx-runtime";
36
- import { Fragment as _Fragment } from "react/jsx-runtime";
37
- var labelPriority = function labelPriority(point, frontierKeys) {
38
- return (frontierKeys.has(point.key) ? 0 : 2) + (point.item.highlighted ? 0 : 1);
39
- };
40
- var MARGIN_TOP = 12;
41
- var MARGIN_RIGHT = 16;
42
- var TICK_GAP = 8;
43
- var AXIS_TITLE_SIZE = 22;
44
- // Monospace glyph advance relative to font size (Geist Mono / SF Mono ≈ 0.6em)
45
- var MONO_CHAR_RATIO = 0.62;
46
- var renderShape = function renderShape(shape, color, size) {
47
- var ring = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
48
- var half = size / 2;
49
- var node;
50
- switch (shape) {
51
- case 'square':
52
- {
53
- node = /*#__PURE__*/_jsx("rect", {
54
- fill: color,
55
- height: size * 0.84,
56
- width: size * 0.84,
57
- x: size * 0.08,
58
- y: size * 0.08
59
- });
60
- break;
61
- }
62
- case 'diamond':
63
- {
64
- node = /*#__PURE__*/_jsx("path", {
65
- d: "M".concat(half, ",0 L").concat(size, ",").concat(half, " L").concat(half, ",").concat(size, " L0,").concat(half, " Z"),
66
- fill: color
67
- });
68
- break;
69
- }
70
- case 'triangle':
71
- {
72
- node = /*#__PURE__*/_jsx("path", {
73
- d: "M".concat(half, ",0 L").concat(size, ",").concat(size * 0.9, " L0,").concat(size * 0.9, " Z"),
74
- fill: color
75
- });
76
- break;
77
- }
78
- default:
79
- {
80
- node = /*#__PURE__*/_jsx("circle", {
81
- cx: half,
82
- cy: half,
83
- fill: color,
84
- r: half
85
- });
86
- }
87
- }
88
- return /*#__PURE__*/_jsx("svg", {
89
- height: size,
90
- style: {
91
- display: 'block',
92
- overflow: 'visible'
93
- },
94
- width: size,
95
- children: ring ? /*#__PURE__*/_jsx("g", {
96
- paintOrder: "stroke",
97
- stroke: cssVar.colorBgContainer,
98
- strokeWidth: 4,
99
- children: node
100
- }) : node
101
- });
102
- };
103
- var toLabelText = function toLabelText(name) {
104
- return String(name !== null && name !== void 0 ? name : '').replaceAll('\n', ' ');
105
- };
106
- var BenchmarkScatterChart = /*#__PURE__*/forwardRef(function (props, ref) {
107
- var _metrics$length;
108
- var theme = useTheme();
109
- var themeColorRange = useThemeColorRange();
110
- var _props$data = props.data,
111
- data = _props$data === void 0 ? [] : _props$data,
112
- index = props.index,
113
- valueKey = props.valueKey,
114
- providerKey = props.providerKey,
115
- iconKey = props.iconKey,
116
- colorKey = props.colorKey,
117
- errorKey = props.errorKey,
118
- renderIcon = props.renderIcon,
119
- _props$valueFormatter = props.valueFormatter,
120
- valueFormatter = _props$valueFormatter === void 0 ? defaultBenchmarkValueFormatter : _props$valueFormatter,
121
- accuracyFormatter = props.accuracyFormatter,
122
- _props$errorFormatter = props.errorFormatter,
123
- errorFormatter = _props$errorFormatter === void 0 ? defaultBenchmarkErrorFormatter : _props$errorFormatter,
124
- _props$showError = props.showError,
125
- showError = _props$showError === void 0 ? true : _props$showError,
126
- _props$showErrorBars = props.showErrorBars,
127
- showErrorBars = _props$showErrorBars === void 0 ? true : _props$showErrorBars,
128
- _props$showAnimation = props.showAnimation,
129
- showAnimation = _props$showAnimation === void 0 ? false : _props$showAnimation,
130
- onValueChange = props.onValueChange,
131
- className = props.className,
132
- style = props.style,
133
- loading = props.loading,
134
- _props$width = props.width,
135
- width = _props$width === void 0 ? '100%' : _props$width,
136
- _props$height = props.height,
137
- height = _props$height === void 0 ? 420 : _props$height,
138
- noDataText = props.noDataText,
139
- highlightColor = props.highlightColor,
140
- frontierColor = props.frontierColor,
141
- _props$frontierWidth = props.frontierWidth,
142
- frontierWidth = _props$frontierWidth === void 0 ? 2 : _props$frontierWidth,
143
- _props$iconSize = props.iconSize,
144
- iconSize = _props$iconSize === void 0 ? 20 : _props$iconSize,
145
- _props$markerSize = props.markerSize,
146
- markerSize = _props$markerSize === void 0 ? 12 : _props$markerSize,
147
- _props$labelFontSize = props.labelFontSize,
148
- labelFontSize = _props$labelFontSize === void 0 ? 12 : _props$labelFontSize,
149
- _props$valueLabelFont = props.valueLabelFontSize,
150
- valueLabelFontSize = _props$valueLabelFont === void 0 ? 11 : _props$valueLabelFont,
151
- metrics = props.metrics,
152
- metric = props.metric,
153
- defaultMetric = props.defaultMetric,
154
- onMetricChange = props.onMetricChange,
155
- minX = props.minX,
156
- maxX = props.maxX,
157
- minY = props.minY,
158
- maxY = props.maxY,
159
- _props$showDominatedA = props.showDominatedArea,
160
- showDominatedArea = _props$showDominatedA === void 0 ? true : _props$showDominatedA,
161
- _props$showFrontier = props.showFrontier,
162
- showFrontier = _props$showFrontier === void 0 ? true : _props$showFrontier,
163
- _props$showGridLines = props.showGridLines,
164
- showGridLines = _props$showGridLines === void 0 ? true : _props$showGridLines,
165
- _props$showLabels = props.showLabels,
166
- showLabels = _props$showLabels === void 0 ? true : _props$showLabels,
167
- _props$showLegend = props.showLegend,
168
- showLegend = _props$showLegend === void 0 ? true : _props$showLegend,
169
- _props$showTooltip = props.showTooltip,
170
- showTooltip = _props$showTooltip === void 0 ? true : _props$showTooltip,
171
- _props$showValueLabel = props.showValueLabel,
172
- showValueLabel = _props$showValueLabel === void 0 ? true : _props$showValueLabel,
173
- _props$showXAxis = props.showXAxis,
174
- showXAxis = _props$showXAxis === void 0 ? true : _props$showXAxis,
175
- _props$showYAxis = props.showYAxis,
176
- showYAxis = _props$showYAxis === void 0 ? true : _props$showYAxis,
177
- xAxisLabel = props.xAxisLabel,
178
- _props$xDirection = props.xDirection,
179
- xDirection = _props$xDirection === void 0 ? 'lower' : _props$xDirection,
180
- _props$xFormatter = props.xFormatter,
181
- xFormatter = _props$xFormatter === void 0 ? defaultBenchmarkValueFormatter : _props$xFormatter,
182
- _props$xKey = props.xKey,
183
- xKey = _props$xKey === void 0 ? 'x' : _props$xKey,
184
- _props$xScale = props.xScale,
185
- xScale = _props$xScale === void 0 ? 'linear' : _props$xScale,
186
- yAxisLabel = props.yAxisLabel,
187
- rest = _objectWithoutProperties(props, _excluded);
188
- var plotRef = useRef(null);
189
- var size = useSize(plotRef);
190
- var _useState = useState(defaultMetric),
191
- _useState2 = _slicedToArray(_useState, 2),
192
- innerMetric = _useState2[0],
193
- setInnerMetric = _useState2[1];
194
- var _useState3 = useState(),
195
- _useState4 = _slicedToArray(_useState3, 2),
196
- hoverKey = _useState4[0],
197
- setHoverKey = _useState4[1];
198
- var _useState5 = useState(),
199
- _useState6 = _slicedToArray(_useState5, 2),
200
- selectedKey = _useState6[0],
201
- setSelectedKey = _useState6[1];
202
- var resolvedHighlightColor = highlightColor !== null && highlightColor !== void 0 ? highlightColor : theme.gold;
203
- var resolvedFrontierColor = frontierColor !== null && frontierColor !== void 0 ? frontierColor : theme.orange;
204
- var yFormatter = accuracyFormatter !== null && accuracyFormatter !== void 0 ? accuracyFormatter : valueFormatter;
205
- var yName = yAxisLabel || (accuracyFormatter ? 'Accuracy' : 'Score');
206
- var activeMetric = useMemo(function () {
207
- if (metrics !== null && metrics !== void 0 && metrics.length) {
208
- var _metrics$find, _found$axisLabel, _found$direction, _found$formatter, _found$max, _found$min, _found$scale;
209
- var key = metric !== null && metric !== void 0 ? metric : innerMetric;
210
- var found = (_metrics$find = metrics.find(function (m) {
211
- return m.key === key;
212
- })) !== null && _metrics$find !== void 0 ? _metrics$find : metrics[0];
213
- return {
214
- axisLabel: (_found$axisLabel = found.axisLabel) !== null && _found$axisLabel !== void 0 ? _found$axisLabel : found.label,
215
- direction: (_found$direction = found.direction) !== null && _found$direction !== void 0 ? _found$direction : 'lower',
216
- formatter: (_found$formatter = found.formatter) !== null && _found$formatter !== void 0 ? _found$formatter : defaultBenchmarkValueFormatter,
217
- key: found.key,
218
- label: found.label,
219
- max: (_found$max = found.max) !== null && _found$max !== void 0 ? _found$max : maxX,
220
- min: (_found$min = found.min) !== null && _found$min !== void 0 ? _found$min : minX,
221
- scale: (_found$scale = found.scale) !== null && _found$scale !== void 0 ? _found$scale : 'linear'
222
- };
223
- }
224
- return {
225
- axisLabel: xAxisLabel,
226
- direction: xDirection,
227
- formatter: xFormatter,
228
- key: xKey,
229
- label: xAxisLabel || 'X',
230
- max: maxX,
231
- min: minX,
232
- scale: xScale
233
- };
234
- }, [innerMetric, maxX, metric, metrics, minX, xAxisLabel, xDirection, xFormatter, xKey, xScale]);
235
- var items = useMemo(function () {
236
- return normalizeBenchmarkData({
237
- colorKey: colorKey,
238
- data: data,
239
- errorKey: errorKey,
240
- iconKey: iconKey,
241
- index: index,
242
- providerKey: providerKey,
243
- renderIcon: renderIcon,
244
- sortOrder: 'descending',
245
- valueKey: valueKey
246
- });
247
- }, [colorKey, data, errorKey, iconKey, index, providerKey, renderIcon, valueKey]);
248
- var categoryColors = useMemo(function () {
249
- return constructCategoryColors(items.map(function (item) {
250
- return String(item.key);
251
- }), themeColorRange);
252
- }, [items, themeColorRange]);
253
- var points = useMemo(function () {
254
- return items.map(function (item) {
255
- var _ref, _item$color;
256
- return {
257
- color: (_ref = (_item$color = item.color) !== null && _item$color !== void 0 ? _item$color : categoryColors.get(String(item.key))) !== null && _ref !== void 0 ? _ref : cssVar.colorPrimary,
258
- item: item,
259
- key: item.key,
260
- x: Number(item.original[activeMetric.key]),
261
- y: item.value
262
- };
263
- }).filter(function (p) {
264
- return Number.isFinite(p.x) && Number.isFinite(p.y) && (activeMetric.scale !== 'log' || p.x > 0);
265
- });
266
- }, [activeMetric.key, activeMetric.scale, categoryColors, items]);
267
- var frontier = useMemo(function () {
268
- return showFrontier ? getParetoFrontier(points, activeMetric.direction) : [];
269
- }, [activeMetric.direction, points, showFrontier]);
270
- var frontierKeys = useMemo(function () {
271
- return new Set(frontier.map(function (p) {
272
- return p.key;
273
- }));
274
- }, [frontier]);
275
- var enableErrorBars = showError && showErrorBars;
276
- var yValues = useMemo(function () {
277
- return points.flatMap(function (p) {
278
- return enableErrorBars && p.item.error ? [p.y - p.item.error, p.y + p.item.error] : [p.y];
279
- });
280
- }, [enableErrorBars, points]);
281
- var labelSizes = useMemo(function () {
282
- var map = new Map();
283
- if (!showLabels) return map;
284
- var nameScale = labelFontSize / 12 * 1.1;
285
- var _iterator = _createForOfIteratorHelper(points),
286
- _step;
287
- try {
288
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
289
- var p = _step.value;
290
- var nameWidth = getTextWidth(toLabelText(p.item.name)) * nameScale;
291
- var valueWidth = showValueLabel ? "".concat(yFormatter(p.y), " \xB7 ").concat(activeMetric.formatter(p.x)).length * valueLabelFontSize * MONO_CHAR_RATIO : 0;
292
- map.set(p.key, {
293
- height: Math.ceil(labelFontSize * 1.3 + (showValueLabel ? valueLabelFontSize * 1.3 : 0)),
294
- width: Math.ceil(Math.max(nameWidth, valueWidth)) + 2
295
- });
296
- }
297
- } catch (err) {
298
- _iterator.e(err);
299
- } finally {
300
- _iterator.f();
301
- }
302
- return map;
303
- }, [activeMetric, labelFontSize, points, showLabels, showValueLabel, valueLabelFontSize, yFormatter]);
304
- var plotWidth = (size === null || size === void 0 ? void 0 : size.width) || (typeof width === 'number' ? width : 0);
305
- var plotHeight = typeof height === 'number' ? height : 420;
306
- var layout = useMemo(function () {
307
- if (!plotWidth || !points.length) return null;
308
- var probeY = createScale({
309
- max: maxY,
310
- min: minY,
311
- range: [0, 1],
312
- values: yValues
313
- });
314
- var yTickWidth = showYAxis ? Math.max.apply(Math, _toConsumableArray(probeY.ticks.map(function (t) {
315
- return yFormatter(t).length * 12 * MONO_CHAR_RATIO;
316
- })).concat([0])) : 0;
317
- var left = (showYAxis ? yTickWidth + TICK_GAP + 4 : 4) + (yAxisLabel ? AXIS_TITLE_SIZE : 0);
318
- var bottom = (showXAxis ? 26 : 4) + (activeMetric.axisLabel ? AXIS_TITLE_SIZE : 0);
319
- var innerRight = plotWidth - MARGIN_RIGHT;
320
- var innerBottom = plotHeight - bottom;
321
- var xScaleObj = createScale({
322
- max: activeMetric.max,
323
- min: activeMetric.min,
324
- range: [left, innerRight],
325
- type: activeMetric.scale,
326
- values: points.map(function (p) {
327
- return p.x;
328
- })
329
- });
330
- var yScaleObj = createScale({
331
- max: maxY,
332
- min: minY,
333
- range: [innerBottom, MARGIN_TOP],
334
- values: yValues
335
- });
336
- var positions = new Map();
337
- var _iterator2 = _createForOfIteratorHelper(points),
338
- _step2;
339
- try {
340
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
341
- var p = _step2.value;
342
- positions.set(p.key, {
343
- px: xScaleObj.map(p.x),
344
- py: yScaleObj.map(p.y),
345
- radius: (p.item.icon ? iconSize : markerSize) / 2
346
- });
347
- }
348
- } catch (err) {
349
- _iterator2.e(err);
350
- } finally {
351
- _iterator2.f();
352
- }
353
- var frontierPath = frontier.map(function (p, i) {
354
- var pos = positions.get(p.key);
355
- return "".concat(i === 0 ? 'M' : 'L').concat(pos.px.toFixed(2), ",").concat(pos.py.toFixed(2));
356
- }).join(' ');
357
- var labels = new Map();
358
- if (showLabels) {
359
- var lineBoxes = [];
360
- for (var i = 1; i < frontier.length; i++) {
361
- var a = positions.get(frontier[i - 1].key);
362
- var b = positions.get(frontier[i].key);
363
- var steps = Math.max(1, Math.ceil(Math.hypot(b.px - a.px, b.py - a.py) / 10));
364
- for (var s = 0; s <= steps; s++) {
365
- var t = s / steps;
366
- lineBoxes.push({
367
- height: 6,
368
- width: 6,
369
- x: a.px + (b.px - a.px) * t - 3,
370
- y: a.py + (b.py - a.py) * t - 3
371
- });
372
- }
373
- }
374
- var ordered = _toConsumableArray(points).sort(function (a, b) {
375
- return labelPriority(a, frontierKeys) - labelPriority(b, frontierKeys) || b.y - a.y;
376
- });
377
- var candidates = ordered.map(function (p) {
378
- var _labelSizes$get;
379
- var pos = positions.get(p.key);
380
- var labelSize = (_labelSizes$get = labelSizes.get(p.key)) !== null && _labelSizes$get !== void 0 ? _labelSizes$get : {
381
- height: 16,
382
- width: 40
383
- };
384
- return _objectSpread(_objectSpread({}, labelSize), {}, {
385
- key: p.key
386
- }, pos);
387
- });
388
- labels = placeLabels(candidates, {
389
- height: innerBottom,
390
- width: plotWidth - left + MARGIN_RIGHT,
391
- x: left,
392
- y: 0
393
- }, {
394
- lines: lineBoxes
395
- });
396
- }
397
- return {
398
- bottom: bottom,
399
- frontierPath: frontierPath,
400
- innerBottom: innerBottom,
401
- innerRight: innerRight,
402
- labels: labels,
403
- left: left,
404
- positions: positions,
405
- xScale: xScaleObj,
406
- yScale: yScaleObj
407
- };
408
- }, [activeMetric, frontier, frontierKeys, iconSize, labelSizes, markerSize, maxY, minY, plotHeight, plotWidth, points, showLabels, showXAxis, showYAxis, yAxisLabel, yFormatter, yValues]);
409
- if (loading || !data) return /*#__PURE__*/_jsx(Skeleton, {
410
- height: plotHeight,
411
- width: width
412
- });
413
- var focusKey = hoverKey !== null && hoverKey !== void 0 ? hoverKey : selectedKey;
414
- var focusPoint = focusKey === undefined ? undefined : points.find(function (point) {
415
- return point.key === focusKey;
416
- });
417
- var dominatedKeys = new Set();
418
- if (showDominatedArea && focusPoint) {
419
- var _iterator3 = _createForOfIteratorHelper(points),
420
- _step3;
421
- try {
422
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
423
- var point = _step3.value;
424
- if (point.key === focusPoint.key || point.y > focusPoint.y) continue;
425
- var worseX = activeMetric.direction === 'lower' ? point.x >= focusPoint.x : point.x <= focusPoint.x;
426
- if (worseX) dominatedKeys.add(point.key);
427
- }
428
- } catch (err) {
429
- _iterator3.e(err);
430
- } finally {
431
- _iterator3.f();
432
- }
433
- }
434
- var getEmphasis = function getEmphasis(key) {
435
- if (focusKey === undefined || key === focusKey) return 'normal';
436
- if (!showDominatedArea) return 'dimmed';
437
- return dominatedKeys.has(key) ? 'dominated' : 'normal';
438
- };
439
- var isDimmed = function isDimmed(key) {
440
- return getEmphasis(key) !== 'normal';
441
- };
442
- var animatedCls = showAnimation ? undefined : styles.noTransition;
443
- var handleClick = function handleClick(item) {
444
- if (!onValueChange) return;
445
- if (selectedKey === item.key) {
446
- setSelectedKey(undefined);
447
- onValueChange(null);
448
- return;
449
- }
450
- setSelectedKey(item.key);
451
- var payload = _objectSpread(_objectSpread({}, item.original), {}, {
452
- eventType: 'point',
453
- rank: item.rank,
454
- value: item.value
455
- });
456
- onValueChange(payload);
457
- };
458
- var handleMetricChange = function handleMetricChange(key) {
459
- if (metric === undefined) setInnerMetric(key);
460
- onMetricChange === null || onMetricChange === void 0 || onMetricChange(key);
461
- };
462
- var renderTooltip = function renderTooltip(point, child) {
463
- if (!showTooltip) return child;
464
- var item = point.item;
465
- var rows = [];
466
- if (metrics !== null && metrics !== void 0 && metrics.length) {
467
- var _iterator4 = _createForOfIteratorHelper(metrics),
468
- _step4;
469
- try {
470
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
471
- var _m$formatter;
472
- var m = _step4.value;
473
- var _value2 = Number(item.original[m.key]);
474
- if (!Number.isFinite(_value2)) continue;
475
- rows.push({
476
- format: (_m$formatter = m.formatter) !== null && _m$formatter !== void 0 ? _m$formatter : defaultBenchmarkValueFormatter,
477
- name: m.label,
478
- value: _value2
479
- });
480
- }
481
- } catch (err) {
482
- _iterator4.e(err);
483
- } finally {
484
- _iterator4.f();
485
- }
486
- } else {
487
- rows.push({
488
- format: activeMetric.formatter,
489
- name: activeMetric.label,
490
- value: point.x
491
- });
492
- }
493
- rows.reverse();
494
- rows.push({
495
- format: function format(v) {
496
- return showError && item.error !== undefined ? "".concat(yFormatter(v), " \xB1 ").concat(errorFormatter(item.error)) : yFormatter(v);
497
- },
498
- name: yName,
499
- value: point.y
500
- });
501
- var formatters = new Map(rows.map(function (row) {
502
- return [row.name, row.format];
503
- }));
504
- var modelName = toLabelText(item.name);
505
- return /*#__PURE__*/_jsx(Tooltip, {
506
- arrow: false,
507
- mouseEnterDelay: 0.05,
508
- mouseLeaveDelay: 0,
509
- styles: {
510
- container: {
511
- background: 'transparent',
512
- boxShadow: 'none',
513
- maxWidth: 'none',
514
- padding: 0,
515
- pointerEvents: 'none',
516
- width: 'max-content'
517
- },
518
- content: {
519
- color: cssVar.colorText,
520
- fontSize: cssVar.fontSize,
521
- lineHeight: cssVar.lineHeight,
522
- maxWidth: 'none',
523
- overflow: 'visible',
524
- padding: 0
525
- },
526
- root: {
527
- maxWidth: 'none',
528
- pointerEvents: 'none'
529
- }
530
- },
531
- title: /*#__PURE__*/_jsx(ChartTooltip, {
532
- active: true,
533
- categoryColors: new Map(rows.map(function (row) {
534
- return [row.name, point.color];
535
- })),
536
- label: item.provider ? "".concat(modelName, " \xB7 ").concat(String(item.provider)) : modelName,
537
- payload: rows.map(function (row) {
538
- return {
539
- dataKey: row.name,
540
- name: row.name,
541
- value: row.value
542
- };
543
- }),
544
- valueFormatter: function valueFormatter(value, name) {
545
- var _formatters$get;
546
- return ((_formatters$get = formatters.get(name !== null && name !== void 0 ? name : '')) !== null && _formatters$get !== void 0 ? _formatters$get : String)(Number(value));
547
- }
548
- }),
549
- children: child
550
- });
551
- };
552
- var renderMarker = function renderMarker(point, markerSizePx) {
553
- var ring = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
554
- return point.item.icon ? /*#__PURE__*/_jsx("span", {
555
- className: ring ? styles.markerIconRing : undefined,
556
- style: {
557
- alignItems: 'center',
558
- display: 'flex',
559
- flexShrink: 0,
560
- height: iconSize,
561
- justifyContent: 'center',
562
- transform: markerSizePx === iconSize ? undefined : "scale(".concat(markerSizePx / iconSize, ")"),
563
- width: iconSize
564
- },
565
- children: point.item.icon
566
- }) : renderShape(point.item.original.shape, point.color, markerSizePx, ring);
567
- };
568
- var hasMetricSwitch = ((_metrics$length = metrics === null || metrics === void 0 ? void 0 : metrics.length) !== null && _metrics$length !== void 0 ? _metrics$length : 0) > 1;
569
- return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
570
- className: cx(styles.container, className),
571
- ref: ref,
572
- style: _objectSpread({
573
- '--benchmark-label-font-size': "".concat(labelFontSize, "px"),
574
- '--benchmark-value-label-font-size': "".concat(valueLabelFontSize, "px"),
575
- 'width': width
576
- }, style)
577
- }, rest), {}, {
578
- children: [showLegend && points.length > 0 || hasMetricSwitch ? /*#__PURE__*/_jsxs("div", {
579
- className: styles.header,
580
- children: [/*#__PURE__*/_jsx("div", {
581
- className: styles.legend,
582
- children: showLegend ? points.map(function (point) {
583
- return /*#__PURE__*/_jsxs("span", {
584
- className: styles.legendItem,
585
- onClick: function onClick() {
586
- return handleClick(point.item);
587
- },
588
- onMouseEnter: function onMouseEnter() {
589
- return setHoverKey(point.key);
590
- },
591
- onMouseLeave: function onMouseLeave() {
592
- return setHoverKey(undefined);
593
- },
594
- style: {
595
- color: point.item.highlighted ? resolvedHighlightColor : undefined,
596
- cursor: onValueChange ? 'pointer' : undefined,
597
- opacity: isDimmed(point.key) ? 0.4 : 1
598
- },
599
- children: [/*#__PURE__*/_jsx("span", {
600
- className: styles.legendMarker,
601
- children: renderMarker(point, 12)
602
- }), toLabelText(point.item.name)]
603
- }, "legend-".concat(point.key));
604
- }) : null
605
- }), hasMetricSwitch ? /*#__PURE__*/_jsx(Segmented, {
606
- onChange: function onChange(value) {
607
- return handleMetricChange(String(value));
608
- },
609
- options: metrics.map(function (m) {
610
- return {
611
- label: m.label,
612
- value: m.key
613
- };
614
- }),
615
- size: "small",
616
- value: activeMetric.key
617
- }) : null]
618
- }) : null, /*#__PURE__*/_jsxs("div", {
619
- className: styles.plot,
620
- ref: plotRef,
621
- style: {
622
- height: plotHeight
623
- },
624
- children: [!points.length ? /*#__PURE__*/_jsx(NoData, {
625
- noDataText: noDataText
626
- }) : null, layout ? /*#__PURE__*/_jsxs(_Fragment, {
627
- children: [/*#__PURE__*/_jsxs("svg", {
628
- height: plotHeight,
629
- role: "img",
630
- style: {
631
- display: 'block',
632
- overflow: 'visible'
633
- },
634
- width: plotWidth,
635
- children: [showGridLines ? /*#__PURE__*/_jsxs("g", {
636
- children: [layout.yScale.ticks.map(function (tick) {
637
- var y = layout.yScale.map(tick);
638
- return /*#__PURE__*/_jsx("line", {
639
- className: styles.gridLine,
640
- x1: layout.left,
641
- x2: layout.innerRight,
642
- y1: y,
643
- y2: y
644
- }, "gy-".concat(tick));
645
- }), layout.xScale.ticks.map(function (tick) {
646
- var x = layout.xScale.map(tick);
647
- return /*#__PURE__*/_jsx("line", {
648
- className: styles.gridLine,
649
- x1: x,
650
- x2: x,
651
- y1: MARGIN_TOP,
652
- y2: layout.innerBottom
653
- }, "gx-".concat(tick));
654
- })]
655
- }) : null, showYAxis ? /*#__PURE__*/_jsx("g", {
656
- children: layout.yScale.ticks.map(function (tick) {
657
- return /*#__PURE__*/_jsx("text", {
658
- className: styles.tickLabel,
659
- dominantBaseline: "middle",
660
- textAnchor: "end",
661
- x: layout.left - TICK_GAP,
662
- y: layout.yScale.map(tick),
663
- children: yFormatter(tick)
664
- }, "ty-".concat(tick));
665
- })
666
- }) : null, showXAxis ? /*#__PURE__*/_jsxs("g", {
667
- children: [/*#__PURE__*/_jsx("line", {
668
- className: styles.axisLine,
669
- x1: layout.left,
670
- x2: layout.innerRight,
671
- y1: layout.innerBottom,
672
- y2: layout.innerBottom
673
- }), layout.xScale.ticks.map(function (tick) {
674
- return /*#__PURE__*/_jsx("text", {
675
- className: styles.tickLabel,
676
- dominantBaseline: "hanging",
677
- textAnchor: "middle",
678
- x: layout.xScale.map(tick),
679
- y: layout.innerBottom + TICK_GAP,
680
- children: activeMetric.formatter(tick)
681
- }, "tx-".concat(tick));
682
- })]
683
- }) : null, yAxisLabel ? /*#__PURE__*/_jsx("text", {
684
- className: styles.axisLabel,
685
- dominantBaseline: "hanging",
686
- textAnchor: "middle",
687
- transform: "rotate(-90, 0, ".concat((MARGIN_TOP + layout.innerBottom) / 2, ")"),
688
- x: 0,
689
- y: (MARGIN_TOP + layout.innerBottom) / 2,
690
- children: yAxisLabel
691
- }) : null, activeMetric.axisLabel ? /*#__PURE__*/_jsx("text", {
692
- className: styles.axisLabel,
693
- dominantBaseline: "auto",
694
- textAnchor: "middle",
695
- x: (layout.left + layout.innerRight) / 2,
696
- y: plotHeight - 4,
697
- children: activeMetric.axisLabel
698
- }) : null, showDominatedArea && focusPoint ? function () {
699
- var pos = layout.positions.get(focusPoint.key);
700
- var toRight = activeMetric.direction === 'lower';
701
- var x0 = toRight ? pos.px : layout.left;
702
- var x1 = toRight ? layout.innerRight : pos.px;
703
- return /*#__PURE__*/_jsxs("g", {
704
- className: styles.dominatedArea,
705
- "data-testid": "benchmark-scatter-dominated-area",
706
- children: [/*#__PURE__*/_jsx("rect", {
707
- fill: resolvedFrontierColor,
708
- fillOpacity: 0.08,
709
- height: Math.max(0, layout.innerBottom - pos.py),
710
- width: Math.max(0, x1 - x0),
711
- x: x0,
712
- y: pos.py
713
- }), /*#__PURE__*/_jsx("line", {
714
- className: styles.dominatedGuide,
715
- x1: x0,
716
- x2: x1,
717
- y1: pos.py,
718
- y2: pos.py
719
- }), /*#__PURE__*/_jsx("line", {
720
- className: styles.dominatedGuide,
721
- x1: pos.px,
722
- x2: pos.px,
723
- y1: pos.py,
724
- y2: layout.innerBottom
725
- })]
726
- });
727
- }() : null, enableErrorBars ? points.map(function (point) {
728
- var error = point.item.error;
729
- if (!error) return null;
730
- var pos = layout.positions.get(point.key);
731
- var top = layout.yScale.map(point.y + error);
732
- var bottom = layout.yScale.map(point.y - error);
733
- return /*#__PURE__*/_jsxs("g", {
734
- className: styles.errorBar,
735
- "data-testid": "benchmark-scatter-error-bar",
736
- opacity: isDimmed(point.key) ? 0.25 : 0.7,
737
- stroke: point.color,
738
- children: [/*#__PURE__*/_jsx("line", {
739
- x1: pos.px,
740
- x2: pos.px,
741
- y1: top,
742
- y2: bottom
743
- }), /*#__PURE__*/_jsx("line", {
744
- x1: pos.px - 4,
745
- x2: pos.px + 4,
746
- y1: top,
747
- y2: top
748
- }), /*#__PURE__*/_jsx("line", {
749
- x1: pos.px - 4,
750
- x2: pos.px + 4,
751
- y1: bottom,
752
- y2: bottom
753
- })]
754
- }, "err-".concat(point.key));
755
- }) : null, layout.frontierPath ? /*#__PURE__*/_jsx("path", {
756
- className: styles.frontier,
757
- d: layout.frontierPath,
758
- "data-testid": "benchmark-scatter-frontier",
759
- opacity: !showDominatedArea && focusKey !== undefined && !frontierKeys.has(focusKey) ? 0.35 : 1,
760
- stroke: resolvedFrontierColor,
761
- strokeWidth: frontierWidth,
762
- style: showAnimation ? {
763
- transition: "d 0.4s, opacity 0.2s"
764
- } : undefined
765
- }) : null]
766
- }), /*#__PURE__*/_jsxs("div", {
767
- className: styles.overlay,
768
- children: [points.map(function (point) {
769
- var pos = layout.positions.get(point.key);
770
- var markerPx = point.item.icon ? iconSize : markerSize;
771
- return /*#__PURE__*/_jsx("div", {
772
- children: renderTooltip(point, /*#__PURE__*/_jsx("div", {
773
- "aria-label": "".concat(toLabelText(point.item.name), ": ").concat(yFormatter(point.y), ", ").concat(activeMetric.formatter(point.x)),
774
- className: cx(styles.marker, animatedCls),
775
- onClick: function onClick() {
776
- return handleClick(point.item);
777
- },
778
- onMouseEnter: function onMouseEnter() {
779
- return setHoverKey(point.key);
780
- },
781
- onMouseLeave: function onMouseLeave() {
782
- return setHoverKey(undefined);
783
- },
784
- role: "button",
785
- style: {
786
- cursor: onValueChange ? 'pointer' : 'default',
787
- filter: getEmphasis(point.key) === 'dominated' ? 'grayscale(1)' : undefined,
788
- height: markerPx,
789
- left: pos.px,
790
- opacity: {
791
- dimmed: 0.25,
792
- dominated: 0.5,
793
- normal: 1
794
- }[getEmphasis(point.key)],
795
- top: pos.py,
796
- width: markerPx
797
- },
798
- children: renderMarker(point, markerPx, true)
799
- }))
800
- }, "marker-".concat(point.key));
801
- }), showLabels ? points.map(function (point) {
802
- var label = layout.labels.get(point.key);
803
- if (!label) return null;
804
- var emphasis = getEmphasis(point.key);
805
- var textColor = emphasis === 'dominated' ? cssVar.colorTextQuaternary : point.item.highlighted ? resolvedHighlightColor : undefined;
806
- var isKeyLabel = emphasis !== 'dominated' && (frontierKeys.has(point.key) || point.item.highlighted || point.key === focusKey);
807
- var align = label.placement.endsWith('left') ? 'right' : label.placement === 'top' || label.placement === 'bottom' ? 'center' : 'left';
808
- var name = toLabelText(point.item.name);
809
- return /*#__PURE__*/_jsxs("div", {
810
- className: cx(styles.label, animatedCls),
811
- onClick: function onClick() {
812
- return handleClick(point.item);
813
- },
814
- onMouseEnter: function onMouseEnter() {
815
- return setHoverKey(point.key);
816
- },
817
- onMouseLeave: function onMouseLeave() {
818
- return setHoverKey(undefined);
819
- },
820
- style: {
821
- cursor: onValueChange ? 'pointer' : 'default',
822
- height: label.height,
823
- left: label.x,
824
- opacity: emphasis === 'dimmed' ? 0.25 : 1,
825
- textAlign: align,
826
- top: label.y,
827
- width: label.width
828
- },
829
- children: [/*#__PURE__*/_jsx("div", {
830
- className: cx(styles.labelName, isKeyLabel && styles.labelNameEmphasis),
831
- style: textColor ? {
832
- color: textColor
833
- } : undefined,
834
- children: point.item.href ? /*#__PURE__*/_jsx(A, {
835
- className: styles.labelNameLink,
836
- href: point.item.href,
837
- onClick: function onClick(event) {
838
- return event.stopPropagation();
839
- },
840
- target: point.item.target,
841
- children: name
842
- }) : name
843
- }), showValueLabel ? /*#__PURE__*/_jsxs("div", {
844
- className: styles.labelValue,
845
- children: [yFormatter(point.y), " \xB7 ", activeMetric.formatter(point.x)]
846
- }) : null]
847
- }, "label-".concat(point.key));
848
- }) : null]
849
- })]
850
- }) : null]
851
- })]
852
- }));
853
- });
854
- BenchmarkScatterChart.displayName = 'BenchmarkScatterChart';
855
- export default BenchmarkScatterChart;