@mui/x-charts 8.23.0 → 8.24.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 (262) hide show
  1. package/BarChart/BarChart.js +39 -0
  2. package/BarChart/BarChart.plugins.d.ts +2 -1
  3. package/BarChart/BarChart.plugins.js +2 -1
  4. package/BarChart/BarLabel/BarLabel.d.ts +2 -0
  5. package/BarChart/BarLabel/BarLabel.js +8 -3
  6. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
  7. package/BarChart/BarLabel/BarLabelItem.js +4 -2
  8. package/BarChart/BarPlot.d.ts +12 -2
  9. package/BarChart/BarPlot.js +29 -86
  10. package/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
  11. package/BarChart/BatchBarPlot/BarGroup.js +142 -0
  12. package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
  13. package/BarChart/BatchBarPlot/BatchBarPlot.js +140 -0
  14. package/BarChart/BatchBarPlot/index.d.ts +1 -0
  15. package/BarChart/BatchBarPlot/index.js +12 -0
  16. package/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
  17. package/BarChart/BatchBarPlot/useCreateBarPaths.js +53 -0
  18. package/BarChart/FocusedBar.js +5 -1
  19. package/BarChart/IndividualBarPlot.d.ts +21 -0
  20. package/BarChart/IndividualBarPlot.js +106 -0
  21. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
  22. package/BarChart/seriesConfig/bar/legend.js +1 -0
  23. package/BarChart/seriesConfig/index.js +3 -1
  24. package/BarChart/types.d.ts +2 -0
  25. package/BarChart/useBarChartProps.d.ts +6 -2
  26. package/BarChart/useBarChartProps.js +4 -2
  27. package/BarChart/useBarPlotData.d.ts +1 -1
  28. package/BarChart/useBarPlotData.js +23 -4
  29. package/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
  30. package/BarChart/useRegisterItemClickHandlers.js +72 -0
  31. package/CHANGELOG.md +111 -1
  32. package/ChartContainer/ChartContainer.js +34 -0
  33. package/ChartContainer/useChartContainerProps.js +6 -2
  34. package/ChartsLegend/ChartsLegend.js +2 -2
  35. package/ChartsLegend/legendContext.types.d.ts +12 -0
  36. package/ChartsLegend/onClickContextBuilder.js +2 -1
  37. package/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
  38. package/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
  39. package/ChartsReferenceLine/common.d.ts +1 -1
  40. package/ChartsReferenceLine/common.js +4 -1
  41. package/ChartsTooltip/ChartsTooltipContainer.js +25 -21
  42. package/Gauge/GaugeContainer.js +4 -1
  43. package/LineChart/AnimatedLine.js +7 -3
  44. package/LineChart/AppearingMask.js +4 -1
  45. package/LineChart/CircleMarkElement.d.ts +5 -0
  46. package/LineChart/CircleMarkElement.js +13 -5
  47. package/LineChart/FocusedLineMark.js +5 -1
  48. package/LineChart/LineChart.js +30 -0
  49. package/LineChart/LineChart.plugins.d.ts +2 -1
  50. package/LineChart/LineChart.plugins.js +2 -1
  51. package/LineChart/LineElement.d.ts +4 -0
  52. package/LineChart/LineElement.js +7 -3
  53. package/LineChart/MarkElement.d.ts +5 -0
  54. package/LineChart/MarkElement.js +17 -10
  55. package/LineChart/markElementClasses.d.ts +0 -1
  56. package/LineChart/seriesConfig/index.js +3 -1
  57. package/LineChart/seriesConfig/legend.js +1 -0
  58. package/PieChart/FocusedPieArc.js +5 -2
  59. package/PieChart/PieArcLabel.d.ts +2 -0
  60. package/PieChart/PieArcLabel.js +5 -2
  61. package/PieChart/PieChart.js +35 -5
  62. package/PieChart/PieChart.plugins.d.ts +2 -1
  63. package/PieChart/PieChart.plugins.js +2 -1
  64. package/PieChart/seriesConfig/index.js +3 -1
  65. package/PieChart/seriesConfig/legend.js +6 -3
  66. package/RadarChart/RadarChart.js +30 -0
  67. package/RadarChart/RadarChart.plugins.d.ts +3 -2
  68. package/RadarChart/RadarChart.plugins.js +2 -1
  69. package/RadarChart/seriesConfig/index.js +3 -1
  70. package/RadarChart/seriesConfig/legend.js +1 -0
  71. package/ScatterChart/BatchScatter.js +8 -14
  72. package/ScatterChart/ScatterChart.js +30 -0
  73. package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  74. package/ScatterChart/ScatterChart.plugins.js +2 -1
  75. package/ScatterChart/seriesConfig/index.js +3 -1
  76. package/ScatterChart/seriesConfig/legend.js +1 -0
  77. package/SparkLineChart/SparkLineChart.js +46 -0
  78. package/esm/BarChart/BarChart.js +39 -0
  79. package/esm/BarChart/BarChart.plugins.d.ts +2 -1
  80. package/esm/BarChart/BarChart.plugins.js +2 -1
  81. package/esm/BarChart/BarLabel/BarLabel.d.ts +2 -0
  82. package/esm/BarChart/BarLabel/BarLabel.js +8 -3
  83. package/esm/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
  84. package/esm/BarChart/BarLabel/BarLabelItem.js +4 -2
  85. package/esm/BarChart/BarPlot.d.ts +12 -2
  86. package/esm/BarChart/BarPlot.js +29 -86
  87. package/esm/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
  88. package/esm/BarChart/BatchBarPlot/BarGroup.js +134 -0
  89. package/esm/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
  90. package/esm/BarChart/BatchBarPlot/BatchBarPlot.js +133 -0
  91. package/esm/BarChart/BatchBarPlot/index.d.ts +1 -0
  92. package/esm/BarChart/BatchBarPlot/index.js +1 -0
  93. package/esm/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
  94. package/esm/BarChart/BatchBarPlot/useCreateBarPaths.js +46 -0
  95. package/esm/BarChart/FocusedBar.js +5 -1
  96. package/esm/BarChart/IndividualBarPlot.d.ts +21 -0
  97. package/esm/BarChart/IndividualBarPlot.js +98 -0
  98. package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
  99. package/esm/BarChart/seriesConfig/bar/legend.js +1 -0
  100. package/esm/BarChart/seriesConfig/index.js +3 -1
  101. package/esm/BarChart/types.d.ts +2 -0
  102. package/esm/BarChart/useBarChartProps.d.ts +6 -2
  103. package/esm/BarChart/useBarChartProps.js +4 -3
  104. package/esm/BarChart/useBarPlotData.d.ts +1 -1
  105. package/esm/BarChart/useBarPlotData.js +20 -1
  106. package/esm/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
  107. package/esm/BarChart/useRegisterItemClickHandlers.js +67 -0
  108. package/esm/ChartContainer/ChartContainer.js +34 -0
  109. package/esm/ChartContainer/useChartContainerProps.js +6 -2
  110. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  111. package/esm/ChartsLegend/legendContext.types.d.ts +12 -0
  112. package/esm/ChartsLegend/onClickContextBuilder.js +2 -1
  113. package/esm/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
  114. package/esm/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
  115. package/esm/ChartsReferenceLine/common.d.ts +1 -1
  116. package/esm/ChartsReferenceLine/common.js +4 -1
  117. package/esm/ChartsTooltip/ChartsTooltipContainer.js +26 -22
  118. package/esm/Gauge/GaugeContainer.js +4 -1
  119. package/esm/LineChart/AnimatedLine.js +7 -3
  120. package/esm/LineChart/AppearingMask.js +4 -1
  121. package/esm/LineChart/CircleMarkElement.d.ts +5 -0
  122. package/esm/LineChart/CircleMarkElement.js +13 -5
  123. package/esm/LineChart/FocusedLineMark.js +5 -1
  124. package/esm/LineChart/LineChart.js +30 -0
  125. package/esm/LineChart/LineChart.plugins.d.ts +2 -1
  126. package/esm/LineChart/LineChart.plugins.js +2 -1
  127. package/esm/LineChart/LineElement.d.ts +4 -0
  128. package/esm/LineChart/LineElement.js +7 -3
  129. package/esm/LineChart/MarkElement.d.ts +5 -0
  130. package/esm/LineChart/MarkElement.js +17 -10
  131. package/esm/LineChart/markElementClasses.d.ts +0 -1
  132. package/esm/LineChart/seriesConfig/index.js +3 -1
  133. package/esm/LineChart/seriesConfig/legend.js +1 -0
  134. package/esm/PieChart/FocusedPieArc.js +4 -1
  135. package/esm/PieChart/PieArcLabel.d.ts +2 -0
  136. package/esm/PieChart/PieArcLabel.js +5 -2
  137. package/esm/PieChart/PieChart.js +35 -5
  138. package/esm/PieChart/PieChart.plugins.d.ts +2 -1
  139. package/esm/PieChart/PieChart.plugins.js +2 -1
  140. package/esm/PieChart/seriesConfig/index.js +3 -1
  141. package/esm/PieChart/seriesConfig/legend.js +6 -3
  142. package/esm/RadarChart/RadarChart.js +30 -0
  143. package/esm/RadarChart/RadarChart.plugins.d.ts +3 -2
  144. package/esm/RadarChart/RadarChart.plugins.js +2 -1
  145. package/esm/RadarChart/seriesConfig/index.js +3 -1
  146. package/esm/RadarChart/seriesConfig/legend.js +1 -0
  147. package/esm/ScatterChart/BatchScatter.js +5 -11
  148. package/esm/ScatterChart/ScatterChart.js +30 -0
  149. package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  150. package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
  151. package/esm/ScatterChart/seriesConfig/index.js +3 -1
  152. package/esm/ScatterChart/seriesConfig/legend.js +1 -0
  153. package/esm/SparkLineChart/SparkLineChart.js +46 -0
  154. package/esm/index.js +1 -1
  155. package/esm/internals/appendAtKey.d.ts +8 -0
  156. package/esm/internals/appendAtKey.js +17 -0
  157. package/esm/internals/commonNextFocusItem.js +12 -8
  158. package/esm/internals/getBarDimensions.d.ts +1 -2
  159. package/esm/internals/identifierSerializer.d.ts +9 -0
  160. package/esm/internals/identifierSerializer.js +6 -0
  161. package/esm/internals/index.d.ts +6 -2
  162. package/esm/internals/index.js +6 -2
  163. package/esm/internals/invertScale.d.ts +6 -2
  164. package/esm/internals/invertScale.js +9 -1
  165. package/esm/internals/plugins/allPlugins.d.ts +4 -3
  166. package/esm/internals/plugins/allPlugins.js +2 -1
  167. package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
  168. package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +18 -0
  169. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
  170. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
  171. package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
  172. package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +74 -0
  173. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
  174. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
  175. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
  176. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +83 -0
  177. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
  178. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +6 -0
  179. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +7 -34
  180. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
  181. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +9 -0
  182. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +10 -32
  183. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  184. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
  185. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +3 -0
  186. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
  187. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +5 -0
  188. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
  189. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +78 -0
  190. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
  191. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +19 -0
  192. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
  193. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +1 -0
  194. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
  195. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +11 -0
  196. package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
  197. package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.js +1 -0
  198. package/esm/internals/plugins/models/seriesConfig/index.d.ts +2 -1
  199. package/esm/internals/plugins/models/seriesConfig/index.js +2 -1
  200. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
  201. package/esm/models/axis.d.ts +5 -4
  202. package/esm/models/featureFlags.d.ts +1 -0
  203. package/esm/models/featureFlags.js +1 -0
  204. package/esm/models/index.d.ts +1 -0
  205. package/esm/models/index.js +1 -0
  206. package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
  207. package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.js +1 -0
  208. package/index.js +1 -1
  209. package/internals/appendAtKey.d.ts +8 -0
  210. package/internals/appendAtKey.js +23 -0
  211. package/internals/commonNextFocusItem.js +12 -8
  212. package/internals/getBarDimensions.d.ts +1 -2
  213. package/internals/identifierSerializer.d.ts +9 -0
  214. package/internals/identifierSerializer.js +16 -0
  215. package/internals/index.d.ts +6 -2
  216. package/internals/index.js +51 -7
  217. package/internals/invertScale.d.ts +6 -2
  218. package/internals/invertScale.js +10 -1
  219. package/internals/plugins/allPlugins.d.ts +4 -3
  220. package/internals/plugins/allPlugins.js +2 -1
  221. package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
  222. package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +25 -0
  223. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
  224. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
  225. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
  226. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +81 -0
  227. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
  228. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
  229. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
  230. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +89 -0
  231. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
  232. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +12 -0
  233. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +6 -34
  234. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
  235. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +15 -0
  236. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +9 -32
  237. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  238. package/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
  239. package/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +39 -0
  240. package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
  241. package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +12 -0
  242. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
  243. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +85 -0
  244. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
  245. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +25 -0
  246. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
  247. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +5 -0
  248. package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
  249. package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +18 -0
  250. package/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
  251. package/internals/plugins/models/seriesConfig/identifierSerializer.types.js +5 -0
  252. package/internals/plugins/models/seriesConfig/index.d.ts +2 -1
  253. package/internals/plugins/models/seriesConfig/index.js +11 -0
  254. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
  255. package/models/axis.d.ts +5 -4
  256. package/models/featureFlags.d.ts +1 -0
  257. package/models/featureFlags.js +5 -0
  258. package/models/index.d.ts +1 -0
  259. package/models/index.js +11 -0
  260. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
  261. package/moduleAugmentation/barChartBatchRendererOnItemClick.js +5 -0
  262. package/package.json +13 -3
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.BatchBarPlot = BatchBarPlot;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _hooks = require("../../hooks");
10
+ var _barClasses = require("../barClasses");
11
+ var _useChartContext = require("../../context/ChartProvider/useChartContext");
12
+ var _useChartHighlight = require("../../internals/plugins/featurePlugins/useChartHighlight");
13
+ var _useRegisterItemClickHandlers = require("../useRegisterItemClickHandlers");
14
+ var _useCreateBarPaths = require("./useCreateBarPaths");
15
+ var _BarGroup = require("./BarGroup");
16
+ var _useRegisterPointerInteractions = require("../../internals/plugins/featurePlugins/shared/useRegisterPointerInteractions");
17
+ var _useChartCartesianAxisPosition = require("../../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function BatchBarPlot({
20
+ completedData,
21
+ borderRadius = 0,
22
+ onItemClick,
23
+ skipAnimation = false
24
+ }) {
25
+ const prevCursorRef = React.useRef(null);
26
+ const svgRef = (0, _hooks.useSvgRef)();
27
+ const onItemEnter = onItemClick ? () => {
28
+ const svg = svgRef.current;
29
+ if (!svg) {
30
+ return;
31
+ }
32
+ if (prevCursorRef.current == null) {
33
+ prevCursorRef.current = svg.style.cursor;
34
+ // eslint-disable-next-line react-compiler/react-compiler
35
+ svg.style.cursor = 'pointer';
36
+ }
37
+ } : undefined;
38
+ const onItemLeave = onItemClick ? () => {
39
+ const svg = svgRef.current;
40
+ if (!svg) {
41
+ return;
42
+ }
43
+ if (prevCursorRef.current != null) {
44
+ svg.style.cursor = prevCursorRef.current;
45
+ prevCursorRef.current = null;
46
+ }
47
+ } : undefined;
48
+ (0, _useRegisterPointerInteractions.useRegisterPointerInteractions)(_useChartCartesianAxisPosition.selectorBarItemAtPosition, onItemEnter, onItemLeave);
49
+ (0, _useRegisterItemClickHandlers.useRegisterItemClickHandlers)(onItemClick);
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
51
+ children: completedData.map(series => /*#__PURE__*/(0, _jsxRuntime.jsx)(SeriesBatchPlot, {
52
+ series: series,
53
+ borderRadius: borderRadius,
54
+ skipAnimation: skipAnimation
55
+ }, series.seriesId))
56
+ });
57
+ }
58
+ const MemoFadedHighlightedBars = /*#__PURE__*/React.memo(FadedHighlightedBars);
59
+ if (process.env.NODE_ENV !== "production") MemoFadedHighlightedBars.displayName = "MemoFadedHighlightedBars";
60
+ function SeriesBatchPlot({
61
+ series,
62
+ borderRadius,
63
+ skipAnimation
64
+ }) {
65
+ const classes = (0, _barClasses.useUtilityClasses)();
66
+ const {
67
+ store
68
+ } = (0, _useChartContext.useChartContext)();
69
+ const isSeriesHighlighted = store.use(_useChartHighlight.selectorChartIsSeriesHighlighted, series.seriesId);
70
+ const isSeriesFaded = store.use(_useChartHighlight.selectorChartIsSeriesFaded, series.seriesId);
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
72
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarGroup.BarGroup, {
73
+ className: classes.series,
74
+ "data-series": series.seriesId,
75
+ layout: series.layout,
76
+ xOrigin: series.xOrigin,
77
+ yOrigin: series.yOrigin,
78
+ skipAnimation: skipAnimation,
79
+ "data-faded": isSeriesFaded || undefined,
80
+ "data-highlighted": isSeriesHighlighted || undefined,
81
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(BatchBarSeriesPlot, {
82
+ processedSeries: series,
83
+ borderRadius: borderRadius
84
+ })
85
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(MemoFadedHighlightedBars, {
86
+ processedSeries: series,
87
+ borderRadius: borderRadius
88
+ })]
89
+ });
90
+ }
91
+ function BatchBarSeriesPlot({
92
+ processedSeries,
93
+ borderRadius
94
+ }) {
95
+ const paths = (0, _useCreateBarPaths.useCreateBarPaths)(processedSeries, borderRadius);
96
+ const children = [];
97
+ let i = 0;
98
+ for (const [fill, dArray] of paths.entries()) {
99
+ for (const d of dArray) {
100
+ children.push(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
101
+ fill: fill,
102
+ d: d
103
+ }, i));
104
+ i += 1;
105
+ }
106
+ }
107
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
108
+ children: children
109
+ });
110
+ }
111
+ function FadedHighlightedBars({
112
+ processedSeries,
113
+ borderRadius
114
+ }) {
115
+ const {
116
+ store
117
+ } = (0, _useChartContext.useChartContext)();
118
+ const seriesHighlightedDataIndex = store.use(_useChartHighlight.selectorChartSeriesHighlightedItem, processedSeries.seriesId);
119
+ const seriesUnfadedDataIndex = store.use(_useChartHighlight.selectorChartSeriesUnfadedItem, processedSeries.seriesId);
120
+ const seriesHighlightedItem = seriesHighlightedDataIndex != null ? processedSeries.data.find(v => v.dataIndex === seriesHighlightedDataIndex) || null : null;
121
+ const seriesUnfadedItem = seriesUnfadedDataIndex != null ? processedSeries.data.find(v => v.dataIndex === seriesUnfadedDataIndex) || null : null;
122
+ const siblings = [];
123
+ if (seriesHighlightedItem != null) {
124
+ siblings.push(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
125
+ fill: seriesHighlightedItem.color,
126
+ filter: "brightness(120%)",
127
+ "data-highlighted": true,
128
+ d: (0, _useCreateBarPaths.createPath)(seriesHighlightedItem, borderRadius)
129
+ }, `highlighted-${processedSeries.seriesId}`));
130
+ }
131
+ if (seriesUnfadedItem != null) {
132
+ siblings.push(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
133
+ fill: seriesUnfadedItem.color,
134
+ d: (0, _useCreateBarPaths.createPath)(seriesUnfadedItem, borderRadius)
135
+ }, `unfaded-${seriesUnfadedItem.seriesId}`));
136
+ }
137
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
138
+ children: siblings
139
+ });
140
+ }
@@ -0,0 +1 @@
1
+ export { BatchBarPlot } from "./BatchBarPlot.js";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BatchBarPlot", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _BatchBarPlot.BatchBarPlot;
10
+ }
11
+ });
12
+ var _BatchBarPlot = require("./BatchBarPlot");
@@ -0,0 +1,8 @@
1
+ import type { ProcessedBarData, ProcessedBarSeriesData } from "../types.js";
2
+ export declare function createPath(barData: ProcessedBarData, borderRadius: number): string;
3
+ /**
4
+ * Hook that creates bar paths for a given series data. Used by the batch bar renderer.
5
+ * @param seriesData
6
+ * @param borderRadius
7
+ */
8
+ export declare function useCreateBarPaths(seriesData: ProcessedBarSeriesData, borderRadius: number): Map<string, string[]>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPath = createPath;
7
+ exports.useCreateBarPaths = useCreateBarPaths;
8
+ var _appendAtKey = require("../../internals/appendAtKey");
9
+ const MAX_POINTS_PER_PATH = 1000;
10
+ function generateBarPath(x, y, width, height, topLeftBorderRadius, topRightBorderRadius, bottomRightBorderRadius, bottomLeftBorderRadius) {
11
+ const tLBR = Math.min(topLeftBorderRadius, width / 2, height / 2);
12
+ const tRBR = Math.min(topRightBorderRadius, width / 2, height / 2);
13
+ const bRBR = Math.min(bottomRightBorderRadius, width / 2, height / 2);
14
+ const bLBR = Math.min(bottomLeftBorderRadius, width / 2, height / 2);
15
+ return `M${x + tLBR},${y}
16
+ h${width - tLBR - tRBR}
17
+ a${tRBR},${tRBR} 0 0 1 ${tRBR},${tRBR}
18
+ v${height - tRBR - bRBR}
19
+ a${bRBR},${bRBR} 0 0 1 -${bRBR},${bRBR}
20
+ h-${width - bRBR - bLBR}
21
+ a${bLBR},${bLBR} 0 0 1 -${bLBR},-${bLBR}
22
+ v-${height - bLBR - tLBR}
23
+ a${tLBR},${tLBR} 0 0 1 ${tLBR},-${tLBR}
24
+ Z`;
25
+ }
26
+ function createPath(barData, borderRadius) {
27
+ return generateBarPath(barData.x, barData.y, barData.width, barData.height, barData.borderRadiusSide === 'left' || barData.borderRadiusSide === 'top' ? borderRadius : 0, barData.borderRadiusSide === 'right' || barData.borderRadiusSide === 'top' ? borderRadius : 0, barData.borderRadiusSide === 'right' || barData.borderRadiusSide === 'bottom' ? borderRadius : 0, barData.borderRadiusSide === 'left' || barData.borderRadiusSide === 'bottom' ? borderRadius : 0);
28
+ }
29
+
30
+ /**
31
+ * Hook that creates bar paths for a given series data. Used by the batch bar renderer.
32
+ * @param seriesData
33
+ * @param borderRadius
34
+ */
35
+ function useCreateBarPaths(seriesData, borderRadius) {
36
+ const paths = new Map();
37
+ const temporaryPaths = new Map();
38
+ for (let j = 0; j < seriesData.data.length; j += 1) {
39
+ const barData = seriesData.data[j];
40
+ const pathString = createPath(barData, borderRadius);
41
+ const tempPath = (0, _appendAtKey.appendAtKey)(temporaryPaths, barData.color, pathString);
42
+ if (tempPath.length >= MAX_POINTS_PER_PATH) {
43
+ (0, _appendAtKey.appendAtKey)(paths, barData.color, tempPath.join(''));
44
+ temporaryPaths.delete(barData.color);
45
+ }
46
+ }
47
+ for (const [fill, tempPath] of temporaryPaths.entries()) {
48
+ if (tempPath.length > 0) {
49
+ (0, _appendAtKey.appendAtKey)(paths, fill, tempPath.join(''));
50
+ }
51
+ }
52
+ return paths;
53
+ }
@@ -29,7 +29,11 @@ function FocusedBar(props) {
29
29
  if (focusedItem === null || focusedItem.type !== 'bar' || !barSeries) {
30
30
  return null;
31
31
  }
32
- const series = barSeries?.series[focusedItem.seriesId];
32
+ const series = barSeries.series[focusedItem.seriesId];
33
+ if (series.data[focusedItem.dataIndex] == null) {
34
+ // Handle missing data
35
+ return null;
36
+ }
33
37
  const xAxisId = series.xAxisId ?? xAxisIds[0];
34
38
  const yAxisId = series.yAxisId ?? yAxisIds[0];
35
39
  const xAxisConfig = xAxis[xAxisId];
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import { type BarPlotSlotProps, type BarPlotSlots } from "./BarPlot.js";
3
+ import { type BarItemIdentifier } from "../models/index.js";
4
+ import { type MaskData, type ProcessedBarSeriesData } from "./types.js";
5
+ export interface IndividualBarPlotProps {
6
+ completedData: ProcessedBarSeriesData[];
7
+ masksData: MaskData[];
8
+ borderRadius?: number;
9
+ skipAnimation?: boolean;
10
+ onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, barItemIdentifier: BarItemIdentifier) => void;
11
+ slotProps?: BarPlotSlotProps;
12
+ slots?: BarPlotSlots;
13
+ }
14
+ export declare function IndividualBarPlot({
15
+ completedData,
16
+ masksData,
17
+ borderRadius,
18
+ onItemClick,
19
+ skipAnimation,
20
+ ...other
21
+ }: IndividualBarPlotProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.IndividualBarPlot = IndividualBarPlot;
9
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
11
+ var React = _interopRequireWildcard(require("react"));
12
+ var _BarElement = require("./BarElement");
13
+ var _barClasses = require("./barClasses");
14
+ var _BarClipPath = require("./BarClipPath");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ const _excluded = ["completedData", "masksData", "borderRadius", "onItemClick", "skipAnimation"];
17
+ function IndividualBarPlot(_ref) {
18
+ let {
19
+ completedData,
20
+ masksData,
21
+ borderRadius,
22
+ onItemClick,
23
+ skipAnimation
24
+ } = _ref,
25
+ other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
26
+ const classes = (0, _barClasses.useUtilityClasses)();
27
+ const withoutBorderRadius = !borderRadius || borderRadius <= 0;
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
29
+ children: [!withoutBorderRadius && masksData.map(({
30
+ id,
31
+ x,
32
+ y,
33
+ xOrigin,
34
+ yOrigin,
35
+ width,
36
+ height,
37
+ hasPositive,
38
+ hasNegative,
39
+ layout
40
+ }) => {
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarClipPath.BarClipPath, {
42
+ maskId: id,
43
+ borderRadius: borderRadius,
44
+ hasNegative: hasNegative,
45
+ hasPositive: hasPositive,
46
+ layout: layout,
47
+ x: x,
48
+ y: y,
49
+ xOrigin: xOrigin,
50
+ yOrigin: yOrigin,
51
+ width: width,
52
+ height: height,
53
+ skipAnimation: skipAnimation ?? false
54
+ }, id);
55
+ }), completedData.map(({
56
+ seriesId,
57
+ layout,
58
+ xOrigin,
59
+ yOrigin,
60
+ data
61
+ }) => {
62
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
63
+ "data-series": seriesId,
64
+ className: classes.series,
65
+ children: data.map(({
66
+ dataIndex,
67
+ color,
68
+ maskId,
69
+ x,
70
+ y,
71
+ width,
72
+ height
73
+ }) => {
74
+ const barElement = /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarElement.BarElement, (0, _extends2.default)({
75
+ id: seriesId,
76
+ dataIndex: dataIndex,
77
+ color: color,
78
+ skipAnimation: skipAnimation ?? false,
79
+ layout: layout ?? 'vertical',
80
+ x: x,
81
+ xOrigin: xOrigin,
82
+ y: y,
83
+ yOrigin: yOrigin,
84
+ width: width,
85
+ height: height
86
+ }, other, {
87
+ onClick: onItemClick && (event => {
88
+ onItemClick(event, {
89
+ type: 'bar',
90
+ seriesId,
91
+ dataIndex
92
+ });
93
+ })
94
+ }), dataIndex);
95
+ if (withoutBorderRadius) {
96
+ return barElement;
97
+ }
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
99
+ clipPath: `url(#${maskId})`,
100
+ children: barElement
101
+ }, dataIndex);
102
+ })
103
+ }, seriesId);
104
+ })]
105
+ });
106
+ }
@@ -9,7 +9,7 @@ export declare function getSeriesWithDefaultValues(seriesData: AllSeriesType<'ba
9
9
  layout?: "horizontal" | "vertical";
10
10
  stackOffset?: import("../../../index.js").StackOffsetType;
11
11
  minBarSize?: number;
12
- barLabel?: "value" | ((item: import("../../index.js").BarItem, context: import("../../index.js").BarLabelContext) => string | null | undefined);
12
+ barLabel?: "value" | ((item: import("@mui/x-charts/BarChart").BarItem, context: import("@mui/x-charts/BarChart").BarLabelContext) => string | null | undefined);
13
13
  barLabelPlacement?: "center" | "outside";
14
14
  valueFormatter?: import("../../../internals/index.js").SeriesValueFormatter<number | null> | undefined;
15
15
  highlightScope?: import("../../../index.js").HighlightScope;
@@ -16,6 +16,7 @@ const legendGetter = params => {
16
16
  return acc;
17
17
  }
18
18
  acc.push({
19
+ type: 'bar',
19
20
  markType: series[seriesId].labelMarkType,
20
21
  id: seriesId,
21
22
  seriesId,
@@ -14,6 +14,7 @@ var _keyboardFocusHandler = _interopRequireDefault(require("./bar/keyboardFocusH
14
14
  var _tooltip = _interopRequireWildcard(require("./bar/tooltip"));
15
15
  var _tooltipPosition = _interopRequireDefault(require("./bar/tooltipPosition"));
16
16
  var _getSeriesWithDefaultValues = require("./bar/getSeriesWithDefaultValues");
17
+ var _identifierSerializer = require("../../internals/identifierSerializer");
17
18
  const barSeriesConfig = exports.barSeriesConfig = {
18
19
  seriesProcessor: _seriesProcessor.default,
19
20
  colorProcessor: _getColor.default,
@@ -24,5 +25,6 @@ const barSeriesConfig = exports.barSeriesConfig = {
24
25
  xExtremumGetter: _extremums.getExtremumX,
25
26
  yExtremumGetter: _extremums.getExtremumY,
26
27
  getSeriesWithDefaultValues: _getSeriesWithDefaultValues.getSeriesWithDefaultValues,
27
- keyboardFocusHandler: _keyboardFocusHandler.default
28
+ keyboardFocusHandler: _keyboardFocusHandler.default,
29
+ identifierSerializer: _identifierSerializer.identifierSerializerSeriesIdDataIndex
28
30
  };
@@ -15,12 +15,14 @@ export interface ProcessedBarSeriesData {
15
15
  xOrigin: number;
16
16
  yOrigin: number;
17
17
  }
18
+ export type BorderRadiusSide = 'top' | 'bottom' | 'left' | 'right';
18
19
  export interface ProcessedBarData extends AnimationData {
19
20
  seriesId: SeriesId;
20
21
  dataIndex: number;
21
22
  color: string;
22
23
  value: number | null;
23
24
  maskId: string;
25
+ borderRadiusSide?: BorderRadiusSide;
24
26
  }
25
27
  export interface MaskData extends AnimationData {
26
28
  id: string;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import type { BarChartProps } from "./BarChart.js";
2
+ import { type BarChartProps, type BarSeries } from "./BarChart.js";
3
3
  import { type ChartContainerProps } from "../ChartContainer/index.js";
4
4
  import { type BarPlotProps } from "./BarPlot.js";
5
5
  import { type ChartsGridProps } from "../ChartsGrid/index.js";
@@ -10,6 +10,10 @@ import { type ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
10
10
  import { type ChartsLegendSlotExtension } from "../ChartsLegend/index.js";
11
11
  import type { ChartsWrapperProps } from "../ChartsWrapper/index.js";
12
12
  import { type BarChartPluginSignatures } from "./BarChart.plugins.js";
13
+ export interface UseBarChartPropsExtensions {}
14
+ export type UseBarChartProps = Omit<BarChartProps, 'series'> & Omit<{
15
+ series: ReadonlyArray<BarSeries>;
16
+ }, keyof UseBarChartPropsExtensions> & UseBarChartPropsExtensions;
13
17
  /**
14
18
  * A helper function that extracts BarChartProps from the input props
15
19
  * and returns an object with props for the children components of BarChart.
@@ -17,7 +21,7 @@ import { type BarChartPluginSignatures } from "./BarChart.plugins.js";
17
21
  * @param props The input props for BarChart
18
22
  * @returns An object with props for the children components of BarChart
19
23
  */
20
- export declare const useBarChartProps: (props: BarChartProps) => {
24
+ export declare const useBarChartProps: (props: UseBarChartProps) => {
21
25
  chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
22
26
  chartContainerProps: ChartContainerProps<"bar", BarChartPluginSignatures>;
23
27
  barPlotProps: BarPlotProps;
@@ -13,7 +13,7 @@ var React = _interopRequireWildcard(require("react"));
13
13
  var _useId = _interopRequireDefault(require("@mui/utils/useId"));
14
14
  var _constants = require("../constants");
15
15
  var _BarChart = require("./BarChart.plugins");
16
- const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar", "brushConfig"];
16
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar", "brushConfig", "renderer"];
17
17
  /**
18
18
  * A helper function that extracts BarChartProps from the input props
19
19
  * and returns an object with props for the children components of BarChart.
@@ -46,7 +46,8 @@ const useBarChartProps = props => {
46
46
  borderRadius,
47
47
  barLabel,
48
48
  className,
49
- brushConfig
49
+ brushConfig,
50
+ renderer
50
51
  } = props,
51
52
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
52
53
  const id = (0, _useId.default)();
@@ -111,6 +112,7 @@ const useBarChartProps = props => {
111
112
  slots,
112
113
  slotProps,
113
114
  borderRadius,
115
+ renderer,
114
116
  barLabel
115
117
  };
116
118
  const gridProps = {
@@ -1,7 +1,7 @@
1
1
  import { type ChartsXAxisProps, type ChartsYAxisProps } from "../models/axis.js";
2
- import { type ChartDrawingArea } from "../hooks/index.js";
3
2
  import { type MaskData, type ProcessedBarSeriesData } from "./types.js";
4
3
  import { type ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js";
4
+ import { type ChartDrawingArea } from "../hooks/useDrawingArea.js";
5
5
  export declare function useBarPlotData(drawingArea: ChartDrawingArea, xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): {
6
6
  completedData: ProcessedBarSeriesData[];
7
7
  masksData: MaskData[];
@@ -7,19 +7,20 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.useBarPlotData = useBarPlotData;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
  var _getColor = _interopRequireDefault(require("./seriesConfig/bar/getColor"));
10
- var _hooks = require("../hooks");
10
+ var _useAxis = require("../hooks/useAxis");
11
11
  var _checkBarChartScaleErrors = require("./checkBarChartScaleErrors");
12
12
  var _useBarSeries = require("../hooks/useBarSeries");
13
13
  var _getBarDimensions = require("../internals/getBarDimensions");
14
+ var _useChartId = require("../hooks/useChartId");
14
15
  function useBarPlotData(drawingArea, xAxes, yAxes) {
15
16
  const seriesData = (0, _useBarSeries.useBarSeriesContext)() ?? {
16
17
  series: {},
17
18
  stackingGroups: [],
18
19
  seriesOrder: []
19
20
  };
20
- const defaultXAxisId = (0, _hooks.useXAxes)().xAxisIds[0];
21
- const defaultYAxisId = (0, _hooks.useYAxes)().yAxisIds[0];
22
- const chartId = (0, _hooks.useChartId)();
21
+ const defaultXAxisId = (0, _useAxis.useXAxes)().xAxisIds[0];
22
+ const defaultYAxisId = (0, _useAxis.useYAxes)().yAxisIds[0];
23
+ const chartId = (0, _useChartId.useChartId)();
23
24
  const {
24
25
  series,
25
26
  stackingGroups
@@ -32,6 +33,8 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
32
33
  const xMax = drawingArea.left + drawingArea.width;
33
34
  const yMin = drawingArea.top;
34
35
  const yMax = drawingArea.top + drawingArea.height;
36
+ const lastNegativePerIndex = new Map();
37
+ const lastPositivePerIndex = new Map();
35
38
  return seriesIds.map(seriesId => {
36
39
  const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
37
40
  const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
@@ -73,6 +76,22 @@ function useBarPlotData(drawingArea, xAxes, yAxes) {
73
76
  if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
74
77
  continue;
75
78
  }
79
+ const lastNegative = lastNegativePerIndex.get(dataIndex);
80
+ const lastPositive = lastPositivePerIndex.get(dataIndex);
81
+ const sign = (reverse ? -1 : 1) * Math.sign(result.value ?? 0);
82
+ if (sign > 0) {
83
+ if (lastPositive) {
84
+ delete lastPositive.borderRadiusSide;
85
+ }
86
+ result.borderRadiusSide = verticalLayout ? 'top' : 'right';
87
+ lastPositivePerIndex.set(dataIndex, result);
88
+ } else if (sign < 0) {
89
+ if (lastNegative) {
90
+ delete lastNegative.borderRadiusSide;
91
+ }
92
+ result.borderRadiusSide = verticalLayout ? 'bottom' : 'left';
93
+ lastNegativePerIndex.set(dataIndex, result);
94
+ }
76
95
  if (!masks[result.maskId]) {
77
96
  masks[result.maskId] = {
78
97
  id: result.maskId,
@@ -0,0 +1,6 @@
1
+ import { type BarItemIdentifier } from "../models/seriesType/index.js";
2
+ /**
3
+ * Hook that registers pointer event handlers for chart item clicking.
4
+ * @param onItemClick Callback for item click events.
5
+ */
6
+ export declare function useRegisterItemClickHandlers(onItemClick: ((event: MouseEvent, barItemIdentifier: BarItemIdentifier) => void) | undefined): void;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useRegisterItemClickHandlers = useRegisterItemClickHandlers;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _useSvgRef = require("../hooks/useSvgRef");
11
+ var _ChartProvider = require("../context/ChartProvider");
12
+ var _getSVGPoint = require("../internals/getSVGPoint");
13
+ var _useStore = require("../internals/store/useStore");
14
+ var _useChartCartesianAxisPosition = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors");
15
+ /**
16
+ * Hook that registers pointer event handlers for chart item clicking.
17
+ * @param onItemClick Callback for item click events.
18
+ */
19
+ function useRegisterItemClickHandlers(onItemClick) {
20
+ const {
21
+ instance
22
+ } = (0, _ChartProvider.useChartContext)();
23
+ const svgRef = (0, _useSvgRef.useSvgRef)();
24
+ const store = (0, _useStore.useStore)();
25
+ React.useEffect(() => {
26
+ const element = svgRef.current;
27
+ if (!element || !onItemClick) {
28
+ return undefined;
29
+ }
30
+ let lastPointerUp = null;
31
+ const onClick = function onClick(event) {
32
+ let point = event;
33
+
34
+ /* The click event doesn't contain decimal values in clientX/Y, but the pointermove does.
35
+ * This caused a problem when rendering many bars that were thinner than a pixel where the tooltip or the highlight
36
+ * would refer to a different bar than the click since those rely on the pointermove event.
37
+ * As a fix, we use the pointerup event to get the decimal values and check if the pointer up event was close enough
38
+ * to the click event (1px difference in each direction); if so, then we can use the pointerup's clientX/Y; if not,
39
+ * we default to the click event's clientX/Y. */
40
+ if (lastPointerUp) {
41
+ if (Math.abs(event.clientX - lastPointerUp.clientX) <= 1 && Math.abs(event.clientY - lastPointerUp.clientY) <= 1) {
42
+ point = {
43
+ clientX: lastPointerUp.clientX,
44
+ clientY: lastPointerUp.clientY
45
+ };
46
+ }
47
+ }
48
+ lastPointerUp = null;
49
+ const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, point);
50
+ if (!instance.isPointInside(svgPoint.x, svgPoint.y)) {
51
+ return;
52
+ }
53
+ const item = (0, _useChartCartesianAxisPosition.selectorBarItemAtPosition)(store.state, svgPoint);
54
+ if (item) {
55
+ onItemClick(event, {
56
+ type: 'bar',
57
+ seriesId: item.seriesId,
58
+ dataIndex: item.dataIndex
59
+ });
60
+ }
61
+ };
62
+ const onPointerUp = function onPointerUp(event) {
63
+ lastPointerUp = event;
64
+ };
65
+ element.addEventListener('click', onClick);
66
+ element.addEventListener('pointerup', onPointerUp);
67
+ return () => {
68
+ element.removeEventListener('click', onClick);
69
+ element.removeEventListener('pointerup', onPointerUp);
70
+ };
71
+ }, [instance, onItemClick, store, svgRef]);
72
+ }