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

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 (234) hide show
  1. package/cjs/AreaChart/AreaChart.cjs +304 -376
  2. package/cjs/AreaChart/AreaChart.cjs.map +1 -1
  3. package/cjs/AreaChart/AreaGradient.cjs +32 -11
  4. package/cjs/AreaChart/AreaGradient.cjs.map +1 -1
  5. package/cjs/AreaChart/AreaSplit.cjs +24 -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 +266 -364
  10. package/cjs/BarChart/BarChart.cjs.map +1 -1
  11. package/cjs/BarsList/BarsList.cjs +85 -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 +123 -143
  16. package/cjs/BubbleChart/BubbleChart.cjs.map +1 -1
  17. package/cjs/ChartLegend/ChartLegend.cjs +65 -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 +100 -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 +300 -389
  26. package/cjs/CompositeChart/CompositeChart.cjs.map +1 -1
  27. package/cjs/DonutChart/DonutChart.cjs +121 -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 +155 -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 +47 -72
  40. package/cjs/Heatmap/HeatmapSplitWeeks.cjs.map +1 -1
  41. package/cjs/Heatmap/HeatmapWeeks.cjs +44 -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 +274 -341
  56. package/cjs/LineChart/LineChart.cjs.map +1 -1
  57. package/cjs/PieChart/PieChart.cjs +124 -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 +19 -20
  62. package/cjs/PointLabel/PointLabel.cjs.map +1 -1
  63. package/cjs/RadarChart/RadarChart.cjs +127 -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 +116 -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/SankeyChart/SankeyChart.cjs +182 -256
  72. package/cjs/SankeyChart/SankeyChart.cjs.map +1 -1
  73. package/cjs/SankeyChart/SankeyChart.module.cjs +7 -0
  74. package/cjs/SankeyChart/SankeyChart.module.cjs.map +1 -0
  75. package/cjs/ScatterChart/ScatterChart.cjs +218 -278
  76. package/cjs/ScatterChart/ScatterChart.cjs.map +1 -1
  77. package/cjs/Sparkline/Sparkline.cjs +70 -99
  78. package/cjs/Sparkline/Sparkline.cjs.map +1 -1
  79. package/cjs/Sparkline/Sparkline.module.cjs +7 -0
  80. package/cjs/Sparkline/Sparkline.module.cjs.map +1 -0
  81. package/cjs/Treemap/Treemap.cjs +122 -187
  82. package/cjs/Treemap/Treemap.cjs.map +1 -1
  83. package/cjs/Treemap/Treemap.module.cjs +7 -0
  84. package/cjs/Treemap/Treemap.module.cjs.map +1 -0
  85. package/cjs/_virtual/_rolldown/runtime.cjs +24 -0
  86. package/cjs/grid-chart.module.cjs +14 -0
  87. package/cjs/grid-chart.module.cjs.map +1 -0
  88. package/cjs/index.cjs +39 -44
  89. package/cjs/utils/get-series-labels/get-series-labels.cjs +16 -18
  90. package/cjs/utils/get-series-labels/get-series-labels.cjs.map +1 -1
  91. package/esm/AreaChart/AreaChart.mjs +306 -376
  92. package/esm/AreaChart/AreaChart.mjs.map +1 -1
  93. package/esm/AreaChart/AreaGradient.mjs +32 -9
  94. package/esm/AreaChart/AreaGradient.mjs.map +1 -1
  95. package/esm/AreaChart/AreaSplit.mjs +24 -25
  96. package/esm/AreaChart/AreaSplit.mjs.map +1 -1
  97. package/esm/AreaChart/get-split-offset.mjs +18 -17
  98. package/esm/AreaChart/get-split-offset.mjs.map +1 -1
  99. package/esm/BarChart/BarChart.mjs +268 -364
  100. package/esm/BarChart/BarChart.mjs.map +1 -1
  101. package/esm/BarsList/BarsList.mjs +84 -112
  102. package/esm/BarsList/BarsList.mjs.map +1 -1
  103. package/esm/BarsList/BarsList.module.mjs +13 -0
  104. package/esm/BarsList/BarsList.module.mjs.map +1 -0
  105. package/esm/BubbleChart/BubbleChart.mjs +122 -140
  106. package/esm/BubbleChart/BubbleChart.mjs.map +1 -1
  107. package/esm/ChartLegend/ChartLegend.mjs +64 -80
  108. package/esm/ChartLegend/ChartLegend.mjs.map +1 -1
  109. package/esm/ChartLegend/ChartLegend.module.mjs +12 -0
  110. package/esm/ChartLegend/ChartLegend.module.mjs.map +1 -0
  111. package/esm/ChartTooltip/ChartTooltip.mjs +99 -113
  112. package/esm/ChartTooltip/ChartTooltip.mjs.map +1 -1
  113. package/esm/ChartTooltip/ChartTooltip.module.mjs +16 -0
  114. package/esm/ChartTooltip/ChartTooltip.module.mjs.map +1 -0
  115. package/esm/CompositeChart/CompositeChart.mjs +299 -386
  116. package/esm/CompositeChart/CompositeChart.mjs.map +1 -1
  117. package/esm/DonutChart/DonutChart.mjs +120 -165
  118. package/esm/DonutChart/DonutChart.mjs.map +1 -1
  119. package/esm/DonutChart/DonutChart.module.mjs +10 -0
  120. package/esm/DonutChart/DonutChart.module.mjs.map +1 -0
  121. package/esm/FunnelChart/FunnelChart.mjs +93 -129
  122. package/esm/FunnelChart/FunnelChart.mjs.map +1 -1
  123. package/esm/FunnelChart/FunnelChart.module.mjs +7 -0
  124. package/esm/FunnelChart/FunnelChart.module.mjs.map +1 -0
  125. package/esm/Heatmap/Heatmap.mjs +154 -185
  126. package/esm/Heatmap/Heatmap.mjs.map +1 -1
  127. package/esm/Heatmap/Heatmap.module.mjs +12 -0
  128. package/esm/Heatmap/Heatmap.module.mjs.map +1 -0
  129. package/esm/Heatmap/HeatmapSplitWeeks.mjs +47 -70
  130. package/esm/Heatmap/HeatmapSplitWeeks.mjs.map +1 -1
  131. package/esm/Heatmap/HeatmapWeeks.mjs +44 -55
  132. package/esm/Heatmap/HeatmapWeeks.mjs.map +1 -1
  133. package/esm/Heatmap/get-boundaries/get-boundaries.mjs +8 -8
  134. package/esm/Heatmap/get-boundaries/get-boundaries.mjs.map +1 -1
  135. package/esm/Heatmap/get-columns/get-columns.mjs +74 -62
  136. package/esm/Heatmap/get-columns/get-columns.mjs.map +1 -1
  137. package/esm/Heatmap/get-dates-range/get-dates-range.mjs +43 -52
  138. package/esm/Heatmap/get-dates-range/get-dates-range.mjs.map +1 -1
  139. package/esm/Heatmap/get-heat-color/get-heat-color.mjs +7 -6
  140. package/esm/Heatmap/get-heat-color/get-heat-color.mjs.map +1 -1
  141. package/esm/Heatmap/get-months-range/get-months-range.mjs +23 -17
  142. package/esm/Heatmap/get-months-range/get-months-range.mjs.map +1 -1
  143. package/esm/Heatmap/rotate-weekdays-names/rotate-weekdays-names.mjs +8 -8
  144. package/esm/Heatmap/rotate-weekdays-names/rotate-weekdays-names.mjs.map +1 -1
  145. package/esm/LineChart/LineChart.mjs +276 -341
  146. package/esm/LineChart/LineChart.mjs.map +1 -1
  147. package/esm/PieChart/PieChart.mjs +126 -171
  148. package/esm/PieChart/PieChart.mjs.map +1 -1
  149. package/esm/PieChart/PieChart.module.mjs +7 -0
  150. package/esm/PieChart/PieChart.module.mjs.map +1 -0
  151. package/esm/PointLabel/PointLabel.mjs +19 -18
  152. package/esm/PointLabel/PointLabel.mjs.map +1 -1
  153. package/esm/RadarChart/RadarChart.mjs +129 -157
  154. package/esm/RadarChart/RadarChart.mjs.map +1 -1
  155. package/esm/RadarChart/RadarChart.module.mjs +10 -0
  156. package/esm/RadarChart/RadarChart.module.mjs.map +1 -0
  157. package/esm/RadialBarChart/RadialBarChart.mjs +118 -147
  158. package/esm/RadialBarChart/RadialBarChart.mjs.map +1 -1
  159. package/esm/RadialBarChart/RadialBarChart.module.mjs +10 -0
  160. package/esm/RadialBarChart/RadialBarChart.module.mjs.map +1 -0
  161. package/esm/SankeyChart/SankeyChart.mjs +179 -253
  162. package/esm/SankeyChart/SankeyChart.mjs.map +1 -1
  163. package/esm/SankeyChart/SankeyChart.module.mjs +7 -0
  164. package/esm/SankeyChart/SankeyChart.module.mjs.map +1 -0
  165. package/esm/ScatterChart/ScatterChart.mjs +220 -278
  166. package/esm/ScatterChart/ScatterChart.mjs.map +1 -1
  167. package/esm/Sparkline/Sparkline.mjs +69 -96
  168. package/esm/Sparkline/Sparkline.mjs.map +1 -1
  169. package/esm/Sparkline/Sparkline.module.mjs +7 -0
  170. package/esm/Sparkline/Sparkline.module.mjs.map +1 -0
  171. package/esm/Treemap/Treemap.mjs +122 -187
  172. package/esm/Treemap/Treemap.mjs.map +1 -1
  173. package/esm/Treemap/Treemap.module.mjs +7 -0
  174. package/esm/Treemap/Treemap.module.mjs.map +1 -0
  175. package/esm/grid-chart.module.mjs +14 -0
  176. package/esm/grid-chart.module.mjs.map +1 -0
  177. package/esm/index.mjs +19 -19
  178. package/esm/utils/get-series-labels/get-series-labels.mjs +16 -16
  179. package/esm/utils/get-series-labels/get-series-labels.mjs.map +1 -1
  180. package/package.json +3 -3
  181. package/cjs/BarsList/BarsList.module.css.cjs +0 -7
  182. package/cjs/BarsList/BarsList.module.css.cjs.map +0 -1
  183. package/cjs/ChartLegend/ChartLegend.module.css.cjs +0 -7
  184. package/cjs/ChartLegend/ChartLegend.module.css.cjs.map +0 -1
  185. package/cjs/ChartTooltip/ChartTooltip.module.css.cjs +0 -7
  186. package/cjs/ChartTooltip/ChartTooltip.module.css.cjs.map +0 -1
  187. package/cjs/DonutChart/DonutChart.module.css.cjs +0 -7
  188. package/cjs/DonutChart/DonutChart.module.css.cjs.map +0 -1
  189. package/cjs/FunnelChart/FunnelChart.module.css.cjs +0 -7
  190. package/cjs/FunnelChart/FunnelChart.module.css.cjs.map +0 -1
  191. package/cjs/Heatmap/Heatmap.module.css.cjs +0 -7
  192. package/cjs/Heatmap/Heatmap.module.css.cjs.map +0 -1
  193. package/cjs/PieChart/PieChart.module.css.cjs +0 -7
  194. package/cjs/PieChart/PieChart.module.css.cjs.map +0 -1
  195. package/cjs/RadarChart/RadarChart.module.css.cjs +0 -7
  196. package/cjs/RadarChart/RadarChart.module.css.cjs.map +0 -1
  197. package/cjs/RadialBarChart/RadialBarChart.module.css.cjs +0 -7
  198. package/cjs/RadialBarChart/RadialBarChart.module.css.cjs.map +0 -1
  199. package/cjs/SankeyChart/SankeyChart.module.css.cjs +0 -7
  200. package/cjs/SankeyChart/SankeyChart.module.css.cjs.map +0 -1
  201. package/cjs/Sparkline/Sparkline.module.css.cjs +0 -7
  202. package/cjs/Sparkline/Sparkline.module.css.cjs.map +0 -1
  203. package/cjs/Treemap/Treemap.module.css.cjs +0 -7
  204. package/cjs/Treemap/Treemap.module.css.cjs.map +0 -1
  205. package/cjs/grid-chart.module.css.cjs +0 -7
  206. package/cjs/grid-chart.module.css.cjs.map +0 -1
  207. package/cjs/index.cjs.map +0 -1
  208. package/esm/BarsList/BarsList.module.css.mjs +0 -5
  209. package/esm/BarsList/BarsList.module.css.mjs.map +0 -1
  210. package/esm/ChartLegend/ChartLegend.module.css.mjs +0 -5
  211. package/esm/ChartLegend/ChartLegend.module.css.mjs.map +0 -1
  212. package/esm/ChartTooltip/ChartTooltip.module.css.mjs +0 -5
  213. package/esm/ChartTooltip/ChartTooltip.module.css.mjs.map +0 -1
  214. package/esm/DonutChart/DonutChart.module.css.mjs +0 -5
  215. package/esm/DonutChart/DonutChart.module.css.mjs.map +0 -1
  216. package/esm/FunnelChart/FunnelChart.module.css.mjs +0 -5
  217. package/esm/FunnelChart/FunnelChart.module.css.mjs.map +0 -1
  218. package/esm/Heatmap/Heatmap.module.css.mjs +0 -5
  219. package/esm/Heatmap/Heatmap.module.css.mjs.map +0 -1
  220. package/esm/PieChart/PieChart.module.css.mjs +0 -5
  221. package/esm/PieChart/PieChart.module.css.mjs.map +0 -1
  222. package/esm/RadarChart/RadarChart.module.css.mjs +0 -5
  223. package/esm/RadarChart/RadarChart.module.css.mjs.map +0 -1
  224. package/esm/RadialBarChart/RadialBarChart.module.css.mjs +0 -5
  225. package/esm/RadialBarChart/RadialBarChart.module.css.mjs.map +0 -1
  226. package/esm/SankeyChart/SankeyChart.module.css.mjs +0 -5
  227. package/esm/SankeyChart/SankeyChart.module.css.mjs.map +0 -1
  228. package/esm/Sparkline/Sparkline.module.css.mjs +0 -5
  229. package/esm/Sparkline/Sparkline.module.css.mjs.map +0 -1
  230. package/esm/Treemap/Treemap.module.css.mjs +0 -5
  231. package/esm/Treemap/Treemap.module.css.mjs.map +0 -1
  232. package/esm/grid-chart.module.css.mjs +0 -5
  233. package/esm/grid-chart.module.css.mjs.map +0 -1
  234. package/esm/index.mjs.map +0 -1
@@ -1,374 +1,278 @@
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 { createElement, useState } from "react";
8
+ import { Bar, BarChart, CartesianGrid, Cell, Label, LabelList, Legend, 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
+ return /* @__PURE__ */ createElement(Bar, {
85
+ ...getStyles("bar"),
86
+ key: item.name,
87
+ name: item.name,
88
+ dataKey: item.name,
89
+ fill: color,
90
+ stroke: color,
91
+ isAnimationActive: false,
92
+ fillOpacity: dimmed ? .1 : fillOpacity,
93
+ strokeOpacity: dimmed ? .2 : 0,
94
+ stackId: stacked ? "stack" : item.stackId || void 0,
95
+ yAxisId: item.yAxisId || void 0,
96
+ minPointSize: minBarSize,
97
+ ...typeof barProps === "function" ? barProps(item) : barProps
98
+ }, inputData.map((entry, index) => {
99
+ return /* @__PURE__ */ jsx(Cell, { fill: entry.color ? getThemeColor(entry.color, theme) : typeof getBarColor === "function" ? getThemeColor(getBarColor(entry[item.name], item), theme) : getBarFill(barProps, item) || color }, `cell-${index}`);
100
+ }), withBarValueLabel && /* @__PURE__ */ jsx(LabelList, {
101
+ position: orientation === "vertical" ? "right" : "top",
102
+ fontSize: 12,
103
+ fill: "var(--chart-bar-label-color, var(--mantine-color-dimmed))",
104
+ formatter: (val) => tickFormatter?.(val),
105
+ ...typeof valueLabelProps === "function" ? valueLabelProps(item) : valueLabelProps
106
+ }));
107
+ });
108
+ const referenceLinesItems = referenceLines?.map((line, index) => {
109
+ const color = getThemeColor(line.color, theme);
110
+ return /* @__PURE__ */ jsx(ReferenceLine, {
111
+ stroke: line.color ? color : "var(--chart-grid-color)",
112
+ strokeWidth: 1,
113
+ yAxisId: line.yAxisId || void 0,
114
+ ...line,
115
+ label: {
116
+ value: line.label,
117
+ fill: line.color ? color : "currentColor",
118
+ fontSize: 12,
119
+ position: line.labelPosition ?? "insideBottomLeft"
120
+ },
121
+ ...getStyles("referenceLine")
122
+ }, index);
123
+ });
124
+ const sharedYAxisProps = {
125
+ axisLine: false,
126
+ ...orientation === "vertical" ? {
127
+ dataKey,
128
+ type: "category"
129
+ } : { type: "number" },
130
+ tickLine: withYTickLine ? { stroke: "currentColor" } : false,
131
+ allowDecimals: true,
132
+ unit,
133
+ tickFormatter: orientation === "vertical" ? void 0 : tickFormatter,
134
+ ...getStyles("axis")
135
+ };
136
+ return /* @__PURE__ */ jsx(Box, {
137
+ ...getStyles("root"),
138
+ onMouseLeave: handleMouseLeave,
139
+ dir: dir || "ltr",
140
+ mod: [{ orientation }, mod],
141
+ ...others,
142
+ children: /* @__PURE__ */ jsx(ResponsiveContainer, {
143
+ ...getStyles("container"),
144
+ children: /* @__PURE__ */ jsxs(BarChart, {
145
+ data: inputData,
146
+ stackOffset: type === "percent" ? "expand" : void 0,
147
+ layout: orientation,
148
+ maxBarSize: maxBarWidth,
149
+ margin: {
150
+ bottom: xAxisLabel ? 30 : void 0,
151
+ left: yAxisLabel ? 10 : void 0,
152
+ right: yAxisLabel ? 5 : void 0
153
+ },
154
+ ...barChartProps,
155
+ children: [
156
+ withLegend && /* @__PURE__ */ jsx(Legend, {
157
+ verticalAlign: "top",
158
+ content: (payload) => /* @__PURE__ */ jsx(ChartLegend, {
159
+ payload: payload.payload,
160
+ onHighlight: setHighlightedArea,
161
+ legendPosition: legendProps?.verticalAlign || "top",
162
+ classNames: resolvedClassNames,
163
+ styles: resolvedStyles,
164
+ series,
165
+ showColor: type !== "waterfall",
166
+ attributes
167
+ }),
168
+ ...legendProps
169
+ }),
170
+ /* @__PURE__ */ jsxs(XAxis, {
171
+ hide: !withXAxis,
172
+ ...orientation === "vertical" ? { type: "number" } : { dataKey },
173
+ tick: {
174
+ transform: "translate(0, 10)",
175
+ fontSize: 12,
176
+ fill: "currentColor"
177
+ },
178
+ stroke: "",
179
+ interval: "preserveStartEnd",
180
+ tickLine: withXTickLine ? { stroke: "currentColor" } : false,
181
+ minTickGap: 5,
182
+ tickFormatter: orientation === "vertical" ? tickFormatter : void 0,
183
+ ...getStyles("axis"),
184
+ ...xAxisProps,
185
+ children: [xAxisLabel && /* @__PURE__ */ jsx(Label, {
186
+ position: "insideBottom",
187
+ offset: -20,
188
+ fontSize: 12,
189
+ ...getStyles("axisLabel"),
190
+ children: xAxisLabel
191
+ }), xAxisProps?.children]
192
+ }),
193
+ /* @__PURE__ */ jsxs(YAxis, {
194
+ orientation: "left",
195
+ tick: {
196
+ transform: "translate(-10, 0)",
197
+ fontSize: 12,
198
+ fill: "currentColor"
199
+ },
200
+ hide: !withYAxis,
201
+ ...sharedYAxisProps,
202
+ ...yAxisProps,
203
+ children: [yAxisLabel && /* @__PURE__ */ jsx(Label, {
204
+ position: "insideLeft",
205
+ angle: -90,
206
+ textAnchor: "middle",
207
+ fontSize: 12,
208
+ offset: -5,
209
+ ...getStyles("axisLabel"),
210
+ children: yAxisLabel
211
+ }), yAxisProps?.children]
212
+ }),
213
+ /* @__PURE__ */ jsxs(YAxis, {
214
+ yAxisId: "right",
215
+ orientation: "right",
216
+ tick: {
217
+ transform: "translate(10, 0)",
218
+ fontSize: 12,
219
+ fill: "currentColor"
220
+ },
221
+ hide: !withRightYAxis,
222
+ ...sharedYAxisProps,
223
+ ...rightYAxisProps,
224
+ children: [rightYAxisLabel && /* @__PURE__ */ jsx(Label, {
225
+ position: "insideRight",
226
+ angle: 90,
227
+ textAnchor: "middle",
228
+ fontSize: 12,
229
+ offset: -5,
230
+ ...getStyles("axisLabel"),
231
+ children: rightYAxisLabel
232
+ }), yAxisProps?.children]
233
+ }),
234
+ /* @__PURE__ */ jsx(CartesianGrid, {
235
+ strokeDasharray,
236
+ vertical: gridAxis === "y" || gridAxis === "xy",
237
+ horizontal: gridAxis === "x" || gridAxis === "xy",
238
+ ...getStyles("grid"),
239
+ ...gridProps
240
+ }),
241
+ withTooltip && /* @__PURE__ */ jsx(Tooltip$1, {
242
+ animationDuration: tooltipAnimationDuration,
243
+ isAnimationActive: tooltipAnimationDuration !== 0,
244
+ position: orientation === "vertical" ? {} : { y: 0 },
245
+ cursor: {
246
+ stroke: "var(--chart-grid-color)",
247
+ strokeWidth: 1,
248
+ strokeDasharray,
249
+ fill: "var(--chart-cursor-fill)"
250
+ },
251
+ content: ({ label, payload, labelFormatter }) => /* @__PURE__ */ jsx(ChartTooltip, {
252
+ label: labelFormatter && payload ? labelFormatter(label, payload) : label,
253
+ payload,
254
+ type: type === "waterfall" ? "scatter" : void 0,
255
+ unit,
256
+ classNames: resolvedClassNames,
257
+ styles: resolvedStyles,
258
+ series,
259
+ valueFormatter,
260
+ attributes
261
+ }),
262
+ ...tooltipProps
263
+ }),
264
+ bars,
265
+ referenceLinesItems,
266
+ children
267
+ ]
268
+ })
269
+ })
270
+ });
368
271
  });
369
- BarChart.displayName = "@mantine/charts/BarChart";
370
- BarChart.classes = classes;
371
- BarChart.varsResolver = varsResolver;
272
+ BarChart$1.displayName = "@mantine/charts/BarChart";
273
+ BarChart$1.classes = grid_chart_module_default;
274
+ BarChart$1.varsResolver = varsResolver;
275
+ //#endregion
276
+ export { BarChart$1 as BarChart };
372
277
 
373
- export { BarChart };
374
- //# sourceMappingURL=BarChart.mjs.map
278
+ //# sourceMappingURL=BarChart.mjs.map