@mantine/charts 9.0.0-alpha.5 → 9.0.0-alpha.7

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 (233) hide show
  1. package/cjs/AreaChart/AreaChart.cjs +305 -376
  2. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaGradient.cjs +33 -11
  4. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  5. package/cjs/AreaChart/AreaSplit.cjs +25 -27
  6. package/cjs/AreaChart/AreaSplit.cjs.map +1 -1
  7. package/cjs/AreaChart/get-split-offset.cjs +18 -19
  8. package/cjs/AreaChart/get-split-offset.cjs.map +1 -1
  9. package/cjs/BarChart/BarChart.cjs +283 -364
  10. package/cjs/BarChart/BarChart.cjs.map +1 -1
  11. package/cjs/BarsList/BarsList.cjs +86 -115
  12. package/cjs/BarsList/BarsList.cjs.map +1 -1
  13. package/cjs/BarsList/BarsList.module.cjs +13 -0
  14. package/cjs/BarsList/BarsList.module.cjs.map +1 -0
  15. package/cjs/BubbleChart/BubbleChart.cjs +124 -143
  16. package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
  17. package/cjs/ChartLegend/ChartLegend.cjs +66 -83
  18. package/cjs/ChartLegend/ChartLegend.cjs.map +1 -1
  19. package/cjs/ChartLegend/ChartLegend.module.cjs +12 -0
  20. package/cjs/ChartLegend/ChartLegend.module.cjs.map +1 -0
  21. package/cjs/ChartTooltip/ChartTooltip.cjs +101 -116
  22. package/cjs/ChartTooltip/ChartTooltip.cjs.map +1 -1
  23. package/cjs/ChartTooltip/ChartTooltip.module.cjs +16 -0
  24. package/cjs/ChartTooltip/ChartTooltip.module.cjs.map +1 -0
  25. package/cjs/CompositeChart/CompositeChart.cjs +301 -389
  26. package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
  27. package/cjs/DonutChart/DonutChart.cjs +122 -168
  28. package/cjs/DonutChart/DonutChart.cjs.map +1 -1
  29. package/cjs/DonutChart/DonutChart.module.cjs +10 -0
  30. package/cjs/DonutChart/DonutChart.module.cjs.map +1 -0
  31. package/cjs/FunnelChart/FunnelChart.cjs +91 -129
  32. package/cjs/FunnelChart/FunnelChart.cjs.map +1 -1
  33. package/cjs/FunnelChart/FunnelChart.module.cjs +7 -0
  34. package/cjs/FunnelChart/FunnelChart.module.cjs.map +1 -0
  35. package/cjs/Heatmap/Heatmap.cjs +156 -188
  36. package/cjs/Heatmap/Heatmap.cjs.map +1 -1
  37. package/cjs/Heatmap/Heatmap.module.cjs +12 -0
  38. package/cjs/Heatmap/Heatmap.module.cjs.map +1 -0
  39. package/cjs/Heatmap/HeatmapSplitWeeks.cjs +48 -72
  40. package/cjs/Heatmap/HeatmapSplitWeeks.cjs.map +1 -1
  41. package/cjs/Heatmap/HeatmapWeeks.cjs +45 -57
  42. package/cjs/Heatmap/HeatmapWeeks.cjs.map +1 -1
  43. package/cjs/Heatmap/get-boundaries/get-boundaries.cjs +8 -10
  44. package/cjs/Heatmap/get-boundaries/get-boundaries.cjs.map +1 -1
  45. package/cjs/Heatmap/get-columns/get-columns.cjs +74 -64
  46. package/cjs/Heatmap/get-columns/get-columns.cjs.map +1 -1
  47. package/cjs/Heatmap/get-dates-range/get-dates-range.cjs +43 -54
  48. package/cjs/Heatmap/get-dates-range/get-dates-range.cjs.map +1 -1
  49. package/cjs/Heatmap/get-heat-color/get-heat-color.cjs +7 -8
  50. package/cjs/Heatmap/get-heat-color/get-heat-color.cjs.map +1 -1
  51. package/cjs/Heatmap/get-months-range/get-months-range.cjs +23 -19
  52. package/cjs/Heatmap/get-months-range/get-months-range.cjs.map +1 -1
  53. package/cjs/Heatmap/rotate-weekdays-names/rotate-weekdays-names.cjs +8 -10
  54. package/cjs/Heatmap/rotate-weekdays-names/rotate-weekdays-names.cjs.map +1 -1
  55. package/cjs/LineChart/LineChart.cjs +275 -341
  56. package/cjs/LineChart/LineChart.cjs.map +1 -1
  57. package/cjs/PieChart/PieChart.cjs +125 -171
  58. package/cjs/PieChart/PieChart.cjs.map +1 -1
  59. package/cjs/PieChart/PieChart.module.cjs +7 -0
  60. package/cjs/PieChart/PieChart.module.cjs.map +1 -0
  61. package/cjs/PointLabel/PointLabel.cjs +20 -20
  62. package/cjs/PointLabel/PointLabel.cjs.map +1 -1
  63. package/cjs/RadarChart/RadarChart.cjs +128 -157
  64. package/cjs/RadarChart/RadarChart.cjs.map +1 -1
  65. package/cjs/RadarChart/RadarChart.module.cjs +10 -0
  66. package/cjs/RadarChart/RadarChart.module.cjs.map +1 -0
  67. package/cjs/RadialBarChart/RadialBarChart.cjs +117 -147
  68. package/cjs/RadialBarChart/RadialBarChart.cjs.map +1 -1
  69. package/cjs/RadialBarChart/RadialBarChart.module.cjs +10 -0
  70. package/cjs/RadialBarChart/RadialBarChart.module.cjs.map +1 -0
  71. package/cjs/ScatterChart/ScatterChart.cjs +219 -278
  72. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  73. package/cjs/Sparkline/Sparkline.cjs +71 -99
  74. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  75. package/cjs/Sparkline/Sparkline.module.cjs +7 -0
  76. package/cjs/Sparkline/Sparkline.module.cjs.map +1 -0
  77. package/cjs/_virtual/_rolldown/runtime.cjs +24 -0
  78. package/cjs/grid-chart.module.cjs +14 -0
  79. package/cjs/grid-chart.module.cjs.map +1 -0
  80. package/cjs/index.cjs +39 -44
  81. package/cjs/utils/get-series-labels/get-series-labels.cjs +16 -18
  82. package/cjs/utils/get-series-labels/get-series-labels.cjs.map +1 -1
  83. package/esm/AreaChart/AreaChart.mjs +306 -376
  84. package/esm/AreaChart/AreaChart.mjs.map +1 -1
  85. package/esm/AreaChart/AreaGradient.mjs +32 -9
  86. package/esm/AreaChart/AreaGradient.mjs.map +1 -1
  87. package/esm/AreaChart/AreaSplit.mjs +24 -25
  88. package/esm/AreaChart/AreaSplit.mjs.map +1 -1
  89. package/esm/AreaChart/get-split-offset.mjs +18 -17
  90. package/esm/AreaChart/get-split-offset.mjs.map +1 -1
  91. package/esm/BarChart/BarChart.mjs +283 -364
  92. package/esm/BarChart/BarChart.mjs.map +1 -1
  93. package/esm/BarsList/BarsList.mjs +84 -112
  94. package/esm/BarsList/BarsList.mjs.map +1 -1
  95. package/esm/BarsList/BarsList.module.mjs +13 -0
  96. package/esm/BarsList/BarsList.module.mjs.map +1 -0
  97. package/esm/BubbleChart/BubbleChart.mjs +122 -140
  98. package/esm/BubbleChart/BubbleChart.mjs.map +1 -1
  99. package/esm/ChartLegend/ChartLegend.mjs +64 -80
  100. package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
  101. package/esm/ChartLegend/ChartLegend.module.mjs +12 -0
  102. package/esm/ChartLegend/ChartLegend.module.mjs.map +1 -0
  103. package/esm/ChartTooltip/ChartTooltip.mjs +99 -113
  104. package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
  105. package/esm/ChartTooltip/ChartTooltip.module.mjs +16 -0
  106. package/esm/ChartTooltip/ChartTooltip.module.mjs.map +1 -0
  107. package/esm/CompositeChart/CompositeChart.mjs +299 -386
  108. package/esm/CompositeChart/CompositeChart.mjs.map +1 -1
  109. package/esm/DonutChart/DonutChart.mjs +120 -165
  110. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  111. package/esm/DonutChart/DonutChart.module.mjs +10 -0
  112. package/esm/DonutChart/DonutChart.module.mjs.map +1 -0
  113. package/esm/FunnelChart/FunnelChart.mjs +92 -129
  114. package/esm/FunnelChart/FunnelChart.mjs.map +1 -1
  115. package/esm/FunnelChart/FunnelChart.module.mjs +7 -0
  116. package/esm/FunnelChart/FunnelChart.module.mjs.map +1 -0
  117. package/esm/Heatmap/Heatmap.mjs +154 -185
  118. package/esm/Heatmap/Heatmap.mjs.map +1 -1
  119. package/esm/Heatmap/Heatmap.module.mjs +12 -0
  120. package/esm/Heatmap/Heatmap.module.mjs.map +1 -0
  121. package/esm/Heatmap/HeatmapSplitWeeks.mjs +47 -70
  122. package/esm/Heatmap/HeatmapSplitWeeks.mjs.map +1 -1
  123. package/esm/Heatmap/HeatmapWeeks.mjs +44 -55
  124. package/esm/Heatmap/HeatmapWeeks.mjs.map +1 -1
  125. package/esm/Heatmap/get-boundaries/get-boundaries.mjs +8 -8
  126. package/esm/Heatmap/get-boundaries/get-boundaries.mjs.map +1 -1
  127. package/esm/Heatmap/get-columns/get-columns.mjs +74 -62
  128. package/esm/Heatmap/get-columns/get-columns.mjs.map +1 -1
  129. package/esm/Heatmap/get-dates-range/get-dates-range.mjs +43 -52
  130. package/esm/Heatmap/get-dates-range/get-dates-range.mjs.map +1 -1
  131. package/esm/Heatmap/get-heat-color/get-heat-color.mjs +7 -6
  132. package/esm/Heatmap/get-heat-color/get-heat-color.mjs.map +1 -1
  133. package/esm/Heatmap/get-months-range/get-months-range.mjs +23 -17
  134. package/esm/Heatmap/get-months-range/get-months-range.mjs.map +1 -1
  135. package/esm/Heatmap/rotate-weekdays-names/rotate-weekdays-names.mjs +8 -8
  136. package/esm/Heatmap/rotate-weekdays-names/rotate-weekdays-names.mjs.map +1 -1
  137. package/esm/LineChart/LineChart.mjs +276 -341
  138. package/esm/LineChart/LineChart.mjs.map +1 -1
  139. package/esm/PieChart/PieChart.mjs +126 -171
  140. package/esm/PieChart/PieChart.mjs.map +1 -1
  141. package/esm/PieChart/PieChart.module.mjs +7 -0
  142. package/esm/PieChart/PieChart.module.mjs.map +1 -0
  143. package/esm/PointLabel/PointLabel.mjs +19 -18
  144. package/esm/PointLabel/PointLabel.mjs.map +1 -1
  145. package/esm/RadarChart/RadarChart.mjs +129 -157
  146. package/esm/RadarChart/RadarChart.mjs.map +1 -1
  147. package/esm/RadarChart/RadarChart.module.mjs +10 -0
  148. package/esm/RadarChart/RadarChart.module.mjs.map +1 -0
  149. package/esm/RadialBarChart/RadialBarChart.mjs +118 -147
  150. package/esm/RadialBarChart/RadialBarChart.mjs.map +1 -1
  151. package/esm/RadialBarChart/RadialBarChart.module.mjs +10 -0
  152. package/esm/RadialBarChart/RadialBarChart.module.mjs.map +1 -0
  153. package/esm/ScatterChart/ScatterChart.mjs +220 -278
  154. package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
  155. package/esm/Sparkline/Sparkline.mjs +69 -96
  156. package/esm/Sparkline/Sparkline.mjs.map +1 -1
  157. package/esm/Sparkline/Sparkline.module.mjs +7 -0
  158. package/esm/Sparkline/Sparkline.module.mjs.map +1 -0
  159. package/esm/grid-chart.module.mjs +14 -0
  160. package/esm/grid-chart.module.mjs.map +1 -0
  161. package/esm/index.mjs +19 -19
  162. package/esm/utils/get-series-labels/get-series-labels.mjs +16 -16
  163. package/esm/utils/get-series-labels/get-series-labels.mjs.map +1 -1
  164. package/lib/BarChart/BarChart.d.ts +1 -0
  165. package/lib/DonutChart/DonutChart.d.ts +3 -3
  166. package/lib/PieChart/PieChart.d.ts +3 -3
  167. package/package.json +3 -3
  168. package/cjs/BarsList/BarsList.module.css.cjs +0 -7
  169. package/cjs/BarsList/BarsList.module.css.cjs.map +0 -1
  170. package/cjs/ChartLegend/ChartLegend.module.css.cjs +0 -7
  171. package/cjs/ChartLegend/ChartLegend.module.css.cjs.map +0 -1
  172. package/cjs/ChartTooltip/ChartTooltip.module.css.cjs +0 -7
  173. package/cjs/ChartTooltip/ChartTooltip.module.css.cjs.map +0 -1
  174. package/cjs/DonutChart/DonutChart.module.css.cjs +0 -7
  175. package/cjs/DonutChart/DonutChart.module.css.cjs.map +0 -1
  176. package/cjs/FunnelChart/FunnelChart.module.css.cjs +0 -7
  177. package/cjs/FunnelChart/FunnelChart.module.css.cjs.map +0 -1
  178. package/cjs/Heatmap/Heatmap.module.css.cjs +0 -7
  179. package/cjs/Heatmap/Heatmap.module.css.cjs.map +0 -1
  180. package/cjs/PieChart/PieChart.module.css.cjs +0 -7
  181. package/cjs/PieChart/PieChart.module.css.cjs.map +0 -1
  182. package/cjs/RadarChart/RadarChart.module.css.cjs +0 -7
  183. package/cjs/RadarChart/RadarChart.module.css.cjs.map +0 -1
  184. package/cjs/RadialBarChart/RadialBarChart.module.css.cjs +0 -7
  185. package/cjs/RadialBarChart/RadialBarChart.module.css.cjs.map +0 -1
  186. package/cjs/SankeyChart/SankeyChart.cjs +0 -276
  187. package/cjs/SankeyChart/SankeyChart.cjs.map +0 -1
  188. package/cjs/SankeyChart/SankeyChart.module.css.cjs +0 -7
  189. package/cjs/SankeyChart/SankeyChart.module.css.cjs.map +0 -1
  190. package/cjs/Sparkline/Sparkline.module.css.cjs +0 -7
  191. package/cjs/Sparkline/Sparkline.module.css.cjs.map +0 -1
  192. package/cjs/Treemap/Treemap.cjs +0 -198
  193. package/cjs/Treemap/Treemap.cjs.map +0 -1
  194. package/cjs/Treemap/Treemap.module.css.cjs +0 -7
  195. package/cjs/Treemap/Treemap.module.css.cjs.map +0 -1
  196. package/cjs/grid-chart.module.css.cjs +0 -7
  197. package/cjs/grid-chart.module.css.cjs.map +0 -1
  198. package/cjs/index.cjs.map +0 -1
  199. package/esm/BarsList/BarsList.module.css.mjs +0 -5
  200. package/esm/BarsList/BarsList.module.css.mjs.map +0 -1
  201. package/esm/ChartLegend/ChartLegend.module.css.mjs +0 -5
  202. package/esm/ChartLegend/ChartLegend.module.css.mjs.map +0 -1
  203. package/esm/ChartTooltip/ChartTooltip.module.css.mjs +0 -5
  204. package/esm/ChartTooltip/ChartTooltip.module.css.mjs.map +0 -1
  205. package/esm/DonutChart/DonutChart.module.css.mjs +0 -5
  206. package/esm/DonutChart/DonutChart.module.css.mjs.map +0 -1
  207. package/esm/FunnelChart/FunnelChart.module.css.mjs +0 -5
  208. package/esm/FunnelChart/FunnelChart.module.css.mjs.map +0 -1
  209. package/esm/Heatmap/Heatmap.module.css.mjs +0 -5
  210. package/esm/Heatmap/Heatmap.module.css.mjs.map +0 -1
  211. package/esm/PieChart/PieChart.module.css.mjs +0 -5
  212. package/esm/PieChart/PieChart.module.css.mjs.map +0 -1
  213. package/esm/RadarChart/RadarChart.module.css.mjs +0 -5
  214. package/esm/RadarChart/RadarChart.module.css.mjs.map +0 -1
  215. package/esm/RadialBarChart/RadialBarChart.module.css.mjs +0 -5
  216. package/esm/RadialBarChart/RadialBarChart.module.css.mjs.map +0 -1
  217. package/esm/SankeyChart/SankeyChart.mjs +0 -274
  218. package/esm/SankeyChart/SankeyChart.mjs.map +0 -1
  219. package/esm/SankeyChart/SankeyChart.module.css.mjs +0 -5
  220. package/esm/SankeyChart/SankeyChart.module.css.mjs.map +0 -1
  221. package/esm/Sparkline/Sparkline.module.css.mjs +0 -5
  222. package/esm/Sparkline/Sparkline.module.css.mjs.map +0 -1
  223. package/esm/Treemap/Treemap.mjs +0 -196
  224. package/esm/Treemap/Treemap.mjs.map +0 -1
  225. package/esm/Treemap/Treemap.module.css.mjs +0 -5
  226. package/esm/Treemap/Treemap.module.css.mjs.map +0 -1
  227. package/esm/grid-chart.module.css.mjs +0 -5
  228. package/esm/grid-chart.module.css.mjs.map +0 -1
  229. package/esm/index.mjs.map +0 -1
  230. package/lib/SankeyChart/SankeyChart.d.ts +0 -71
  231. package/lib/SankeyChart/index.d.ts +0 -12
  232. package/lib/Treemap/Treemap.d.ts +0 -57
  233. package/lib/Treemap/index.d.ts +0 -10
@@ -1,374 +1,293 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useState, createElement } from 'react';
4
- import { Bar, Cell, LabelList, ReferenceLine, ResponsiveContainer, BarChart as BarChart$1, Legend, XAxis, Label, YAxis, CartesianGrid, Tooltip } from 'recharts';
5
- import { createVarsResolver, getThemeColor, factory, useProps, useMantineTheme, useResolvedStylesApi, useStyles, Box } from '@mantine/core';
6
- import { ChartLegend } from '../ChartLegend/ChartLegend.mjs';
7
- import { ChartTooltip } from '../ChartTooltip/ChartTooltip.mjs';
8
- import classes from '../grid-chart.module.css.mjs';
9
-
1
+ "use client";
2
+ import { ChartTooltip } from "../ChartTooltip/ChartTooltip.mjs";
3
+ import { ChartLegend } from "../ChartLegend/ChartLegend.mjs";
4
+ import grid_chart_module_default from "../grid-chart.module.mjs";
5
+ import { Box, createVarsResolver, factory, getThemeColor, useMantineTheme, useProps, useResolvedStylesApi, useStyles } from "@mantine/core";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import React, { createElement, useState } from "react";
8
+ import { Bar, BarChart, CartesianGrid, Label, LabelList, Legend, Rectangle, ReferenceLine, ResponsiveContainer, Tooltip as Tooltip$1, XAxis, YAxis } from "recharts";
9
+ //#region packages/@mantine/charts/src/BarChart/BarChart.tsx
10
10
  function valueToPercent(value) {
11
- return `${(value * 100).toFixed(0)}%`;
11
+ return `${(value * 100).toFixed(0)}%`;
12
12
  }
13
13
  const defaultProps = {
14
- withXAxis: true,
15
- withYAxis: true,
16
- withTooltip: true,
17
- tooltipAnimationDuration: 0,
18
- fillOpacity: 1,
19
- tickLine: "y",
20
- strokeDasharray: "5 5",
21
- gridAxis: "x",
22
- type: "default"
14
+ withXAxis: true,
15
+ withYAxis: true,
16
+ withTooltip: true,
17
+ tooltipAnimationDuration: 0,
18
+ fillOpacity: 1,
19
+ tickLine: "y",
20
+ strokeDasharray: "5 5",
21
+ gridAxis: "x",
22
+ type: "default"
23
23
  };
24
- const varsResolver = createVarsResolver(
25
- (theme, { textColor, gridColor, cursorFill, barLabelColor }) => ({
26
- root: {
27
- "--chart-text-color": textColor ? getThemeColor(textColor, theme) : void 0,
28
- "--chart-grid-color": gridColor ? getThemeColor(gridColor, theme) : void 0,
29
- "--chart-cursor-fill": cursorFill ? getThemeColor(cursorFill, theme) : void 0,
30
- "--chart-bar-label-color": barLabelColor ? getThemeColor(barLabelColor, theme) : void 0
31
- }
32
- })
33
- );
24
+ const varsResolver = createVarsResolver((theme, { textColor, gridColor, cursorFill, barLabelColor }) => ({ root: {
25
+ "--chart-text-color": textColor ? getThemeColor(textColor, theme) : void 0,
26
+ "--chart-grid-color": gridColor ? getThemeColor(gridColor, theme) : void 0,
27
+ "--chart-cursor-fill": cursorFill ? getThemeColor(cursorFill, theme) : void 0,
28
+ "--chart-bar-label-color": barLabelColor ? getThemeColor(barLabelColor, theme) : void 0
29
+ } }));
34
30
  function calculateCumulativeTotal(waterfallData, dataKey) {
35
- let start = 0;
36
- let end = 0;
37
- return waterfallData.map((item) => {
38
- if (item.standalone) {
39
- for (const prop in item) {
40
- if (typeof item[prop] === "number" && prop !== dataKey) {
41
- item[prop] = [0, item[prop]];
42
- }
43
- }
44
- } else {
45
- for (const prop in item) {
46
- if (typeof item[prop] === "number" && prop !== dataKey) {
47
- end += item[prop];
48
- item[prop] = [start, end];
49
- start = end;
50
- }
51
- }
52
- }
53
- return item;
54
- });
31
+ let start = 0;
32
+ let end = 0;
33
+ return waterfallData.map((item) => {
34
+ if (item.standalone) {
35
+ for (const prop in item) if (typeof item[prop] === "number" && prop !== dataKey) item[prop] = [0, item[prop]];
36
+ } else for (const prop in item) if (typeof item[prop] === "number" && prop !== dataKey) {
37
+ end += item[prop];
38
+ item[prop] = [start, end];
39
+ start = end;
40
+ }
41
+ return item;
42
+ });
55
43
  }
56
44
  function getBarFill(barProps, series) {
57
- if (typeof barProps === "function") {
58
- return barProps(series).fill;
59
- }
60
- return barProps?.fill;
45
+ if (typeof barProps === "function") return barProps(series).fill;
46
+ return barProps?.fill;
61
47
  }
62
- const BarChart = factory((_props) => {
63
- const props = useProps("BarChart", defaultProps, _props);
64
- const {
65
- classNames,
66
- className,
67
- style,
68
- styles,
69
- unstyled,
70
- vars,
71
- data,
72
- withLegend,
73
- legendProps,
74
- series,
75
- onMouseLeave,
76
- dataKey,
77
- withTooltip,
78
- withXAxis,
79
- withYAxis,
80
- gridAxis,
81
- tickLine,
82
- xAxisProps,
83
- yAxisProps,
84
- unit,
85
- tooltipAnimationDuration,
86
- strokeDasharray,
87
- gridProps,
88
- tooltipProps,
89
- referenceLines,
90
- fillOpacity,
91
- barChartProps,
92
- type,
93
- orientation,
94
- dir,
95
- valueFormatter,
96
- children,
97
- barProps,
98
- xAxisLabel,
99
- yAxisLabel,
100
- withBarValueLabel,
101
- valueLabelProps,
102
- withRightYAxis,
103
- rightYAxisLabel,
104
- rightYAxisProps,
105
- minBarSize,
106
- maxBarWidth,
107
- mod,
108
- getBarColor,
109
- gridColor,
110
- textColor,
111
- attributes,
112
- ...others
113
- } = props;
114
- const theme = useMantineTheme();
115
- const withXTickLine = gridAxis !== "none" && (tickLine === "x" || tickLine === "xy");
116
- const withYTickLine = gridAxis !== "none" && (tickLine === "y" || tickLine === "xy");
117
- const [highlightedArea, setHighlightedArea] = useState(null);
118
- const shouldHighlight = highlightedArea !== null;
119
- const stacked = type === "stacked" || type === "percent";
120
- const tickFormatter = type === "percent" ? valueToPercent : valueFormatter;
121
- const handleMouseLeave = (event) => {
122
- setHighlightedArea(null);
123
- onMouseLeave?.(event);
124
- };
125
- const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
126
- classNames,
127
- styles,
128
- props
129
- });
130
- const inputData = type === "waterfall" ? calculateCumulativeTotal(data, dataKey) : data;
131
- const getStyles = useStyles({
132
- name: "BarChart",
133
- classes,
134
- props,
135
- className,
136
- style,
137
- classNames,
138
- styles,
139
- unstyled,
140
- attributes,
141
- vars,
142
- varsResolver
143
- });
144
- const bars = series.map((item) => {
145
- const color = getThemeColor(item.color, theme);
146
- const dimmed = shouldHighlight && highlightedArea !== item.name;
147
- return /* @__PURE__ */ createElement(
148
- Bar,
149
- {
150
- ...getStyles("bar"),
151
- key: item.name,
152
- name: item.name,
153
- dataKey: item.name,
154
- fill: color,
155
- stroke: color,
156
- isAnimationActive: false,
157
- fillOpacity: dimmed ? 0.1 : fillOpacity,
158
- strokeOpacity: dimmed ? 0.2 : 0,
159
- stackId: stacked ? "stack" : item.stackId || void 0,
160
- yAxisId: item.yAxisId || void 0,
161
- minPointSize: minBarSize,
162
- ...typeof barProps === "function" ? barProps(item) : barProps
163
- },
164
- inputData.map((entry, index) => {
165
- const cellColor = entry.color ? getThemeColor(entry.color, theme) : typeof getBarColor === "function" ? getThemeColor(getBarColor(entry[item.name], item), theme) : getBarFill(barProps, item) || color;
166
- return /* @__PURE__ */ jsx(Cell, { fill: cellColor }, `cell-${index}`);
167
- }),
168
- withBarValueLabel && /* @__PURE__ */ jsx(
169
- LabelList,
170
- {
171
- position: orientation === "vertical" ? "right" : "top",
172
- fontSize: 12,
173
- fill: "var(--chart-bar-label-color, var(--mantine-color-dimmed))",
174
- formatter: (val) => tickFormatter?.(val),
175
- ...typeof valueLabelProps === "function" ? valueLabelProps(item) : valueLabelProps
176
- }
177
- )
178
- );
179
- });
180
- const referenceLinesItems = referenceLines?.map((line, index) => {
181
- const color = getThemeColor(line.color, theme);
182
- return /* @__PURE__ */ jsx(
183
- ReferenceLine,
184
- {
185
- stroke: line.color ? color : "var(--chart-grid-color)",
186
- strokeWidth: 1,
187
- yAxisId: line.yAxisId || void 0,
188
- ...line,
189
- label: {
190
- value: line.label,
191
- fill: line.color ? color : "currentColor",
192
- fontSize: 12,
193
- position: line.labelPosition ?? "insideBottomLeft"
194
- },
195
- ...getStyles("referenceLine")
196
- },
197
- index
198
- );
199
- });
200
- const sharedYAxisProps = {
201
- axisLine: false,
202
- ...orientation === "vertical" ? { dataKey, type: "category" } : { type: "number" },
203
- tickLine: withYTickLine ? { stroke: "currentColor" } : false,
204
- allowDecimals: true,
205
- unit,
206
- tickFormatter: orientation === "vertical" ? void 0 : tickFormatter,
207
- ...getStyles("axis")
208
- };
209
- return /* @__PURE__ */ jsx(
210
- Box,
211
- {
212
- ...getStyles("root"),
213
- onMouseLeave: handleMouseLeave,
214
- dir: dir || "ltr",
215
- mod: [{ orientation }, mod],
216
- ...others,
217
- children: /* @__PURE__ */ jsx(ResponsiveContainer, { ...getStyles("container"), children: /* @__PURE__ */ jsxs(
218
- BarChart$1,
219
- {
220
- data: inputData,
221
- stackOffset: type === "percent" ? "expand" : void 0,
222
- layout: orientation,
223
- maxBarSize: maxBarWidth,
224
- margin: {
225
- bottom: xAxisLabel ? 30 : void 0,
226
- left: yAxisLabel ? 10 : void 0,
227
- right: yAxisLabel ? 5 : void 0
228
- },
229
- ...barChartProps,
230
- children: [
231
- withLegend && /* @__PURE__ */ jsx(
232
- Legend,
233
- {
234
- verticalAlign: "top",
235
- content: (payload) => /* @__PURE__ */ jsx(
236
- ChartLegend,
237
- {
238
- payload: payload.payload,
239
- onHighlight: setHighlightedArea,
240
- legendPosition: legendProps?.verticalAlign || "top",
241
- classNames: resolvedClassNames,
242
- styles: resolvedStyles,
243
- series,
244
- showColor: type !== "waterfall",
245
- attributes
246
- }
247
- ),
248
- ...legendProps
249
- }
250
- ),
251
- /* @__PURE__ */ jsxs(
252
- XAxis,
253
- {
254
- hide: !withXAxis,
255
- ...orientation === "vertical" ? { type: "number" } : { dataKey },
256
- tick: { transform: "translate(0, 10)", fontSize: 12, fill: "currentColor" },
257
- stroke: "",
258
- interval: "preserveStartEnd",
259
- tickLine: withXTickLine ? { stroke: "currentColor" } : false,
260
- minTickGap: 5,
261
- tickFormatter: orientation === "vertical" ? tickFormatter : void 0,
262
- ...getStyles("axis"),
263
- ...xAxisProps,
264
- children: [
265
- xAxisLabel && /* @__PURE__ */ jsx(Label, { position: "insideBottom", offset: -20, fontSize: 12, ...getStyles("axisLabel"), children: xAxisLabel }),
266
- xAxisProps?.children
267
- ]
268
- }
269
- ),
270
- /* @__PURE__ */ jsxs(
271
- YAxis,
272
- {
273
- orientation: "left",
274
- tick: { transform: "translate(-10, 0)", fontSize: 12, fill: "currentColor" },
275
- hide: !withYAxis,
276
- ...sharedYAxisProps,
277
- ...yAxisProps,
278
- children: [
279
- yAxisLabel && /* @__PURE__ */ jsx(
280
- Label,
281
- {
282
- position: "insideLeft",
283
- angle: -90,
284
- textAnchor: "middle",
285
- fontSize: 12,
286
- offset: -5,
287
- ...getStyles("axisLabel"),
288
- children: yAxisLabel
289
- }
290
- ),
291
- yAxisProps?.children
292
- ]
293
- }
294
- ),
295
- /* @__PURE__ */ jsxs(
296
- YAxis,
297
- {
298
- yAxisId: "right",
299
- orientation: "right",
300
- tick: { transform: "translate(10, 0)", fontSize: 12, fill: "currentColor" },
301
- hide: !withRightYAxis,
302
- ...sharedYAxisProps,
303
- ...rightYAxisProps,
304
- children: [
305
- rightYAxisLabel && /* @__PURE__ */ jsx(
306
- Label,
307
- {
308
- position: "insideRight",
309
- angle: 90,
310
- textAnchor: "middle",
311
- fontSize: 12,
312
- offset: -5,
313
- ...getStyles("axisLabel"),
314
- children: rightYAxisLabel
315
- }
316
- ),
317
- yAxisProps?.children
318
- ]
319
- }
320
- ),
321
- /* @__PURE__ */ jsx(
322
- CartesianGrid,
323
- {
324
- strokeDasharray,
325
- vertical: gridAxis === "y" || gridAxis === "xy",
326
- horizontal: gridAxis === "x" || gridAxis === "xy",
327
- ...getStyles("grid"),
328
- ...gridProps
329
- }
330
- ),
331
- withTooltip && /* @__PURE__ */ jsx(
332
- Tooltip,
333
- {
334
- animationDuration: tooltipAnimationDuration,
335
- isAnimationActive: tooltipAnimationDuration !== 0,
336
- position: orientation === "vertical" ? {} : { y: 0 },
337
- cursor: {
338
- stroke: "var(--chart-grid-color)",
339
- strokeWidth: 1,
340
- strokeDasharray,
341
- fill: "var(--chart-cursor-fill)"
342
- },
343
- content: ({ label, payload, labelFormatter }) => /* @__PURE__ */ jsx(
344
- ChartTooltip,
345
- {
346
- label: labelFormatter && payload ? labelFormatter(label, payload) : label,
347
- payload,
348
- type: type === "waterfall" ? "scatter" : void 0,
349
- unit,
350
- classNames: resolvedClassNames,
351
- styles: resolvedStyles,
352
- series,
353
- valueFormatter,
354
- attributes
355
- }
356
- ),
357
- ...tooltipProps
358
- }
359
- ),
360
- bars,
361
- referenceLinesItems,
362
- children
363
- ]
364
- }
365
- ) })
366
- }
367
- );
48
+ const BarChart$1 = factory((_props) => {
49
+ const props = useProps("BarChart", defaultProps, _props);
50
+ const { classNames, className, style, styles, unstyled, vars, data, withLegend, legendProps, series, onMouseLeave, dataKey, withTooltip, withXAxis, withYAxis, gridAxis, tickLine, xAxisProps, yAxisProps, unit, tooltipAnimationDuration, strokeDasharray, gridProps, tooltipProps, referenceLines, fillOpacity, barChartProps, type, orientation, dir, valueFormatter, children, barProps, xAxisLabel, yAxisLabel, withBarValueLabel, valueLabelProps, withRightYAxis, rightYAxisLabel, rightYAxisProps, minBarSize, maxBarWidth, mod, getBarColor, gridColor, textColor, attributes, ...others } = props;
51
+ const theme = useMantineTheme();
52
+ const withXTickLine = gridAxis !== "none" && (tickLine === "x" || tickLine === "xy");
53
+ const withYTickLine = gridAxis !== "none" && (tickLine === "y" || tickLine === "xy");
54
+ const [highlightedArea, setHighlightedArea] = useState(null);
55
+ const shouldHighlight = highlightedArea !== null;
56
+ const stacked = type === "stacked" || type === "percent";
57
+ const tickFormatter = type === "percent" ? valueToPercent : valueFormatter;
58
+ const handleMouseLeave = (event) => {
59
+ setHighlightedArea(null);
60
+ onMouseLeave?.(event);
61
+ };
62
+ const { resolvedClassNames, resolvedStyles } = useResolvedStylesApi({
63
+ classNames,
64
+ styles,
65
+ props
66
+ });
67
+ const inputData = type === "waterfall" ? calculateCumulativeTotal(data, dataKey) : data;
68
+ const getStyles = useStyles({
69
+ name: "BarChart",
70
+ classes: grid_chart_module_default,
71
+ props,
72
+ className,
73
+ style,
74
+ classNames,
75
+ styles,
76
+ unstyled,
77
+ attributes,
78
+ vars,
79
+ varsResolver
80
+ });
81
+ const bars = series.map((item) => {
82
+ const color = getThemeColor(item.color, theme);
83
+ const dimmed = shouldHighlight && highlightedArea !== item.name;
84
+ const resolvedBarProps = typeof barProps === "function" ? barProps(item) : barProps;
85
+ const userShape = resolvedBarProps?.shape;
86
+ return /* @__PURE__ */ createElement(Bar, {
87
+ ...getStyles("bar"),
88
+ key: item.name,
89
+ name: item.name,
90
+ dataKey: item.name,
91
+ fill: color,
92
+ stroke: color,
93
+ isAnimationActive: false,
94
+ fillOpacity: dimmed ? .1 : fillOpacity,
95
+ strokeOpacity: dimmed ? .2 : 0,
96
+ stackId: stacked ? "stack" : item.stackId || void 0,
97
+ yAxisId: item.yAxisId || void 0,
98
+ minPointSize: minBarSize,
99
+ ...resolvedBarProps,
100
+ shape: (shapeProps) => {
101
+ const entry = shapeProps.payload;
102
+ const cellColor = entry?.color ? getThemeColor(entry.color, theme) : typeof getBarColor === "function" ? getThemeColor(getBarColor(entry?.[item.name], item), theme) : getBarFill(barProps, item) || color;
103
+ const coloredProps = {
104
+ ...shapeProps,
105
+ fill: cellColor
106
+ };
107
+ if (typeof userShape === "function") return userShape(coloredProps);
108
+ if (React.isValidElement(userShape)) return React.cloneElement(userShape, coloredProps);
109
+ if (typeof userShape === "object" && userShape) return /* @__PURE__ */ jsx(Rectangle, {
110
+ ...coloredProps,
111
+ ...userShape
112
+ });
113
+ return /* @__PURE__ */ jsx(Rectangle, { ...coloredProps });
114
+ }
115
+ }, withBarValueLabel && /* @__PURE__ */ jsx(LabelList, {
116
+ position: orientation === "vertical" ? "right" : "top",
117
+ fontSize: 12,
118
+ fill: "var(--chart-bar-label-color, var(--mantine-color-dimmed))",
119
+ formatter: (val) => tickFormatter?.(val),
120
+ ...typeof valueLabelProps === "function" ? valueLabelProps(item) : valueLabelProps
121
+ }));
122
+ });
123
+ const referenceLinesItems = referenceLines?.map((line, index) => {
124
+ const color = getThemeColor(line.color, theme);
125
+ return /* @__PURE__ */ jsx(ReferenceLine, {
126
+ stroke: line.color ? color : "var(--chart-grid-color)",
127
+ strokeWidth: 1,
128
+ yAxisId: line.yAxisId || void 0,
129
+ ...line,
130
+ label: {
131
+ value: line.label,
132
+ fill: line.color ? color : "currentColor",
133
+ fontSize: 12,
134
+ position: line.labelPosition ?? "insideBottomLeft"
135
+ },
136
+ ...getStyles("referenceLine")
137
+ }, index);
138
+ });
139
+ const sharedYAxisProps = {
140
+ axisLine: false,
141
+ ...orientation === "vertical" ? {
142
+ dataKey,
143
+ type: "category"
144
+ } : { type: "number" },
145
+ tickLine: withYTickLine ? { stroke: "currentColor" } : false,
146
+ allowDecimals: true,
147
+ unit,
148
+ tickFormatter: orientation === "vertical" ? void 0 : tickFormatter,
149
+ ...getStyles("axis")
150
+ };
151
+ return /* @__PURE__ */ jsx(Box, {
152
+ ...getStyles("root"),
153
+ onMouseLeave: handleMouseLeave,
154
+ dir: dir || "ltr",
155
+ mod: [{ orientation }, mod],
156
+ ...others,
157
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, {
158
+ ...getStyles("container"),
159
+ children: /* @__PURE__ */ jsxs(BarChart, {
160
+ data: inputData,
161
+ stackOffset: type === "percent" ? "expand" : void 0,
162
+ layout: orientation,
163
+ maxBarSize: maxBarWidth,
164
+ margin: {
165
+ bottom: xAxisLabel ? 30 : void 0,
166
+ left: yAxisLabel ? 10 : void 0,
167
+ right: yAxisLabel ? 5 : void 0
168
+ },
169
+ ...barChartProps,
170
+ children: [
171
+ withLegend && /* @__PURE__ */ jsx(Legend, {
172
+ verticalAlign: "top",
173
+ content: (payload) => /* @__PURE__ */ jsx(ChartLegend, {
174
+ payload: payload.payload,
175
+ onHighlight: setHighlightedArea,
176
+ legendPosition: legendProps?.verticalAlign || "top",
177
+ classNames: resolvedClassNames,
178
+ styles: resolvedStyles,
179
+ series,
180
+ showColor: type !== "waterfall",
181
+ attributes
182
+ }),
183
+ ...legendProps
184
+ }),
185
+ /* @__PURE__ */ jsxs(XAxis, {
186
+ hide: !withXAxis,
187
+ ...orientation === "vertical" ? { type: "number" } : { dataKey },
188
+ tick: {
189
+ transform: "translate(0, 10)",
190
+ fontSize: 12,
191
+ fill: "currentColor"
192
+ },
193
+ stroke: "",
194
+ interval: "preserveStartEnd",
195
+ tickLine: withXTickLine ? { stroke: "currentColor" } : false,
196
+ minTickGap: 5,
197
+ tickFormatter: orientation === "vertical" ? tickFormatter : void 0,
198
+ ...getStyles("axis"),
199
+ ...xAxisProps,
200
+ children: [xAxisLabel && /* @__PURE__ */ jsx(Label, {
201
+ position: "insideBottom",
202
+ offset: -20,
203
+ fontSize: 12,
204
+ ...getStyles("axisLabel"),
205
+ children: xAxisLabel
206
+ }), xAxisProps?.children]
207
+ }),
208
+ /* @__PURE__ */ jsxs(YAxis, {
209
+ orientation: "left",
210
+ tick: {
211
+ transform: "translate(-10, 0)",
212
+ fontSize: 12,
213
+ fill: "currentColor"
214
+ },
215
+ hide: !withYAxis,
216
+ ...sharedYAxisProps,
217
+ ...yAxisProps,
218
+ children: [yAxisLabel && /* @__PURE__ */ jsx(Label, {
219
+ position: "insideLeft",
220
+ angle: -90,
221
+ textAnchor: "middle",
222
+ fontSize: 12,
223
+ offset: -5,
224
+ ...getStyles("axisLabel"),
225
+ children: yAxisLabel
226
+ }), yAxisProps?.children]
227
+ }),
228
+ /* @__PURE__ */ jsxs(YAxis, {
229
+ yAxisId: "right",
230
+ orientation: "right",
231
+ tick: {
232
+ transform: "translate(10, 0)",
233
+ fontSize: 12,
234
+ fill: "currentColor"
235
+ },
236
+ hide: !withRightYAxis,
237
+ ...sharedYAxisProps,
238
+ ...rightYAxisProps,
239
+ children: [rightYAxisLabel && /* @__PURE__ */ jsx(Label, {
240
+ position: "insideRight",
241
+ angle: 90,
242
+ textAnchor: "middle",
243
+ fontSize: 12,
244
+ offset: -5,
245
+ ...getStyles("axisLabel"),
246
+ children: rightYAxisLabel
247
+ }), yAxisProps?.children]
248
+ }),
249
+ /* @__PURE__ */ jsx(CartesianGrid, {
250
+ strokeDasharray,
251
+ vertical: gridAxis === "y" || gridAxis === "xy",
252
+ horizontal: gridAxis === "x" || gridAxis === "xy",
253
+ ...getStyles("grid"),
254
+ ...gridProps
255
+ }),
256
+ withTooltip && /* @__PURE__ */ jsx(Tooltip$1, {
257
+ animationDuration: tooltipAnimationDuration,
258
+ isAnimationActive: tooltipAnimationDuration !== 0,
259
+ position: orientation === "vertical" ? {} : { y: 0 },
260
+ cursor: {
261
+ stroke: "var(--chart-grid-color)",
262
+ strokeWidth: 1,
263
+ strokeDasharray,
264
+ fill: "var(--chart-cursor-fill)"
265
+ },
266
+ content: ({ label, payload, labelFormatter }) => /* @__PURE__ */ jsx(ChartTooltip, {
267
+ label: labelFormatter && payload ? labelFormatter(label, payload) : label,
268
+ payload,
269
+ type: type === "waterfall" ? "scatter" : void 0,
270
+ unit,
271
+ classNames: resolvedClassNames,
272
+ styles: resolvedStyles,
273
+ series,
274
+ valueFormatter,
275
+ attributes
276
+ }),
277
+ ...tooltipProps
278
+ }),
279
+ bars,
280
+ referenceLinesItems,
281
+ children
282
+ ]
283
+ })
284
+ })
285
+ });
368
286
  });
369
- BarChart.displayName = "@mantine/charts/BarChart";
370
- BarChart.classes = classes;
371
- BarChart.varsResolver = varsResolver;
287
+ BarChart$1.displayName = "@mantine/charts/BarChart";
288
+ BarChart$1.classes = grid_chart_module_default;
289
+ BarChart$1.varsResolver = varsResolver;
290
+ //#endregion
291
+ export { BarChart$1 as BarChart };
372
292
 
373
- export { BarChart };
374
- //# sourceMappingURL=BarChart.mjs.map
293
+ //# sourceMappingURL=BarChart.mjs.map