@lobehub/charts 6.0.1 → 6.1.0

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 (308) hide show
  1. package/README.md +8 -10
  2. package/es/AccuracyBarChart/index.d.mts +7 -5
  3. package/es/AccuracyBarChart/index.mjs +36 -37
  4. package/es/AccuracyBarChart/index.mjs.map +1 -1
  5. package/es/AccuracyBarChart/styles.d.mts +1 -4
  6. package/es/AccuracyBarChart/styles.mjs +6 -7
  7. package/es/AccuracyBarChart/styles.mjs.map +1 -1
  8. package/es/AreaChart/index.d.mts +11 -7
  9. package/es/AreaChart/index.mjs +100 -60
  10. package/es/AreaChart/index.mjs.map +1 -1
  11. package/es/AreaChart/styles.d.mts +1 -4
  12. package/es/AreaChart/styles.mjs +1 -2
  13. package/es/BarChart/A2uiBarChart.d.mts +56 -0
  14. package/es/BarChart/A2uiBarChart.mjs +368 -0
  15. package/es/BarChart/A2uiBarChart.mjs.map +1 -0
  16. package/es/BarChart/index.d.mts +10 -6
  17. package/es/BarChart/index.mjs +70 -33
  18. package/es/BarChart/index.mjs.map +1 -1
  19. package/es/BarChart/renderShape.d.mts +1 -4
  20. package/es/BarChart/renderShape.mjs +5 -6
  21. package/es/BarChart/renderShape.mjs.map +1 -1
  22. package/es/BarChart/styles.d.mts +1 -4
  23. package/es/BarChart/styles.mjs +1 -2
  24. package/es/BarList/index.d.mts +8 -6
  25. package/es/BarList/index.mjs +13 -14
  26. package/es/BarList/index.mjs.map +1 -1
  27. package/es/BarList/styles.d.mts +1 -4
  28. package/es/BarList/styles.mjs +3 -5
  29. package/es/BarList/styles.mjs.map +1 -1
  30. package/es/BenchmarkColumnChart/index.d.mts +8 -6
  31. package/es/BenchmarkColumnChart/index.mjs +38 -39
  32. package/es/BenchmarkColumnChart/index.mjs.map +1 -1
  33. package/es/BenchmarkColumnChart/styles.d.mts +1 -4
  34. package/es/BenchmarkColumnChart/styles.mjs +6 -8
  35. package/es/BenchmarkColumnChart/styles.mjs.map +1 -1
  36. package/es/BenchmarkRankingChart/index.d.mts +8 -6
  37. package/es/BenchmarkRankingChart/index.mjs +16 -17
  38. package/es/BenchmarkRankingChart/index.mjs.map +1 -1
  39. package/es/BenchmarkRankingChart/styles.d.mts +1 -4
  40. package/es/BenchmarkRankingChart/styles.mjs +25 -27
  41. package/es/BenchmarkRankingChart/styles.mjs.map +1 -1
  42. package/es/BenchmarkScatterChart/index.d.mts +7 -5
  43. package/es/BenchmarkScatterChart/index.mjs +22 -23
  44. package/es/BenchmarkScatterChart/index.mjs.map +1 -1
  45. package/es/BenchmarkScatterChart/styles.d.mts +1 -4
  46. package/es/BenchmarkScatterChart/styles.mjs +3 -2
  47. package/es/BenchmarkScatterChart/styles.mjs.map +1 -1
  48. package/es/BenchmarkScatterChart/utils.d.mts +1 -4
  49. package/es/BenchmarkScatterChart/utils.mjs +4 -5
  50. package/es/BenchmarkScatterChart/utils.mjs.map +1 -1
  51. package/es/CandlestickChart/index.d.mts +52 -0
  52. package/es/CandlestickChart/index.mjs +205 -0
  53. package/es/CandlestickChart/index.mjs.map +1 -0
  54. package/es/CandlestickChart/styles.d.mts +5 -0
  55. package/es/CandlestickChart/styles.mjs +24 -0
  56. package/es/CandlestickChart/styles.mjs.map +1 -0
  57. package/es/CandlestickChart/utils.d.mts +17 -0
  58. package/es/CandlestickChart/utils.mjs +56 -0
  59. package/es/CandlestickChart/utils.mjs.map +1 -0
  60. package/es/ChartFrame/index.d.mts +40 -0
  61. package/es/ChartFrame/index.mjs +18 -0
  62. package/es/ChartFrame/index.mjs.map +1 -0
  63. package/es/ComposedChart/index.d.mts +7 -5
  64. package/es/ComposedChart/index.mjs +37 -38
  65. package/es/ComposedChart/index.mjs.map +1 -1
  66. package/es/ComposedChart/styles.d.mts +1 -4
  67. package/es/ComposedChart/styles.mjs +1 -2
  68. package/es/ComposedChart/types.d.mts +3 -6
  69. package/es/DataBars/CategoryBar.d.mts +8 -6
  70. package/es/DataBars/CategoryBar.mjs +13 -14
  71. package/es/DataBars/CategoryBar.mjs.map +1 -1
  72. package/es/DataBars/DeltaBar.d.mts +7 -5
  73. package/es/DataBars/DeltaBar.mjs +10 -12
  74. package/es/DataBars/DeltaBar.mjs.map +1 -1
  75. package/es/DataBars/MarkerBar.d.mts +7 -5
  76. package/es/DataBars/MarkerBar.mjs +10 -12
  77. package/es/DataBars/MarkerBar.mjs.map +1 -1
  78. package/es/DataBars/ProgressBar.d.mts +7 -5
  79. package/es/DataBars/ProgressBar.mjs +10 -12
  80. package/es/DataBars/ProgressBar.mjs.map +1 -1
  81. package/es/DataBars/styles.d.mts +1 -4
  82. package/es/DataBars/styles.mjs +2 -3
  83. package/es/DataBars/styles.mjs.map +1 -1
  84. package/es/DonutChart/A2uiDonutChart.d.mts +35 -0
  85. package/es/DonutChart/A2uiDonutChart.mjs +189 -0
  86. package/es/DonutChart/A2uiDonutChart.mjs.map +1 -0
  87. package/es/DonutChart/DonutChartTooltip.d.mts +2 -5
  88. package/es/DonutChart/DonutChartTooltip.mjs +3 -4
  89. package/es/DonutChart/DonutChartTooltip.mjs.map +1 -1
  90. package/es/DonutChart/a2uiStyles.d.mts +13 -0
  91. package/es/DonutChart/a2uiStyles.mjs +90 -0
  92. package/es/DonutChart/a2uiStyles.mjs.map +1 -0
  93. package/es/DonutChart/index.d.mts +42 -9
  94. package/es/DonutChart/index.mjs +48 -16
  95. package/es/DonutChart/index.mjs.map +1 -1
  96. package/es/DonutChart/inputParser.d.mts +1 -4
  97. package/es/DonutChart/inputParser.mjs +1 -2
  98. package/es/DonutChart/inputParser.mjs.map +1 -1
  99. package/es/DonutChart/renderInactiveShape.d.mts +1 -4
  100. package/es/DonutChart/renderInactiveShape.mjs +1 -2
  101. package/es/DonutChart/styles.d.mts +1 -4
  102. package/es/DonutChart/styles.mjs +1 -2
  103. package/es/FunnelChart/ArrowRightIcon.d.mts +1 -4
  104. package/es/FunnelChart/ArrowRightIcon.mjs +1 -2
  105. package/es/FunnelChart/index.d.mts +7 -5
  106. package/es/FunnelChart/index.mjs +43 -44
  107. package/es/FunnelChart/index.mjs.map +1 -1
  108. package/es/FunnelChart/styles.d.mts +1 -4
  109. package/es/FunnelChart/styles.mjs +1 -2
  110. package/es/FunnelChart/types.d.mts +1 -4
  111. package/es/GaugeChart/index.d.mts +49 -0
  112. package/es/GaugeChart/index.mjs +77 -0
  113. package/es/GaugeChart/index.mjs.map +1 -0
  114. package/es/GaugeChart/styles.d.mts +9 -0
  115. package/es/GaugeChart/styles.mjs +73 -0
  116. package/es/GaugeChart/styles.mjs.map +1 -0
  117. package/es/GaugeChart/utils.d.mts +5 -0
  118. package/es/GaugeChart/utils.mjs +32 -0
  119. package/es/GaugeChart/utils.mjs.map +1 -0
  120. package/es/HeatmapChart/index.d.mts +68 -0
  121. package/es/HeatmapChart/index.mjs +162 -0
  122. package/es/HeatmapChart/index.mjs.map +1 -0
  123. package/es/HeatmapChart/styles.d.mts +4 -0
  124. package/es/HeatmapChart/styles.mjs +24 -0
  125. package/es/HeatmapChart/styles.mjs.map +1 -0
  126. package/es/HeatmapChart/utils.d.mts +18 -0
  127. package/es/HeatmapChart/utils.mjs +40 -0
  128. package/es/HeatmapChart/utils.mjs.map +1 -0
  129. package/es/Heatmaps/Calendar.d.mts +2 -5
  130. package/es/Heatmaps/Calendar.mjs +8 -9
  131. package/es/Heatmaps/Calendar.mjs.map +1 -1
  132. package/es/Heatmaps/ChartLabels.d.mts +2 -5
  133. package/es/Heatmaps/ChartLabels.mjs +3 -4
  134. package/es/Heatmaps/ChartLabels.mjs.map +1 -1
  135. package/es/Heatmaps/Footer.d.mts +1 -4
  136. package/es/Heatmaps/Footer.mjs +3 -4
  137. package/es/Heatmaps/index.d.mts +10 -8
  138. package/es/Heatmaps/index.mjs +10 -11
  139. package/es/Heatmaps/index.mjs.map +1 -1
  140. package/es/Heatmaps/styles.d.mts +1 -4
  141. package/es/Heatmaps/styles.mjs +2 -3
  142. package/es/Heatmaps/styles.mjs.map +1 -1
  143. package/es/Legend/LegendItem.d.mts +1 -4
  144. package/es/Legend/LegendItem.mjs +7 -8
  145. package/es/Legend/LegendItem.mjs.map +1 -1
  146. package/es/Legend/ScrollButton.d.mts +1 -4
  147. package/es/Legend/ScrollButton.mjs +6 -7
  148. package/es/Legend/ScrollButton.mjs.map +1 -1
  149. package/es/Legend/index.d.mts +7 -5
  150. package/es/Legend/index.mjs +13 -18
  151. package/es/Legend/index.mjs.map +1 -1
  152. package/es/LineChart/index.d.mts +11 -7
  153. package/es/LineChart/index.mjs +91 -53
  154. package/es/LineChart/index.mjs.map +1 -1
  155. package/es/LineChart/styles.d.mts +1 -4
  156. package/es/LineChart/styles.mjs +1 -2
  157. package/es/RadarChart/A2uiRadarChart.d.mts +37 -0
  158. package/es/RadarChart/A2uiRadarChart.mjs +203 -0
  159. package/es/RadarChart/A2uiRadarChart.mjs.map +1 -0
  160. package/es/RadarChart/index.d.mts +11 -7
  161. package/es/RadarChart/index.mjs +51 -18
  162. package/es/RadarChart/index.mjs.map +1 -1
  163. package/es/RadarChart/styles.d.mts +1 -4
  164. package/es/RadarChart/styles.mjs +1 -2
  165. package/es/SankeyChart/index.d.mts +73 -0
  166. package/es/SankeyChart/index.mjs +156 -0
  167. package/es/SankeyChart/index.mjs.map +1 -0
  168. package/es/SankeyChart/utils.d.mts +54 -0
  169. package/es/SankeyChart/utils.mjs +270 -0
  170. package/es/SankeyChart/utils.mjs.map +1 -0
  171. package/es/ScatterChart/A2uiScatterChart.d.mts +41 -0
  172. package/es/ScatterChart/A2uiScatterChart.mjs +259 -0
  173. package/es/ScatterChart/A2uiScatterChart.mjs.map +1 -0
  174. package/es/ScatterChart/ScatterChartTooltip.d.mts +2 -5
  175. package/es/ScatterChart/ScatterChartTooltip.mjs +7 -8
  176. package/es/ScatterChart/ScatterChartTooltip.mjs.map +1 -1
  177. package/es/ScatterChart/ScatterChartTooltipRow.d.mts +1 -4
  178. package/es/ScatterChart/ScatterChartTooltipRow.mjs +3 -4
  179. package/es/ScatterChart/ScatterChartTooltipRow.mjs.map +1 -1
  180. package/es/ScatterChart/index.d.mts +15 -9
  181. package/es/ScatterChart/index.mjs +70 -33
  182. package/es/ScatterChart/index.mjs.map +1 -1
  183. package/es/ScatterChart/renderShape.d.mts +1 -4
  184. package/es/ScatterChart/renderShape.mjs +4 -5
  185. package/es/ScatterChart/renderShape.mjs.map +1 -1
  186. package/es/ScatterChart/styles.d.mts +1 -4
  187. package/es/ScatterChart/styles.mjs +1 -2
  188. package/es/SparkChart/A2uiSparkChart.d.mts +41 -0
  189. package/es/SparkChart/A2uiSparkChart.mjs +179 -0
  190. package/es/SparkChart/A2uiSparkChart.mjs.map +1 -0
  191. package/es/SparkChart/SparkAreaChart.d.mts +12 -7
  192. package/es/SparkChart/SparkAreaChart.mjs +47 -22
  193. package/es/SparkChart/SparkAreaChart.mjs.map +1 -1
  194. package/es/SparkChart/SparkBarChart.d.mts +11 -6
  195. package/es/SparkChart/SparkBarChart.mjs +39 -16
  196. package/es/SparkChart/SparkBarChart.mjs.map +1 -1
  197. package/es/SparkChart/SparkLineChart.d.mts +12 -7
  198. package/es/SparkChart/SparkLineChart.mjs +41 -16
  199. package/es/SparkChart/SparkLineChart.mjs.map +1 -1
  200. package/es/SparkChart/index.d.mts +2 -1
  201. package/es/Tracker/TrackerBlock.d.mts +5 -5
  202. package/es/Tracker/TrackerBlock.mjs +8 -9
  203. package/es/Tracker/TrackerBlock.mjs.map +1 -1
  204. package/es/Tracker/index.d.mts +8 -6
  205. package/es/Tracker/index.mjs +11 -13
  206. package/es/Tracker/index.mjs.map +1 -1
  207. package/es/Tracker/styles.d.mts +1 -4
  208. package/es/Tracker/styles.mjs +1 -2
  209. package/es/TreemapChart/index.d.mts +64 -0
  210. package/es/TreemapChart/index.mjs +140 -0
  211. package/es/TreemapChart/index.mjs.map +1 -0
  212. package/es/TreemapChart/utils.d.mts +23 -0
  213. package/es/TreemapChart/utils.mjs +175 -0
  214. package/es/TreemapChart/utils.mjs.map +1 -0
  215. package/es/common/BaseAnimationTimingProps.d.mts +1 -4
  216. package/es/common/BaseChartProps.d.mts +3 -6
  217. package/es/common/BaseSparkChartProps.d.mts +2 -5
  218. package/es/common/ChartLegend.d.mts +1 -4
  219. package/es/common/ChartLegend.mjs +4 -5
  220. package/es/common/ChartLegend.mjs.map +1 -1
  221. package/es/common/ChartTooltip/ChartTooltipFrame.d.mts +1 -4
  222. package/es/common/ChartTooltip/ChartTooltipFrame.mjs +1 -2
  223. package/es/common/ChartTooltip/ChartTooltipFrame.mjs.map +1 -1
  224. package/es/common/ChartTooltip/ChartTooltipRow.d.mts +1 -4
  225. package/es/common/ChartTooltip/ChartTooltipRow.mjs +5 -6
  226. package/es/common/ChartTooltip/ChartTooltipRow.mjs.map +1 -1
  227. package/es/common/ChartTooltip/index.d.mts +2 -5
  228. package/es/common/ChartTooltip/index.mjs +3 -4
  229. package/es/common/ChartTooltip/index.mjs.map +1 -1
  230. package/es/common/CustomTooltipProps.d.mts +3 -6
  231. package/es/common/CustomYAxisTick.d.mts +2 -5
  232. package/es/common/CustomYAxisTick.mjs +1 -2
  233. package/es/common/CustomYAxisTick.mjs.map +1 -1
  234. package/es/common/NoData.d.mts +1 -4
  235. package/es/common/NoData.mjs +2 -3
  236. package/es/common/NoData.mjs.map +1 -1
  237. package/es/common/a2ui/A2uiTrendChart.d.mts +43 -0
  238. package/es/common/a2ui/A2uiTrendChart.mjs +353 -0
  239. package/es/common/a2ui/A2uiTrendChart.mjs.map +1 -0
  240. package/es/common/a2ui/Frame.d.mts +20 -0
  241. package/es/common/a2ui/Frame.mjs +43 -0
  242. package/es/common/a2ui/Frame.mjs.map +1 -0
  243. package/es/common/a2ui/HoverTooltip.d.mts +28 -0
  244. package/es/common/a2ui/HoverTooltip.mjs +36 -0
  245. package/es/common/a2ui/HoverTooltip.mjs.map +1 -0
  246. package/es/common/a2ui/Legend.d.mts +11 -0
  247. package/es/common/a2ui/Legend.mjs +33 -0
  248. package/es/common/a2ui/Legend.mjs.map +1 -0
  249. package/es/common/a2ui/PlacedTooltip.d.mts +22 -0
  250. package/es/common/a2ui/PlacedTooltip.mjs +58 -0
  251. package/es/common/a2ui/PlacedTooltip.mjs.map +1 -0
  252. package/es/common/a2ui/Tooltip.d.mts +13 -0
  253. package/es/common/a2ui/Tooltip.mjs +33 -0
  254. package/es/common/a2ui/Tooltip.mjs.map +1 -0
  255. package/es/common/a2ui/axis.d.mts +38 -0
  256. package/es/common/a2ui/axis.mjs +48 -0
  257. package/es/common/a2ui/axis.mjs.map +1 -0
  258. package/es/common/a2ui/curve.d.mts +20 -0
  259. package/es/common/a2ui/curve.mjs +58 -0
  260. package/es/common/a2ui/curve.mjs.map +1 -0
  261. package/es/common/a2ui/format.d.mts +17 -0
  262. package/es/common/a2ui/format.mjs +56 -0
  263. package/es/common/a2ui/format.mjs.map +1 -0
  264. package/es/common/a2ui/index.d.mts +16 -0
  265. package/es/common/a2ui/index.mjs +15 -0
  266. package/es/common/a2ui/scale.d.mts +20 -0
  267. package/es/common/a2ui/scale.mjs +112 -0
  268. package/es/common/a2ui/scale.mjs.map +1 -0
  269. package/es/common/a2ui/styles.d.mts +35 -0
  270. package/es/common/a2ui/styles.mjs +254 -0
  271. package/es/common/a2ui/styles.mjs.map +1 -0
  272. package/es/common/a2ui/tokens.d.mts +20 -0
  273. package/es/common/a2ui/tokens.mjs +103 -0
  274. package/es/common/a2ui/tokens.mjs.map +1 -0
  275. package/es/common/a2ui/types.d.mts +25 -0
  276. package/es/common/a2ui/types.mjs +0 -0
  277. package/es/common/a2ui/useA2uiTheme.d.mts +2 -0
  278. package/es/common/a2ui/useA2uiTheme.mjs +11 -0
  279. package/es/common/a2ui/useA2uiTheme.mjs.map +1 -0
  280. package/es/common/a2ui/useElementWidth.d.mts +2 -0
  281. package/es/common/a2ui/useElementWidth.mjs +31 -0
  282. package/es/common/a2ui/useElementWidth.mjs.map +1 -0
  283. package/es/common/benchmark/types.d.mts +2 -5
  284. package/es/common/benchmark/utils.d.mts +1 -4
  285. package/es/common/benchmark/utils.mjs +1 -2
  286. package/es/common/utils.d.mts +1 -4
  287. package/es/common/utils.mjs +1 -2
  288. package/es/hooks/useOnWindowResize.d.mts +1 -4
  289. package/es/hooks/useOnWindowResize.mjs +2 -3
  290. package/es/hooks/usePrefersReducedMotion.d.mts +1 -4
  291. package/es/hooks/usePrefersReducedMotion.mjs +2 -3
  292. package/es/hooks/useThemeColorRange.d.mts +1 -4
  293. package/es/hooks/useThemeColorRange.mjs +1 -2
  294. package/es/index.d.mts +20 -9
  295. package/es/index.mjs +15 -9
  296. package/es/types/charts.d.mts +1 -4
  297. package/es/types/charts.mjs +1 -2
  298. package/es/utils/calendar.d.mts +2 -5
  299. package/es/utils/calendar.mjs +2 -3
  300. package/es/utils/getMaxLabelLength.d.mts +1 -4
  301. package/es/utils/getMaxLabelLength.mjs +1 -2
  302. package/es/utils/getMaxLabelLength.mjs.map +1 -1
  303. package/es/utils/index.d.mts +1 -4
  304. package/es/utils/index.mjs +1 -2
  305. package/es/utils/index.mjs.map +1 -1
  306. package/es/utils/theme.d.mts +1 -4
  307. package/es/utils/theme.mjs +1 -2
  308. package/package.json +32 -8
@@ -1,18 +1,18 @@
1
1
  "use client";
2
- import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
3
- import { defaultValueFormatter } from "../utils/index.mjs";
2
+ import { Flexbox, Skeleton, css, cssVar, cx } from "@lobehub/ui";
3
+ import { useMemo, useState } from "react";
4
+ import { Bar, CartesianGrid, ComposedChart as ComposedChart$1, Label, Legend, Line, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
4
5
  import ChartLegend from "../common/ChartLegend.mjs";
5
6
  import ChartTooltip from "../common/ChartTooltip/index.mjs";
6
7
  import CustomYAxisTick from "../common/CustomYAxisTick.mjs";
7
8
  import NoData from "../common/NoData.mjs";
9
+ import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
10
+ import { defaultValueFormatter } from "../utils/index.mjs";
8
11
  import { getMaxLabelLength } from "../utils/getMaxLabelLength.mjs";
9
12
  import { styles } from "./styles.mjs";
10
- import { Flexbox, Skeleton, css, cssVar, cx } from "@lobehub/ui";
11
- import { forwardRef, useMemo, useState } from "react";
12
- import { Bar, CartesianGrid, ComposedChart as ComposedChart$1, Label, Legend, Line, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
- //#region src/ComposedChart/index.tsx
15
- const ComposedChart = forwardRef((props, ref) => {
14
+ // src/ComposedChart/index.tsx
15
+ const ComposedChart = ({ ref, ...props }) => {
16
16
  const themeColorRange = useThemeColorRange();
17
17
  const { data = [], index, series = [], yAxisLeft, yAxisRight, colors = themeColorRange, xAxisLabelFormatter = defaultValueFormatter, startEndOnly = false, animationDuration = 900, showAnimation = false, showXAxis = true, showYAxis = true, intervalType = "equidistantPreserveStart", showTooltip = true, showLegend = true, showGridLines = true, allowDecimals = true, noDataText, enableLegendSlider = false, rotateLabelX, tickGap = 5, loading, xAxisLabel, className, width = "100%", height = 280, style, ...rest } = props;
18
18
  const [legendHeight, setLegendHeight] = useState(60);
@@ -84,8 +84,8 @@ const ComposedChart = forwardRef((props, ref) => {
84
84
  },
85
85
  children: [
86
86
  showGridLines && /* @__PURE__ */ jsx(CartesianGrid, {
87
- className: styles.gridLines,
88
87
  horizontal: true,
88
+ className: styles.gridLines,
89
89
  vertical: false
90
90
  }),
91
91
  /* @__PURE__ */ jsx(XAxis, {
@@ -128,17 +128,17 @@ const ComposedChart = forwardRef((props, ref) => {
128
128
  hide: !showYAxis,
129
129
  orientation: "left",
130
130
  stroke: "",
131
+ tickFormatter: yAxisLeft?.valueFormatter ?? defaultValueFormatter,
132
+ tickLine: false,
133
+ type: "number",
134
+ width: leftYAxisWidth,
135
+ yAxisId: "left",
131
136
  tick: (tickProps) => /* @__PURE__ */ jsx(CustomYAxisTick, {
132
137
  ...tickProps,
133
138
  align: "left",
134
139
  formatter: yAxisLeft?.valueFormatter ?? defaultValueFormatter,
135
140
  yAxisLabel: Boolean(yAxisLeft?.label)
136
141
  }),
137
- tickFormatter: yAxisLeft?.valueFormatter ?? defaultValueFormatter,
138
- tickLine: false,
139
- type: "number",
140
- width: leftYAxisWidth,
141
- yAxisId: "left",
142
142
  children: yAxisLeft?.label && /* @__PURE__ */ jsx(Label, {
143
143
  angle: -90,
144
144
  className: styles.emphasis,
@@ -161,6 +161,11 @@ const ComposedChart = forwardRef((props, ref) => {
161
161
  hide: !showYAxis,
162
162
  orientation: "right",
163
163
  stroke: "",
164
+ tickFormatter: yAxisRight?.valueFormatter ?? defaultValueFormatter,
165
+ tickLine: false,
166
+ type: "number",
167
+ width: rightYAxisWidth,
168
+ yAxisId: "right",
164
169
  tick: (tickProps) => /* @__PURE__ */ jsx(CustomYAxisTick, {
165
170
  ...tickProps,
166
171
  align: "right",
@@ -168,11 +173,6 @@ const ComposedChart = forwardRef((props, ref) => {
168
173
  formatter: yAxisRight?.valueFormatter ?? defaultValueFormatter,
169
174
  yAxisLabel: Boolean(yAxisRight?.label)
170
175
  }),
171
- tickFormatter: yAxisRight?.valueFormatter ?? defaultValueFormatter,
172
- tickLine: false,
173
- type: "number",
174
- width: rightYAxisWidth,
175
- yAxisId: "right",
176
176
  children: yAxisRight?.label && /* @__PURE__ */ jsx(Label, {
177
177
  angle: 90,
178
178
  className: styles.emphasis,
@@ -187,29 +187,26 @@ const ComposedChart = forwardRef((props, ref) => {
187
187
  })
188
188
  }),
189
189
  showLegend && /* @__PURE__ */ jsx(Legend, {
190
- content: ({ payload }) => ChartLegend({ payload }, categoryColors, setLegendHeight, void 0, void 0, enableLegendSlider, customCategories),
191
190
  height: legendHeight,
192
- verticalAlign: "top"
191
+ verticalAlign: "top",
192
+ content: ({ payload }) => ChartLegend({ payload }, categoryColors, setLegendHeight, void 0, void 0, enableLegendSlider, customCategories)
193
193
  }),
194
194
  series.map((s) => {
195
195
  const color = seriesColorMap.get(s.key) ?? cssVar.colorPrimary;
196
196
  const axisId = s.axis ?? "left";
197
197
  if (s.type === "bar") return /* @__PURE__ */ jsx(Bar, {
198
198
  animationDuration,
199
- className: cx(css`
200
- fill: ${color};
201
- `),
202
199
  dataKey: s.key,
203
200
  fill: "",
204
201
  isAnimationActive: showAnimation,
205
202
  name: s.key,
206
- yAxisId: axisId
203
+ yAxisId: axisId,
204
+ className: cx(css`
205
+ fill: ${color};
206
+ `)
207
207
  }, s.key);
208
208
  if (s.type === "line") return /* @__PURE__ */ jsx(Line, {
209
209
  animationDuration,
210
- className: cx(css`
211
- stroke: ${color};
212
- `),
213
210
  dataKey: s.key,
214
211
  dot: false,
215
212
  isAnimationActive: showAnimation,
@@ -217,11 +214,21 @@ const ComposedChart = forwardRef((props, ref) => {
217
214
  stroke: "",
218
215
  strokeWidth: 2,
219
216
  type: "monotone",
220
- yAxisId: axisId
217
+ yAxisId: axisId,
218
+ className: cx(css`
219
+ stroke: ${color};
220
+ `)
221
221
  }, s.key);
222
222
  return null;
223
223
  }),
224
224
  showTooltip && /* @__PURE__ */ jsx(Tooltip$1, {
225
+ cursor: {
226
+ stroke: cssVar.colorTextSecondary,
227
+ strokeWidth: 1
228
+ },
229
+ isAnimationActive: false,
230
+ position: { y: 0 },
231
+ wrapperStyle: { outline: "none" },
225
232
  content: ({ active, payload, label }) => /* @__PURE__ */ jsx(ChartTooltip, {
226
233
  active,
227
234
  categoryColors,
@@ -232,21 +239,13 @@ const ComposedChart = forwardRef((props, ref) => {
232
239
  const currentSeries = series.find((item) => item.key === name);
233
240
  return (currentSeries?.valueFormatter ?? (currentSeries?.axis === "right" ? yAxisRight?.valueFormatter : yAxisLeft?.valueFormatter) ?? defaultValueFormatter)(value);
234
241
  }
235
- }),
236
- cursor: {
237
- stroke: cssVar.colorTextSecondary,
238
- strokeWidth: 1
239
- },
240
- isAnimationActive: false,
241
- position: { y: 0 },
242
- wrapperStyle: { outline: "none" }
242
+ })
243
243
  })
244
244
  ]
245
245
  }) : /* @__PURE__ */ jsx(NoData, { noDataText }) })
246
246
  });
247
- });
247
+ };
248
248
  ComposedChart.displayName = "ComposedChart";
249
- //#endregion
250
249
  export { ComposedChart as default };
251
250
 
252
251
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["ReChartsComposedChart","Tooltip"],"sources":["../../src/ComposedChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, Skeleton, css, cssVar, cx } from '@lobehub/ui';\nimport { forwardRef, useMemo, useState } from 'react';\nimport {\n Bar,\n CartesianGrid,\n Label,\n Legend,\n Line,\n ComposedChart as ReChartsComposedChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\n\nimport ChartLegend from '@/common/ChartLegend';\nimport ChartTooltip from '@/common/ChartTooltip';\nimport CustomYAxisTick from '@/common/CustomYAxisTick';\nimport NoData from '@/common/NoData';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { defaultValueFormatter } from '@/utils';\nimport { getMaxLabelLength } from '@/utils/getMaxLabelLength';\n\nimport { styles } from './styles';\nimport type { ComposedChartProps } from './types';\n\nexport type { ComposedChartProps, SeriesItem, YAxisConfig } from './types';\n\nconst ComposedChart = forwardRef<HTMLDivElement, ComposedChartProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n index,\n series = [],\n yAxisLeft,\n yAxisRight,\n colors = themeColorRange,\n xAxisLabelFormatter = defaultValueFormatter,\n startEndOnly = false,\n animationDuration = 900,\n showAnimation = false,\n showXAxis = true,\n showYAxis = true,\n intervalType = 'equidistantPreserveStart',\n showTooltip = true,\n showLegend = true,\n showGridLines = true,\n allowDecimals = true,\n noDataText,\n enableLegendSlider = false,\n rotateLabelX,\n tickGap = 5,\n loading,\n xAxisLabel,\n className,\n width = '100%',\n height = 280,\n style,\n ...rest\n } = props;\n\n const [legendHeight, setLegendHeight] = useState(60);\n\n const seriesColorMap = useMemo(() => {\n const map = new Map<string, string>();\n series.forEach((s, i) => {\n map.set(s.key, s.color ?? colors[i % colors.length]);\n });\n return map;\n }, [series, colors]);\n\n const categoryColors = seriesColorMap;\n const customCategories = useMemo(() => {\n return series.reduce<Record<string, string>>((acc, item) => {\n if (item.name) acc[item.key] = item.name;\n return acc;\n }, {});\n }, [series]);\n\n const hasRightAxis = series.some((s) => s.axis === 'right');\n\n const leftYAxisWidth = useMemo(() => {\n if (yAxisLeft?.width) return yAxisLeft.width;\n const leftFormatter = yAxisLeft?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: leftFormatter });\n }, [yAxisLeft, data, index]);\n\n const rightYAxisWidth = useMemo(() => {\n if (yAxisRight?.width) return yAxisRight.width;\n const rightFormatter = yAxisRight?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: rightFormatter });\n }, [yAxisRight, data, index]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const paddingValue = !showXAxis && !showYAxis ? 0 : 20;\n\n return (\n <Flexbox\n className={className}\n height={height}\n ref={ref}\n style={{ position: 'relative', ...style }}\n width={width}\n {...rest}\n >\n <ResponsiveContainer>\n {data?.length ? (\n <ReChartsComposedChart\n data={data}\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLeft?.label ? 20 : undefined,\n right: hasRightAxis ? (yAxisRight?.label ? 20 : 5) : undefined,\n top: 5,\n }}\n >\n {showGridLines && (\n <CartesianGrid className={styles.gridLines} horizontal vertical={false} />\n )}\n\n <XAxis\n angle={rotateLabelX?.angle}\n axisLine={false}\n className={styles.label}\n dataKey={index}\n dy={rotateLabelX?.verticalShift}\n fill=\"\"\n hide={!showXAxis}\n interval={startEndOnly ? 'preserveStartEnd' : intervalType}\n minTickGap={tickGap}\n padding={{ left: paddingValue, right: paddingValue }}\n stroke=\"\"\n tick={{ transform: 'translate(0, 6)' }}\n tickFormatter={xAxisLabelFormatter}\n tickLine={false}\n ticks={startEndOnly ? [data[0][index], data.at(-1)?.[index]] : undefined}\n >\n {xAxisLabel && (\n <Label\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-20}\n position=\"insideBottom\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {xAxisLabel}\n </Label>\n )}\n </XAxis>\n\n {/* Left Y Axis */}\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisLeft?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"left\"\n stroke=\"\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"left\"\n formatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisLeft?.label)}\n />\n )}\n tickFormatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={leftYAxisWidth}\n yAxisId=\"left\"\n >\n {yAxisLeft?.label && (\n <Label\n angle={-90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideLeft\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisLeft.label}\n </Label>\n )}\n </YAxis>\n\n {/* Right Y Axis */}\n {hasRightAxis && (\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisRight?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"right\"\n stroke=\"\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"right\"\n anchor=\"start\"\n formatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisRight?.label)}\n />\n )}\n tickFormatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={rightYAxisWidth}\n yAxisId=\"right\"\n >\n {yAxisRight?.label && (\n <Label\n angle={90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideRight\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisRight.label}\n </Label>\n )}\n </YAxis>\n )}\n\n {showLegend && (\n <Legend\n content={({ payload }) =>\n ChartLegend(\n { payload },\n categoryColors,\n setLegendHeight,\n undefined,\n undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n height={legendHeight}\n verticalAlign=\"top\"\n />\n )}\n\n {series.map((s) => {\n const color = seriesColorMap.get(s.key) ?? cssVar.colorPrimary;\n const axisId = s.axis ?? 'left';\n\n if (s.type === 'bar') {\n return (\n <Bar\n animationDuration={animationDuration}\n className={cx(css`\n fill: ${color};\n `)}\n dataKey={s.key}\n fill=\"\"\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n yAxisId={axisId}\n />\n );\n }\n\n if (s.type === 'line') {\n return (\n <Line\n animationDuration={animationDuration}\n className={cx(css`\n stroke: ${color};\n `)}\n dataKey={s.key}\n dot={false}\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n stroke=\"\"\n strokeWidth={2}\n type=\"monotone\"\n yAxisId={axisId}\n />\n );\n }\n\n return null;\n })}\n\n {showTooltip && (\n <Tooltip\n content={({ active, payload, label }) => (\n <ChartTooltip\n active={active}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={label}\n payload={payload}\n valueFormatter={(value, name) => {\n const currentSeries = series.find((item) => item.key === name);\n const formatter =\n currentSeries?.valueFormatter ??\n (currentSeries?.axis === 'right'\n ? yAxisRight?.valueFormatter\n : yAxisLeft?.valueFormatter) ??\n defaultValueFormatter;\n\n return formatter(value);\n }}\n />\n )}\n cursor={{ stroke: cssVar.colorTextSecondary, strokeWidth: 1 }}\n isAnimationActive={false}\n position={{ y: 0 }}\n wrapperStyle={{ outline: 'none' }}\n />\n )}\n </ReChartsComposedChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n});\n\nComposedChart.displ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AI,EAAE,GAAG,KAAK,OAAO;KAClD,MAAM,SAAS,EAAE,QAAQ;KAEzB,IAAI,EAAE,SAAS,OACb,OACE,oBAAC,KAAD;MACqB;MACnB,WAAW,GAAG,GAAG;8BACP,MAAM;qBACf;MACD,SAAS,EAAE;MACX,MAAK;MACL,mBAAmB;MAEnB,MAAM,EAAE;MACR,SAAS;KACV,GAHM,EAAE,GAGR;KAIL,IAAI,EAAE,SAAS,QACb,OACE,oBAAC,MAAD;MACqB;MACnB,WAAW,GAAG,GAAG;gCACL,MAAM;qBACjB;MACD,SAAS,EAAE;MACX,KAAK;MACL,mBAAmB;MAEnB,MAAM,EAAE;MACR,QAAO;MACP,aAAa;MACb,MAAK;MACL,SAAS;KACV,GANM,EAAE,GAMR;KAIL,OAAO;IACT,CAAC;IAEA,eACC,oBAACC,WAAD;KACE,UAAU,EAAE,QAAQ,SAAS,YAC3B,oBAAC,cAAD;MACU;MACQ;MACE;MACX;MACE;MACT,iBAAiB,OAAO,SAAS;OAC/B,MAAM,gBAAgB,OAAO,MAAM,SAAS,KAAK,QAAQ,IAAI;OAQ7D,QANE,eAAe,mBACd,eAAe,SAAS,UACrB,YAAY,iBACZ,WAAW,mBACf,sBAAA,CAEe,KAAK;MACxB;KACD,CAAA;KAEH,QAAQ;MAAE,QAAQ,OAAO;MAAoB,aAAa;KAAE;KAC5D,mBAAmB;KACnB,UAAU,EAAE,GAAG,EAAE;KACjB,cAAc,EAAE,SAAS,OAAO;IACjC,CAAA;GAEkB;EAEvB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb,CAAC;AAED,cAAc,cAAc"}
1
+ {"version":3,"file":"index.mjs","names":["ReChartsComposedChart","Tooltip"],"sources":["../../src/ComposedChart/index.tsx"],"sourcesContent":["'use client';\n\nimport { css, cssVar, cx, Flexbox, Skeleton } from '@lobehub/ui';\nimport { useMemo, useState } from 'react';\nimport {\n Bar,\n CartesianGrid,\n ComposedChart as ReChartsComposedChart,\n Label,\n Legend,\n Line,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from 'recharts';\n\nimport ChartLegend from '@/common/ChartLegend';\nimport ChartTooltip from '@/common/ChartTooltip';\nimport CustomYAxisTick from '@/common/CustomYAxisTick';\nimport NoData from '@/common/NoData';\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { defaultValueFormatter } from '@/utils';\nimport { getMaxLabelLength } from '@/utils/getMaxLabelLength';\n\nimport { styles } from './styles';\nimport type { ComposedChartProps } from './types';\n\nexport type { ComposedChartProps, SeriesItem, YAxisConfig } from './types';\n\nconst ComposedChart = ({\n ref,\n ...props\n}: ComposedChartProps & { ref?: React.Ref<HTMLDivElement> }) => {\n const themeColorRange = useThemeColorRange();\n const {\n data = [],\n index,\n series = [],\n yAxisLeft,\n yAxisRight,\n colors = themeColorRange,\n xAxisLabelFormatter = defaultValueFormatter,\n startEndOnly = false,\n animationDuration = 900,\n showAnimation = false,\n showXAxis = true,\n showYAxis = true,\n intervalType = 'equidistantPreserveStart',\n showTooltip = true,\n showLegend = true,\n showGridLines = true,\n allowDecimals = true,\n noDataText,\n enableLegendSlider = false,\n rotateLabelX,\n tickGap = 5,\n loading,\n xAxisLabel,\n className,\n width = '100%',\n height = 280,\n style,\n ...rest\n } = props;\n\n const [legendHeight, setLegendHeight] = useState(60);\n\n const seriesColorMap = useMemo(() => {\n const map = new Map<string, string>();\n series.forEach((s, i) => {\n map.set(s.key, s.color ?? colors[i % colors.length]);\n });\n return map;\n }, [series, colors]);\n\n const categoryColors = seriesColorMap;\n const customCategories = useMemo(() => {\n return series.reduce<Record<string, string>>((acc, item) => {\n if (item.name) acc[item.key] = item.name;\n return acc;\n }, {});\n }, [series]);\n\n const hasRightAxis = series.some((s) => s.axis === 'right');\n\n const leftYAxisWidth = useMemo(() => {\n if (yAxisLeft?.width) return yAxisLeft.width;\n const leftFormatter = yAxisLeft?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: leftFormatter });\n }, [yAxisLeft, data, index]);\n\n const rightYAxisWidth = useMemo(() => {\n if (yAxisRight?.width) return yAxisRight.width;\n const rightFormatter = yAxisRight?.valueFormatter ?? defaultValueFormatter;\n return getMaxLabelLength({ data, index, layout: 'horizontal', valueFormatter: rightFormatter });\n }, [yAxisRight, data, index]);\n\n if (loading || !data) return <Skeleton height={height} width={width} />;\n\n const paddingValue = !showXAxis && !showYAxis ? 0 : 20;\n\n return (\n <Flexbox\n className={className}\n height={height}\n ref={ref}\n style={{ position: 'relative', ...style }}\n width={width}\n {...rest}\n >\n <ResponsiveContainer>\n {data?.length ? (\n <ReChartsComposedChart\n data={data}\n margin={{\n bottom: xAxisLabel ? 30 : undefined,\n left: yAxisLeft?.label ? 20 : undefined,\n right: hasRightAxis ? (yAxisRight?.label ? 20 : 5) : undefined,\n top: 5,\n }}\n >\n {showGridLines && (\n <CartesianGrid horizontal className={styles.gridLines} vertical={false} />\n )}\n\n <XAxis\n angle={rotateLabelX?.angle}\n axisLine={false}\n className={styles.label}\n dataKey={index}\n dy={rotateLabelX?.verticalShift}\n fill=\"\"\n hide={!showXAxis}\n interval={startEndOnly ? 'preserveStartEnd' : intervalType}\n minTickGap={tickGap}\n padding={{ left: paddingValue, right: paddingValue }}\n stroke=\"\"\n tick={{ transform: 'translate(0, 6)' }}\n tickFormatter={xAxisLabelFormatter}\n tickLine={false}\n ticks={startEndOnly ? [data[0][index], data.at(-1)?.[index]] : undefined}\n >\n {xAxisLabel && (\n <Label\n className={cx(styles.strongLabel, styles.emphasis)}\n offset={-20}\n position=\"insideBottom\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {xAxisLabel}\n </Label>\n )}\n </XAxis>\n\n {/* Left Y Axis */}\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisLeft?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"left\"\n stroke=\"\"\n tickFormatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={leftYAxisWidth}\n yAxisId=\"left\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"left\"\n formatter={yAxisLeft?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisLeft?.label)}\n />\n )}\n >\n {yAxisLeft?.label && (\n <Label\n angle={-90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideLeft\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisLeft.label}\n </Label>\n )}\n </YAxis>\n\n {/* Right Y Axis */}\n {hasRightAxis && (\n <YAxis\n allowDecimals={allowDecimals}\n axisLine={false}\n className={styles.label}\n domain={yAxisRight?.domain}\n fill=\"\"\n hide={!showYAxis}\n orientation=\"right\"\n stroke=\"\"\n tickFormatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n tickLine={false}\n type=\"number\"\n width={rightYAxisWidth}\n yAxisId=\"right\"\n tick={(tickProps) => (\n <CustomYAxisTick\n {...tickProps}\n align=\"right\"\n anchor=\"start\"\n formatter={yAxisRight?.valueFormatter ?? defaultValueFormatter}\n yAxisLabel={Boolean(yAxisRight?.label)}\n />\n )}\n >\n {yAxisRight?.label && (\n <Label\n angle={90}\n className={styles.emphasis}\n offset={-15}\n position=\"insideRight\"\n style={{\n fill: cssVar.colorTextSecondary,\n fontWeight: 500,\n textAnchor: 'middle',\n }}\n >\n {yAxisRight.label}\n </Label>\n )}\n </YAxis>\n )}\n\n {showLegend && (\n <Legend\n height={legendHeight}\n verticalAlign=\"top\"\n content={({ payload }) =>\n ChartLegend(\n { payload },\n categoryColors,\n setLegendHeight,\n undefined,\n undefined,\n enableLegendSlider,\n customCategories,\n )\n }\n />\n )}\n\n {series.map((s) => {\n const color = seriesColorMap.get(s.key) ?? cssVar.colorPrimary;\n const axisId = s.axis ?? 'left';\n\n if (s.type === 'bar') {\n return (\n <Bar\n animationDuration={animationDuration}\n dataKey={s.key}\n fill=\"\"\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n yAxisId={axisId}\n className={cx(css`\n fill: ${color};\n `)}\n />\n );\n }\n\n if (s.type === 'line') {\n return (\n <Line\n animationDuration={animationDuration}\n dataKey={s.key}\n dot={false}\n isAnimationActive={showAnimation}\n key={s.key}\n name={s.key}\n stroke=\"\"\n strokeWidth={2}\n type=\"monotone\"\n yAxisId={axisId}\n className={cx(css`\n stroke: ${color};\n `)}\n />\n );\n }\n\n return null;\n })}\n\n {showTooltip && (\n <Tooltip\n cursor={{ stroke: cssVar.colorTextSecondary, strokeWidth: 1 }}\n isAnimationActive={false}\n position={{ y: 0 }}\n wrapperStyle={{ outline: 'none' }}\n content={({ active, payload, label }) => (\n <ChartTooltip\n active={active}\n categoryColors={categoryColors}\n customCategories={customCategories}\n label={label}\n payload={payload}\n valueFormatter={(value, name) => {\n const currentSeries = series.find((item) => item.key === name);\n const formatter =\n currentSeries?.valueFormatter ??\n (currentSeries?.axis === 'right'\n ? yAxisRight?.valueFormatter\n : yAxisLeft?.valueFormatter) ??\n defaultValueFormatter;\n\n return formatter(value);\n }}\n />\n )}\n />\n )}\n </ReChartsComposedChart>\n ) : (\n <NoData noDataText={noDataText} />\n )}\n </ResponsiveContainer>\n </Flexbox>\n );\n};\n\nComposedChart.displayName = 'ComposedChart';\n\nexport default ComposedChart;\n"],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,iBAAiB,EACrB,KACA,GAAG,YAC2D;CAC9D,MAAM,kBAAkB,mBAAmB;CAC3C,MAAM,EACJ,OAAO,CAAC,GACR,OACA,SAAS,CAAC,GACV,WACA,YACA,SAAS,iBACT,sBAAsB,uBACtB,eAAe,OACf,oBAAoB,KACpB,gBAAgB,OAChB,YAAY,MACZ,YAAY,MACZ,eAAe,4BACf,cAAc,MACd,aAAa,MACb,gBAAgB,MACh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AAmB;MAEnB,MAAM,EAAE;MACR,QAAO;MACP,aAAa;MACb,MAAK;MACL,SAAS;MACT,WAAW,GAAG,GAAG;gCACL,MAAM;qBACjB;KACF,GATM,EAAE,GASR;KAIL,OAAO;IACT,CAAC;IAEA,eACC,oBAACC,WAAD;KACE,QAAQ;MAAE,QAAQ,OAAO;MAAoB,aAAa;KAAE;KAC5D,mBAAmB;KACnB,UAAU,EAAE,GAAG,EAAE;KACjB,cAAc,EAAE,SAAS,OAAO;KAChC,UAAU,EAAE,QAAQ,SAAS,YAC3B,oBAAC,cAAD;MACU;MACQ;MACE;MACX;MACE;MACT,iBAAiB,OAAO,SAAS;OAC/B,MAAM,gBAAgB,OAAO,MAAM,SAAS,KAAK,QAAQ,IAAI;OAQ7D,QANE,eAAe,mBACd,eAAe,SAAS,UACrB,YAAY,iBACZ,WAAW,mBACf,sBAAA,CAEe,KAAK;MACxB;KACD,CAAA;IAEJ,CAAA;GAEkB;EAEvB,CAAA,IAAA,oBAAC,QAAD,EAAoB,WAAa,CAAA,EAEhB,CAAA;CACd,CAAA;AAEb;AAEA,cAAc,cAAc"}
@@ -1,9 +1,6 @@
1
- //#region src/ComposedChart/styles.d.ts
2
1
  export declare const styles: {
3
2
  emphasis: string;
4
3
  gridLines: string;
5
4
  label: string;
6
5
  strongLabel: string;
7
- };
8
- //#endregion
9
- //# sourceMappingURL=styles.d.mts.map
6
+ };
@@ -1,5 +1,5 @@
1
1
  import { createStaticStyles } from "@lobehub/ui";
2
- //#region src/ComposedChart/styles.ts
2
+ // src/ComposedChart/styles.ts
3
3
  const styles = createStaticStyles(({ css, cssVar }) => ({
4
4
  emphasis: css`
5
5
  overflow: hidden;
@@ -22,7 +22,6 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
22
22
  fill: ${cssVar.colorTextSecondary};
23
23
  `
24
24
  }));
25
- //#endregion
26
25
  export { styles };
27
26
 
28
27
  //# sourceMappingURL=styles.mjs.map
@@ -1,9 +1,8 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { AxisDomain } from "recharts/types/util/types";
1
3
  import { NoDataProps } from "../common/NoData.mjs";
2
4
  import { IntervalType, LabelFormatter, ValueFormatter } from "../types/charts.mjs";
3
5
  import BaseAnimationTimingProps from "../common/BaseAnimationTimingProps.mjs";
4
- import { HTMLAttributes } from "react";
5
- import { AxisDomain } from "recharts/types/util/types";
6
- //#region src/ComposedChart/types.d.ts
7
6
  export interface SeriesItem {
8
7
  /**
9
8
  * Which y-axis this series is bound to.
@@ -66,6 +65,4 @@ export interface ComposedChartProps extends BaseAnimationTimingProps, HTMLAttrib
66
65
  yAxisLeft?: YAxisConfig;
67
66
  /** Right y-axis configuration */
68
67
  yAxisRight?: YAxisConfig;
69
- }
70
- //#endregion
71
- //# sourceMappingURL=types.d.mts.map
68
+ }
@@ -1,6 +1,5 @@
1
- import { ValueFormatter } from "../types/charts.mjs";
2
1
  import { FlexboxProps } from "@lobehub/ui";
3
- //#region src/DataBars/CategoryBar.d.ts
2
+ import { ValueFormatter } from "../types/charts.mjs";
4
3
  export interface CategoryBarProps extends FlexboxProps {
5
4
  colors?: string[];
6
5
  markerValue?: number;
@@ -11,7 +10,10 @@ export interface CategoryBarProps extends FlexboxProps {
11
10
  valueFormatter?: ValueFormatter;
12
11
  values: number[];
13
12
  }
14
- declare const CategoryBar: import("react").ForwardRefExoticComponent<Omit<CategoryBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
15
- //#endregion
16
- export { CategoryBar as default };
17
- //# sourceMappingURL=CategoryBar.d.mts.map
13
+ declare const CategoryBar: {
14
+ ({ ref, ...props }: CategoryBarProps & {
15
+ ref?: React.Ref<HTMLDivElement>;
16
+ }): import("react").JSX.Element;
17
+ displayName: string;
18
+ };
19
+ export { CategoryBar as default };
@@ -1,11 +1,11 @@
1
1
  "use client";
2
+ import { Flexbox, Tooltip, cssVar, cx } from "@lobehub/ui";
3
+ import { memo, useMemo } from "react";
2
4
  import { useThemeColorRange } from "../hooks/useThemeColorRange.mjs";
3
5
  import { defaultValueFormatter, sumNumericArray } from "../utils/index.mjs";
4
6
  import { styles } from "./styles.mjs";
5
- import { Flexbox, Tooltip, cssVar, cx } from "@lobehub/ui";
6
- import { forwardRef, memo, useMemo } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
- //#region src/DataBars/CategoryBar.tsx
8
+ // src/DataBars/CategoryBar.tsx
9
9
  const getMarkerBgColor = (markerValue, values, colors) => {
10
10
  if (markerValue === void 0) return "";
11
11
  let prefixSum = 0;
@@ -22,8 +22,8 @@ const BarLabels = memo(({ values, valueFormatter }) => {
22
22
  let prefixSum = 0;
23
23
  let sumConsecutiveHiddenLabels = 0;
24
24
  return /* @__PURE__ */ jsxs(Flexbox, {
25
- className: cx(styles.label, styles.emphasis),
26
25
  horizontal: true,
26
+ className: cx(styles.label, styles.emphasis),
27
27
  style: { position: "relative" },
28
28
  children: [
29
29
  values.slice(0, values.length).map((widthPercentage, idx) => {
@@ -33,8 +33,8 @@ const BarLabels = memo(({ values, valueFormatter }) => {
33
33
  const widthPositionLeft = getPositionLeft(widthPercentage, sumValues);
34
34
  if (prefixSum === sumValues) return null;
35
35
  return /* @__PURE__ */ jsx(Flexbox, {
36
- align: "center",
37
36
  horizontal: true,
37
+ align: "center",
38
38
  justify: "flex-end",
39
39
  style: { width: `${widthPositionLeft}%` },
40
40
  children: /* @__PURE__ */ jsx("span", {
@@ -48,8 +48,8 @@ const BarLabels = memo(({ values, valueFormatter }) => {
48
48
  }, `item-${idx}`);
49
49
  }),
50
50
  /* @__PURE__ */ jsx(Flexbox, {
51
- align: "center",
52
51
  horizontal: true,
52
+ align: "center",
53
53
  style: {
54
54
  bottom: 0,
55
55
  left: 0,
@@ -58,8 +58,8 @@ const BarLabels = memo(({ values, valueFormatter }) => {
58
58
  children: valueFormatter ? valueFormatter(0) : 0
59
59
  }),
60
60
  /* @__PURE__ */ jsx(Flexbox, {
61
- align: "center",
62
61
  horizontal: true,
62
+ align: "center",
63
63
  style: {
64
64
  bottom: 0,
65
65
  position: "absolute",
@@ -70,7 +70,7 @@ const BarLabels = memo(({ values, valueFormatter }) => {
70
70
  ]
71
71
  });
72
72
  });
73
- const CategoryBar = forwardRef((props, ref) => {
73
+ const CategoryBar = ({ ref, ...props }) => {
74
74
  const themeColorRange = useThemeColorRange();
75
75
  const { values = [], colors = themeColorRange, valueFormatter = defaultValueFormatter, markerValue, showLabels = true, tooltip, showAnimation = false, className, width = "100%", size = 8, style, ...rest } = props;
76
76
  const colorGroup = colors.concat(themeColorRange);
@@ -87,30 +87,30 @@ const CategoryBar = forwardRef((props, ref) => {
87
87
  className,
88
88
  gap: 8,
89
89
  ref,
90
+ width,
90
91
  style: {
91
92
  position: "relative",
92
93
  ...style
93
94
  },
94
- width,
95
95
  ...rest,
96
96
  children: [showLabels && /* @__PURE__ */ jsx(BarLabels, {
97
97
  valueFormatter,
98
98
  values
99
99
  }), /* @__PURE__ */ jsxs(Flexbox, {
100
+ horizontal: true,
100
101
  align: "center",
101
102
  className: cx("relative w-full flex items-center h-2"),
102
103
  height: size,
103
- horizontal: true,
104
104
  style: { position: "relative" },
105
105
  children: [/* @__PURE__ */ jsx(Flexbox, {
106
+ horizontal: true,
106
107
  align: "center",
107
108
  height: "100%",
108
- horizontal: true,
109
+ width: "100%",
109
110
  style: {
110
111
  borderRadius: size / 2,
111
112
  overflow: "hidden"
112
113
  },
113
- width: "100%",
114
114
  children: values.map((value, idx) => {
115
115
  const baseColor = colorGroup[idx] ?? cssVar.colorPrimary;
116
116
  const percentage = value / maxValue * 100;
@@ -136,9 +136,8 @@ const CategoryBar = forwardRef((props, ref) => {
136
136
  })]
137
137
  })
138
138
  });
139
- });
139
+ };
140
140
  CategoryBar.displayName = "CategoryBar";
141
- //#endregion
142
141
  export { CategoryBar as default };
143
142
 
144
143
  //# sourceMappingURL=CategoryBar.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"CategoryBar.mjs","names":[],"sources":["../../src/DataBars/CategoryBar.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, FlexboxProps, Tooltip, cssVar, cx } from '@lobehub/ui';\nimport { forwardRef, memo, useMemo } from 'react';\n\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport { ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter, sumNumericArray } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getMarkerBgColor = (\n markerValue: number | undefined,\n values: number[],\n colors: string[],\n): string => {\n if (markerValue === undefined) return '';\n\n let prefixSum = 0;\n for (const [i, currentWidthPercentage] of values.entries()) {\n const currentBgColor = colors[i];\n\n prefixSum += currentWidthPercentage;\n if (prefixSum >= markerValue) return currentBgColor;\n }\n\n return '';\n};\n\nconst getPositionLeft = (value: number | undefined, maxValue: number): number =>\n value ? (value / maxValue) * 100 : 0;\n\nconst BarLabels = memo<{ valueFormatter?: ValueFormatter; values: number[] }>(\n ({ values, valueFormatter }) => {\n const sumValues = useMemo(() => sumNumericArray(values), [values]);\n let prefixSum = 0;\n let sumConsecutiveHiddenLabels = 0;\n return (\n <Flexbox\n className={cx(styles.label, styles.emphasis)}\n horizontal\n style={{\n position: 'relative',\n }}\n >\n {values.slice(0, values.length).map((widthPercentage, idx) => {\n prefixSum += widthPercentage;\n const showLabel =\n (widthPercentage >= 0.1 * sumValues ||\n sumConsecutiveHiddenLabels >= 0.09 * sumValues) &&\n sumValues - prefixSum >= 0.15 * sumValues &&\n prefixSum >= 0.1 * sumValues;\n sumConsecutiveHiddenLabels = showLabel\n ? 0\n : (sumConsecutiveHiddenLabels += widthPercentage);\n\n const widthPositionLeft = getPositionLeft(widthPercentage, sumValues);\n\n if (prefixSum === sumValues) return null;\n\n return (\n <Flexbox\n align={'center'}\n horizontal\n justify={'flex-end'}\n key={`item-${idx}`}\n style={{ width: `${widthPositionLeft}%` }}\n >\n <span\n style={{\n display: showLabel ? 'block' : 'hidden',\n left: '50%',\n transform: 'translateX(50%)',\n }}\n >\n {valueFormatter ? valueFormatter(prefixSum) : prefixSum}\n </span>\n </Flexbox>\n );\n })}\n <Flexbox align={'center'} horizontal style={{ bottom: 0, left: 0, position: 'absolute' }}>\n {valueFormatter ? valueFormatter(0) : 0}\n </Flexbox>\n <Flexbox align={'center'} horizontal style={{ bottom: 0, position: 'absolute', right: 0 }}>\n {valueFormatter ? valueFormatter(sumValues) : sumValues}\n </Flexbox>\n </Flexbox>\n );\n },\n);\n\nexport interface CategoryBarProps extends FlexboxProps {\n colors?: string[];\n markerValue?: number;\n showAnimation?: boolean;\n showLabels?: boolean;\n size?: number;\n tooltip?: string;\n valueFormatter?: ValueFormatter;\n values: number[];\n}\n\nconst CategoryBar = forwardRef<HTMLDivElement, CategoryBarProps>((props, ref) => {\n const themeColorRange = useThemeColorRange();\n const {\n values = [],\n colors = themeColorRange,\n valueFormatter = defaultValueFormatter,\n markerValue,\n showLabels = true,\n tooltip,\n showAnimation = false,\n className,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n\n const colorGroup = colors.concat(themeColorRange);\n\n const markerBgColor = useMemo(\n () => getMarkerBgColor(markerValue, values, colorGroup),\n [markerValue, values, colorGroup],\n );\n\n const maxValue = useMemo(() => sumNumericArray(values), [values]);\n\n const markerPositionLeft: number = useMemo(\n () => getPositionLeft(markerValue, maxValue),\n [markerValue, maxValue],\n );\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n className={className}\n gap={8}\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n {showLabels && <BarLabels valueFormatter={valueFormatter} values={values} />}\n <Flexbox\n align={'center'}\n className={cx('relative w-full flex items-center h-2')}\n height={size}\n horizontal\n style={{\n position: 'relative',\n }}\n >\n <Flexbox\n align={'center'}\n height={'100%'}\n horizontal\n style={{\n borderRadius: size / 2,\n overflow: 'hidden',\n }}\n width={'100%'}\n >\n {values.map((value, idx) => {\n const baseColor = colorGroup[idx] ?? cssVar.colorPrimary;\n const percentage = (value / maxValue) * 100;\n return (\n <Flexbox\n height={'100%'}\n key={`item-${idx}`}\n style={{ background: baseColor, width: `${percentage}%` }}\n />\n );\n })}\n </Flexbox>\n {markerValue === undefined ? undefined : (\n <div\n className={cx(styles.markerWrapper, showAnimation && styles.showAnimation)}\n style={{\n left: `${markerPositionLeft}%`,\n }}\n >\n <div\n className={styles.marker}\n style={{\n background: markerBgColor || cssVar.colorPrimary,\n height: size + 8,\n }}\n />\n </div>\n )}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n});\n\nCategoryBar.displayName = 'CategoryBar';\n\nexport default CategoryBar;\n"],"mappings":";;;;;;;;AAWA,MAAM,oBACJ,aACA,QACA,WACW;CACX,IAAI,gBAAgB,KAAA,GAAW,OAAO;CAEtC,IAAI,YAAY;CAChB,KAAK,MAAM,CAAC,GAAG,2BAA2B,OAAO,QAAQ,GAAG;EAC1D,MAAM,iBAAiB,OAAO;EAE9B,aAAa;EACb,IAAI,aAAa,aAAa,OAAO;CACvC;CAEA,OAAO;AACT;AAEA,MAAM,mBAAmB,OAA2B,aAClD,QAAS,QAAQ,WAAY,MAAM;AAErC,MAAM,YAAY,MACf,EAAE,QAAQ,qBAAqB;CAC9B,MAAM,YAAY,cAAc,gBAAgB,MAAM,GAAG,CAAC,MAAM,CAAC;CACjE,IAAI,YAAY;CAChB,IAAI,6BAA6B;CACjC,OACE,qBAAC,SAAD;EACE,WAAW,GAAG,OAAO,OAAO,OAAO,QAAQ;EAC3C,YAAA;EACA,OAAO,EACL,UAAU,WACZ;EALF,UAAA;GAOG,OAAO,MAAM,GAAG,OAAO,MAAM,CAAC,CAAC,KAAK,iBAAiB,QAAQ;IAC5D,aAAa;IACb,MAAM,aACH,mBAAmB,KAAM,aACxB,8BAA8B,MAAO,cACvC,YAAY,aAAa,MAAO,aAChC,aAAa,KAAM;IACrB,6BAA6B,YACzB,IACC,8BAA8B;IAEnC,MAAM,oBAAoB,gBAAgB,iBAAiB,SAAS;IAEpE,IAAI,cAAc,WAAW,OAAO;IAEpC,OACE,oBAAC,SA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AAwB;GAAS,CAAA,GAC3E,qBAAC,SAAD;IACE,OAAO;IACP,WAAW,GAAG,uCAAuC;IACrD,QAAQ;IACR,YAAA;IACA,OAAO,EACL,UAAU,WACZ;IAPF,UAAA,CASE,oBAAC,SAAD;KACE,OAAO;KACP,QAAQ;KACR,YAAA;KACA,OAAO;MACL,cAAc,OAAO;MACrB,UAAU;KACZ;KACA,OAAO;KAEN,UAAA,OAAO,KAAK,OAAO,QAAQ;MAC1B,MAAM,YAAY,WAAW,QAAQ,OAAO;MAC5C,MAAM,aAAc,QAAQ,WAAY;MACxC,OACE,oBAAC,SAAD;OACE,QAAQ;OAER,OAAO;QAAE,YAAY;QAAW,OAAO,GAAG,WAAW;OAAG;MACzD,GAFM,QAAQ,KAEd;KAEL,CAAC;IACM,CAAA,GACR,gBAAgB,KAAA,IAAY,KAAA,IAC3B,oBAAC,OAAD;KACE,WAAW,GAAG,OAAO,eAAe,iBAAiB,OAAO,aAAa;KACzE,OAAO,EACL,MAAM,GAAG,mBAAmB,GAC9B;KAEA,UAAA,oBAAC,OAAD;MACE,WAAW,OAAO;MAClB,OAAO;OACL,YAAY,iBAAiB,OAAO;OACpC,QAAQ,OAAO;MACjB;KACD,CAAA;IACE,CAAA,CAEA;GACF,CAAA,CAAA;;CACF,CAAA;AAEb,CAAC;AAED,YAAY,cAAc"}
1
+ {"version":3,"file":"CategoryBar.mjs","names":[],"sources":["../../src/DataBars/CategoryBar.tsx"],"sourcesContent":["'use client';\n\nimport type { FlexboxProps } from '@lobehub/ui';\nimport { cssVar, cx, Flexbox, Tooltip } from '@lobehub/ui';\nimport { memo, useMemo } from 'react';\n\nimport { useThemeColorRange } from '@/hooks/useThemeColorRange';\nimport type { ValueFormatter } from '@/types/charts';\nimport { defaultValueFormatter, sumNumericArray } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getMarkerBgColor = (\n markerValue: number | undefined,\n values: number[],\n colors: string[],\n): string => {\n if (markerValue === undefined) return '';\n\n let prefixSum = 0;\n for (const [i, currentWidthPercentage] of values.entries()) {\n const currentBgColor = colors[i];\n\n prefixSum += currentWidthPercentage;\n if (prefixSum >= markerValue) return currentBgColor;\n }\n\n return '';\n};\n\nconst getPositionLeft = (value: number | undefined, maxValue: number): number =>\n value ? (value / maxValue) * 100 : 0;\n\nconst BarLabels = memo<{ valueFormatter?: ValueFormatter; values: number[] }>(\n ({ values, valueFormatter }) => {\n const sumValues = useMemo(() => sumNumericArray(values), [values]);\n let prefixSum = 0;\n let sumConsecutiveHiddenLabels = 0;\n return (\n <Flexbox\n horizontal\n className={cx(styles.label, styles.emphasis)}\n style={{\n position: 'relative',\n }}\n >\n {values.slice(0, values.length).map((widthPercentage, idx) => {\n prefixSum += widthPercentage;\n const showLabel =\n (widthPercentage >= 0.1 * sumValues ||\n sumConsecutiveHiddenLabels >= 0.09 * sumValues) &&\n sumValues - prefixSum >= 0.15 * sumValues &&\n prefixSum >= 0.1 * sumValues;\n sumConsecutiveHiddenLabels = showLabel\n ? 0\n : (sumConsecutiveHiddenLabels += widthPercentage);\n\n const widthPositionLeft = getPositionLeft(widthPercentage, sumValues);\n\n if (prefixSum === sumValues) return null;\n\n return (\n <Flexbox\n horizontal\n align={'center'}\n justify={'flex-end'}\n key={`item-${idx}`}\n style={{ width: `${widthPositionLeft}%` }}\n >\n <span\n style={{\n display: showLabel ? 'block' : 'hidden',\n left: '50%',\n transform: 'translateX(50%)',\n }}\n >\n {valueFormatter ? valueFormatter(prefixSum) : prefixSum}\n </span>\n </Flexbox>\n );\n })}\n <Flexbox horizontal align={'center'} style={{ bottom: 0, left: 0, position: 'absolute' }}>\n {valueFormatter ? valueFormatter(0) : 0}\n </Flexbox>\n <Flexbox horizontal align={'center'} style={{ bottom: 0, position: 'absolute', right: 0 }}>\n {valueFormatter ? valueFormatter(sumValues) : sumValues}\n </Flexbox>\n </Flexbox>\n );\n },\n);\n\nexport interface CategoryBarProps extends FlexboxProps {\n colors?: string[];\n markerValue?: number;\n showAnimation?: boolean;\n showLabels?: boolean;\n size?: number;\n tooltip?: string;\n valueFormatter?: ValueFormatter;\n values: number[];\n}\n\nconst CategoryBar = ({ ref, ...props }: CategoryBarProps & { ref?: React.Ref<HTMLDivElement> }) => {\n const themeColorRange = useThemeColorRange();\n const {\n values = [],\n colors = themeColorRange,\n valueFormatter = defaultValueFormatter,\n markerValue,\n showLabels = true,\n tooltip,\n showAnimation = false,\n className,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n\n const colorGroup = colors.concat(themeColorRange);\n\n const markerBgColor = useMemo(\n () => getMarkerBgColor(markerValue, values, colorGroup),\n [markerValue, values, colorGroup],\n );\n\n const maxValue = useMemo(() => sumNumericArray(values), [values]);\n\n const markerPositionLeft: number = useMemo(\n () => getPositionLeft(markerValue, maxValue),\n [markerValue, maxValue],\n );\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n className={className}\n gap={8}\n ref={ref}\n width={width}\n style={{\n position: 'relative',\n ...style,\n }}\n {...rest}\n >\n {showLabels && <BarLabels valueFormatter={valueFormatter} values={values} />}\n <Flexbox\n horizontal\n align={'center'}\n className={cx('relative w-full flex items-center h-2')}\n height={size}\n style={{\n position: 'relative',\n }}\n >\n <Flexbox\n horizontal\n align={'center'}\n height={'100%'}\n width={'100%'}\n style={{\n borderRadius: size / 2,\n overflow: 'hidden',\n }}\n >\n {values.map((value, idx) => {\n const baseColor = colorGroup[idx] ?? cssVar.colorPrimary;\n const percentage = (value / maxValue) * 100;\n return (\n <Flexbox\n height={'100%'}\n key={`item-${idx}`}\n style={{ background: baseColor, width: `${percentage}%` }}\n />\n );\n })}\n </Flexbox>\n {markerValue === undefined ? undefined : (\n <div\n className={cx(styles.markerWrapper, showAnimation && styles.showAnimation)}\n style={{\n left: `${markerPositionLeft}%`,\n }}\n >\n <div\n className={styles.marker}\n style={{\n background: markerBgColor || cssVar.colorPrimary,\n height: size + 8,\n }}\n />\n </div>\n )}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n};\n\nCategoryB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,WAAW,QAAQ,OAAO;MAC5C,MAAM,aAAc,QAAQ,WAAY;MACxC,OACE,oBAAC,SAAD;OACE,QAAQ;OAER,OAAO;QAAE,YAAY;QAAW,OAAO,GAAG,WAAW;OAAG;MACzD,GAFM,QAAQ,KAEd;KAEL,CAAC;IACM,CAAA,GACR,gBAAgB,KAAA,IAAY,KAAA,IAC3B,oBAAC,OAAD;KACE,WAAW,GAAG,OAAO,eAAe,iBAAiB,OAAO,aAAa;KACzE,OAAO,EACL,MAAM,GAAG,mBAAmB,GAC9B;KAEA,UAAA,oBAAC,OAAD;MACE,WAAW,OAAO;MAClB,OAAO;OACL,YAAY,iBAAiB,OAAO;OACpC,QAAQ,OAAO;MACjB;KACD,CAAA;IACE,CAAA,CAEA;GACF,CAAA,CAAA;;CACF,CAAA;AAEb;AAEA,YAAY,cAAc"}
@@ -1,6 +1,5 @@
1
1
  import { FlexboxProps } from "@lobehub/ui";
2
2
  import { ReactNode } from "react";
3
- //#region src/DataBars/DeltaBar.d.ts
4
3
  export interface DeltaBarProps extends FlexboxProps {
5
4
  bgColors?: string;
6
5
  color?: string;
@@ -10,7 +9,10 @@ export interface DeltaBarProps extends FlexboxProps {
10
9
  tooltip?: ReactNode;
11
10
  value: number;
12
11
  }
13
- declare const DeltaBar: import("react").ForwardRefExoticComponent<Omit<DeltaBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
14
- //#endregion
15
- export { DeltaBar as default };
16
- //# sourceMappingURL=DeltaBar.d.mts.map
12
+ declare const DeltaBar: {
13
+ ({ ref, ...props }: DeltaBarProps & {
14
+ ref?: React.Ref<HTMLDivElement>;
15
+ }): import("react").JSX.Element;
16
+ displayName: string;
17
+ };
18
+ export { DeltaBar as default };
@@ -1,13 +1,12 @@
1
1
  "use client";
2
+ import { Flexbox, Tooltip, cssVar, cx } from "@lobehub/ui";
2
3
  import { DeltaTypes } from "../types/charts.mjs";
3
4
  import { mapInputsToDeltaType } from "../utils/index.mjs";
4
5
  import { styles } from "./styles.mjs";
5
- import { Flexbox, Tooltip, cssVar, cx } from "@lobehub/ui";
6
- import { forwardRef } from "react";
7
6
  import { jsx, jsxs } from "react/jsx-runtime";
8
- //#region src/DataBars/DeltaBar.tsx
7
+ // src/DataBars/DeltaBar.tsx
9
8
  const getDeltaType = (value) => value >= 0 ? DeltaTypes.Increase : DeltaTypes.Decrease;
10
- const DeltaBar = forwardRef((props, ref) => {
9
+ const DeltaBar = ({ ref, ...props }) => {
11
10
  const { value, bgColors, color, isIncreasePositive = true, showAnimation = false, className, tooltip, width = "100%", size = 8, style, ...rest } = props;
12
11
  const deltaType = mapInputsToDeltaType(getDeltaType(value), isIncreasePositive);
13
12
  const colors = {
@@ -20,20 +19,21 @@ const DeltaBar = forwardRef((props, ref) => {
20
19
  return /* @__PURE__ */ jsx(Tooltip, {
21
20
  title: tooltip,
22
21
  children: /* @__PURE__ */ jsxs(Flexbox, {
22
+ horizontal: true,
23
23
  align: "center",
24
24
  className,
25
25
  height: size,
26
- horizontal: true,
27
26
  ref,
27
+ width,
28
28
  style: {
29
29
  position: "relative",
30
30
  ...style
31
31
  },
32
- width,
33
32
  ...rest,
34
33
  children: [
35
34
  /* @__PURE__ */ jsx(Flexbox, {
36
35
  height: "100%",
36
+ width: "100%",
37
37
  style: {
38
38
  background: bgColors || cssVar.colorFillTertiary,
39
39
  borderRadius: size / 2,
@@ -41,14 +41,13 @@ const DeltaBar = forwardRef((props, ref) => {
41
41
  opacity: bgColors ? .2 : 1,
42
42
  position: "absolute",
43
43
  zIndex: 0
44
- },
45
- width: "100%"
44
+ }
46
45
  }),
47
46
  /* @__PURE__ */ jsx(Flexbox, {
47
+ horizontal: true,
48
48
  align: "center",
49
49
  flex: 1,
50
50
  height: "100%",
51
- horizontal: true,
52
51
  justify: "flex-end",
53
52
  style: { position: "relative" },
54
53
  children: value < 0 ? /* @__PURE__ */ jsx("div", {
@@ -72,10 +71,10 @@ const DeltaBar = forwardRef((props, ref) => {
72
71
  }
73
72
  }),
74
73
  /* @__PURE__ */ jsx(Flexbox, {
74
+ horizontal: true,
75
75
  align: "center",
76
76
  flex: 1,
77
77
  height: "100%",
78
- horizontal: true,
79
78
  justify: "flex-start",
80
79
  style: { position: "relative" },
81
80
  children: value >= 0 ? /* @__PURE__ */ jsx("div", {
@@ -92,9 +91,8 @@ const DeltaBar = forwardRef((props, ref) => {
92
91
  ]
93
92
  })
94
93
  });
95
- });
94
+ };
96
95
  DeltaBar.displayName = "DeltaBar";
97
- //#endregion
98
96
  export { DeltaBar as default };
99
97
 
100
98
  //# sourceMappingURL=DeltaBar.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeltaBar.mjs","names":[],"sources":["../../src/DataBars/DeltaBar.tsx"],"sourcesContent":["'use client';\n\nimport { Flexbox, FlexboxProps, Tooltip, cssVar, cx } from '@lobehub/ui';\nimport { ReactNode, forwardRef } from 'react';\n\nimport { DeltaTypes } from '@/types/charts';\nimport { mapInputsToDeltaType } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getDeltaType = (value: number) => (value >= 0 ? DeltaTypes.Increase : DeltaTypes.Decrease);\n\nexport interface DeltaBarProps extends FlexboxProps {\n bgColors?: string;\n color?: string;\n isIncreasePositive?: boolean;\n showAnimation?: boolean;\n size?: number;\n tooltip?: ReactNode;\n value: number;\n}\n\nconst DeltaBar = forwardRef<HTMLDivElement, DeltaBarProps>((props, ref) => {\n const {\n value,\n bgColors,\n color,\n isIncreasePositive = true,\n showAnimation = false,\n className,\n tooltip,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n const deltaType = mapInputsToDeltaType(getDeltaType(value), isIncreasePositive);\n\n const colors = {\n [DeltaTypes.Increase]: cssVar.colorSuccess,\n [DeltaTypes.ModerateIncrease]: cssVar.colorSuccess,\n [DeltaTypes.Decrease]: cssVar.colorError,\n [DeltaTypes.ModerateDecrease]: cssVar.colorError,\n [DeltaTypes.Unchanged]: cssVar.colorWarning,\n };\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n align={'center'}\n className={className}\n height={size}\n horizontal\n ref={ref}\n style={{\n position: 'relative',\n ...style,\n }}\n width={width}\n {...rest}\n >\n <Flexbox\n height={'100%'}\n style={{\n background: bgColors || cssVar.colorFillTertiary,\n borderRadius: size / 2,\n inset: 0,\n opacity: bgColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n width={'100%'}\n />\n <Flexbox\n align={'center'}\n flex={1}\n height={'100%'}\n horizontal\n justify={'flex-end'}\n style={{ position: 'relative' }}\n >\n {value < 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomLeftRadius: size / 2,\n borderTopLeftRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n <Flexbox\n className={styles.marker}\n flex={'none'}\n style={{\n background: color || cssVar.colorPrimary,\n height: size + 8,\n zIndex: 2,\n }}\n />\n <Flexbox\n align={'center'}\n flex={1}\n height={'100%'}\n horizontal\n justify={'flex-start'}\n style={{ position: 'relative' }}\n >\n {value >= 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomRightRadius: size / 2,\n borderTopRightRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n});\n\nDeltaBar.displayName = 'DeltaBar';\n\nexport default DeltaBar;\n"],"mappings":";;;;;;;;AAUA,MAAM,gBAAgB,UAAmB,SAAS,IAAI,WAAW,WAAW,WAAW;AAYvF,MAAM,WAAW,YAA2C,OAAO,QAAQ;CACzE,MAAM,EACJ,OACA,UACA,OACA,qBAAqB,MACrB,gBAAgB,OAChB,WACA,SACA,QAAQ,QACR,OAAO,GACP,OACA,GAAG,SACD;CACJ,MAAM,YAAY,qBAAqB,aAAa,KAAK,GAAG,kBAAkB;CAE9E,MAAM,SAAS;GACZ,WAAW,WAAW,OA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B;KACD,CAAA,IACC,KAAA;IACG,CAAA;GACF;;CACF,CAAA;AAEb,CAAC;AAED,SAAS,cAAc"}
1
+ {"version":3,"file":"DeltaBar.mjs","names":[],"sources":["../../src/DataBars/DeltaBar.tsx"],"sourcesContent":["'use client';\n\nimport type { FlexboxProps } from '@lobehub/ui';\nimport { cssVar, cx, Flexbox, Tooltip } from '@lobehub/ui';\nimport type { ReactNode } from 'react';\n\nimport { DeltaTypes } from '@/types/charts';\nimport { mapInputsToDeltaType } from '@/utils';\n\nimport { styles } from './styles';\n\nconst getDeltaType = (value: number) => (value >= 0 ? DeltaTypes.Increase : DeltaTypes.Decrease);\n\nexport interface DeltaBarProps extends FlexboxProps {\n bgColors?: string;\n color?: string;\n isIncreasePositive?: boolean;\n showAnimation?: boolean;\n size?: number;\n tooltip?: ReactNode;\n value: number;\n}\n\nconst DeltaBar = ({ ref, ...props }: DeltaBarProps & { ref?: React.Ref<HTMLDivElement> }) => {\n const {\n value,\n bgColors,\n color,\n isIncreasePositive = true,\n showAnimation = false,\n className,\n tooltip,\n width = '100%',\n size = 8,\n style,\n ...rest\n } = props;\n const deltaType = mapInputsToDeltaType(getDeltaType(value), isIncreasePositive);\n\n const colors = {\n [DeltaTypes.Increase]: cssVar.colorSuccess,\n [DeltaTypes.ModerateIncrease]: cssVar.colorSuccess,\n [DeltaTypes.Decrease]: cssVar.colorError,\n [DeltaTypes.ModerateDecrease]: cssVar.colorError,\n [DeltaTypes.Unchanged]: cssVar.colorWarning,\n };\n\n return (\n <Tooltip title={tooltip}>\n <Flexbox\n horizontal\n align={'center'}\n className={className}\n height={size}\n ref={ref}\n width={width}\n style={{\n position: 'relative',\n ...style,\n }}\n {...rest}\n >\n <Flexbox\n height={'100%'}\n width={'100%'}\n style={{\n background: bgColors || cssVar.colorFillTertiary,\n borderRadius: size / 2,\n inset: 0,\n opacity: bgColors ? 0.2 : 1,\n position: 'absolute',\n zIndex: 0,\n }}\n />\n <Flexbox\n horizontal\n align={'center'}\n flex={1}\n height={'100%'}\n justify={'flex-end'}\n style={{ position: 'relative' }}\n >\n {value < 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomLeftRadius: size / 2,\n borderTopLeftRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n <Flexbox\n className={styles.marker}\n flex={'none'}\n style={{\n background: color || cssVar.colorPrimary,\n height: size + 8,\n zIndex: 2,\n }}\n />\n <Flexbox\n horizontal\n align={'center'}\n flex={1}\n height={'100%'}\n justify={'flex-start'}\n style={{ position: 'relative' }}\n >\n {value >= 0 ? (\n <div\n className={cx(showAnimation && styles.showAnimation)}\n style={{\n background: colors[deltaType],\n borderBottomRightRadius: size / 2,\n borderTopRightRadius: size / 2,\n height: '100%',\n width: `${Math.abs(value)}%`,\n }}\n />\n ) : undefined}\n </Flexbox>\n </Flexbox>\n </Tooltip>\n );\n};\n\nDeltaBar.displayName = 'DeltaBar';\n\nexport default DeltaBar;\n"],"mappings":";;;;;;;AAWA,MAAM,gBAAgB,UAAmB,SAAS,IAAI,WAAW,WAAW,WAAW;AAYvF,MAAM,YAAY,EAAE,KAAK,GAAG,YAAiE;CAC3F,MAAM,EACJ,OACA,UACA,OACA,qBAAqB,MACrB,gBAAgB,OAChB,WACA,SACA,QAAQ,QACR,OAAO,GACP,OACA,GAAG,SACD;CACJ,MAAM,YAAY,qBAAqB,aAAa,KAAK,GAAG,kBAAkB;CAE9E,MAAM,SAAS;GACZ,WAAW,WAAW,OAAO;GAC7B,WAAW,mBAAmB,OAAO;GACrC,WAAW,WAAW,OAAO;GAC7B,WAAW,mBAAmB,OAAO;GACrC,WAAW,YAAY,OAAO;CACjC;CAEA,OACE,oBAAC,SAAD;EAAS,OAAO;EACd,UAAA,qBAAC,SAAD;GACE,YAAA;GACA,OAAO;GACI;GACX,QAAQ;GACH;GACE;GACP,OAAO;IACL,UAAU;IACV,GAAG;GACL;GACA,GAAI;GAXN,UAAA;IAaE,oBAAC,SAAD;KACE,QAAQ;KACR,OAAO;KACP,OAAO;MACL,YAAY,YAAY,OAAO;MAC/B,cAAc,OAAO;MACrB,OAAO;MACP,SAAS,WAAW,KAAM;MAC1B,UAAU;MACV,QAAQ;KACV;IACD,CAAA;IACD,oBAAC,SAAD;KACE,YAAA;KACA,OAAO;KACP,MAAM;KACN,QAAQ;KACR,SAAS;KACT,OAAO,EAAE,UAAU,WAAW;KAE7B,UAAA,QAAQ,IACP,oBAAC,OAAD;MACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;MACnD,OAAO;OACL,YAAY,OAAO;OACnB,wBAAwB,OAAO;OAC/B,qBAAqB,OAAO;OAC5B,QAAQ;OACR,OAAO,GAAG,KAAK,IAAI,KAAK,EAAE;MAC5B;KACD,CAAA,IACC,KAAA;IACG,CAAA;IACT,oBAAC,SAAD;KACE,WAAW,OAAO;KAClB,MAAM;KACN,OAAO;MACL,YAAY,SAAS,OAAO;MAC5B,QAAQ,OAAO;MACf,QAAQ;KACV;IACD,CAAA;IACD,oBAAC,SAAD;KACE,YAAA;KACA,OAAO;KACP,MAAM;KACN,QAAQ;KACR,SAAS;KACT,OAAO,EAAE,UAAU,WAAW;KAE7B,UAAA,SAAS,IACR,oBAAC,OAAD;MACE,WAAW,GAAG,iBAAiB,OAAO,aAAa;MACnD,OAAO;OACL,YAAY,OAAO;OACnB,yBAAyB,OAAO;OAChC,sBAAsB,OAAO;OAC7B,QAAQ;OACR,OAAO,GAAG,KAAK,IAAI,KAAK,EAAE;MAC5B;KACD,CAAA,IACC,KAAA;IACG,CAAA;GACF;;CACF,CAAA;AAEb;AAEA,SAAS,cAAc"}
@@ -1,6 +1,5 @@
1
1
  import { FlexboxProps } from "@lobehub/ui";
2
2
  import { ReactNode } from "react";
3
- //#region src/DataBars/MarkerBar.d.ts
4
3
  export interface MarkerBarProps extends FlexboxProps {
5
4
  bgColors?: string;
6
5
  color?: string;
@@ -13,7 +12,10 @@ export interface MarkerBarProps extends FlexboxProps {
13
12
  size?: number;
14
13
  value: number;
15
14
  }
16
- declare const MarkerBar: import("react").ForwardRefExoticComponent<Omit<MarkerBarProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
17
- //#endregion
18
- export { MarkerBar as default };
19
- //# sourceMappingURL=MarkerBar.d.mts.map
15
+ declare const MarkerBar: {
16
+ ({ ref, ...props }: MarkerBarProps & {
17
+ ref?: React.Ref<HTMLDivElement>;
18
+ }): import("react").JSX.Element;
19
+ displayName: string;
20
+ };
21
+ export { MarkerBar as default };