@octanejs/recharts 0.1.40 → 0.1.42

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 (376) hide show
  1. package/{LICENSE → LICENSE.recharts} +3 -2
  2. package/README.md +12 -0
  3. package/package.json +10 -9
  4. package/src/animation/AnimatedItems.tsrx +36 -3
  5. package/src/animation/AnimationController.ts +17 -65
  6. package/src/animation/{AnimationControllerImpl.js → AnimationControllerImpl.ts} +19 -12
  7. package/src/animation/{AnimationHandle.js → AnimationHandle.ts} +82 -65
  8. package/src/animation/CSSTransitionAnimate.tsrx +3 -2
  9. package/src/animation/JavascriptAnimate.tsrx +18 -2
  10. package/src/animation/easing.ts +235 -0
  11. package/src/animation/{matchBy.js → matchBy.ts} +76 -120
  12. package/src/animation/timeoutController.ts +71 -0
  13. package/src/animation/useAnimationController.ts +4 -1
  14. package/src/animation/useAnimationStartSnapshot.ts +3 -3
  15. package/src/animation/util.ts +12 -0
  16. package/src/cartesian/Area.tsrx +33 -31
  17. package/src/cartesian/AreaRevealShape.tsrx +4 -3
  18. package/src/cartesian/Bar.ts +1 -0
  19. package/src/cartesian/Bar.tsrx +293 -39
  20. package/src/cartesian/BarStack.tsrx +31 -9
  21. package/src/cartesian/CartesianAxis.tsrx +154 -22
  22. package/src/cartesian/CartesianGrid.tsrx +5 -6
  23. package/src/cartesian/ErrorBar.tsrx +9 -8
  24. package/src/cartesian/Funnel.tsrx +40 -37
  25. package/src/cartesian/GraphicalItemClipPath.tsrx +11 -4
  26. package/src/cartesian/Line.ts +1 -0
  27. package/src/cartesian/Line.tsrx +206 -28
  28. package/src/cartesian/LineDrawShape.tsrx +23 -10
  29. package/src/cartesian/ReferenceLine.tsrx +8 -8
  30. package/src/cartesian/Scatter.tsrx +61 -66
  31. package/src/cartesian/XAxis.tsrx +78 -9
  32. package/src/cartesian/YAxis.tsrx +85 -12
  33. package/src/cartesian/getCartesianPosition.ts +265 -0
  34. package/src/cartesian/getEquidistantTicks.ts +144 -0
  35. package/src/cartesian/getTicks.ts +221 -0
  36. package/src/chart/AreaChart.tsrx +5 -1
  37. package/src/chart/BarChart.tsrx +8 -2
  38. package/src/chart/CartesianChart.tsrx +17 -4
  39. package/src/chart/CategoricalChart.tsrx +4 -1
  40. package/src/chart/ComposedChart.tsrx +5 -1
  41. package/src/chart/FunnelChart.tsrx +5 -1
  42. package/src/chart/LineChart.tsrx +8 -2
  43. package/src/chart/PieChart.tsrx +6 -2
  44. package/src/chart/PolarChart.tsrx +5 -4
  45. package/src/chart/RadarChart.tsrx +6 -2
  46. package/src/chart/RadialBarChart.tsrx +6 -2
  47. package/src/chart/RechartsWrapper.tsrx +57 -21
  48. package/src/chart/Sankey.tsrx +89 -91
  49. package/src/chart/ScatterChart.tsrx +5 -1
  50. package/src/chart/SunburstChart.tsrx +21 -14
  51. package/src/chart/types.ts +0 -1
  52. package/src/component/ActivePoints.tsrx +30 -5
  53. package/src/component/Cell.ts +19 -1
  54. package/src/component/Cursor.tsrx +11 -10
  55. package/src/component/DefaultLegendContent.tsrx +15 -10
  56. package/src/component/DefaultTooltipContent.tsrx +11 -9
  57. package/src/component/Dots.tsrx +37 -6
  58. package/src/component/Label.tsrx +99 -19
  59. package/src/component/LabelList.tsrx +54 -5
  60. package/src/component/Legend.tsrx +9 -5
  61. package/src/component/ResponsiveContainer.tsrx +13 -10
  62. package/src/component/Text.tsrx +95 -32
  63. package/src/component/Tooltip.tsrx +11 -10
  64. package/src/component/TooltipBoundingBox.tsrx +4 -5
  65. package/src/component/{responsiveContainerUtils.js → responsiveContainerUtils.ts} +59 -36
  66. package/src/container/ClipPathProvider.tsrx +6 -2
  67. package/src/container/Layer.tsrx +8 -1
  68. package/src/container/RootSurface.tsrx +15 -4
  69. package/src/container/Surface.tsrx +15 -1
  70. package/src/context/CellsContext.ts +6 -5
  71. package/src/context/ErrorBarContext.tsrx +23 -4
  72. package/src/context/RegisterGraphicalItemId.tsrx +10 -2
  73. package/src/context/accessibilityContext.ts +5 -0
  74. package/src/context/brushUpdateContext.ts +11 -0
  75. package/src/context/chartDataContext.ts +5 -4
  76. package/src/context/chartLayoutContext.ts +22 -8
  77. package/src/context/legendPayloadContext.tsrx +1 -1
  78. package/src/context/tooltipContext.ts +83 -0
  79. package/src/{hooks.js → hooks.ts} +88 -66
  80. package/src/index.ts +37 -37
  81. package/src/internal.ts +4 -20
  82. package/src/legacy-props.ts +129 -0
  83. package/src/polar/Pie.tsrx +91 -69
  84. package/src/polar/PolarAngleAxis.tsrx +47 -47
  85. package/src/polar/PolarGrid.tsrx +7 -6
  86. package/src/polar/PolarRadiusAxis.tsrx +29 -21
  87. package/src/polar/Radar.tsrx +26 -19
  88. package/src/polar/RadialBar.tsrx +59 -42
  89. package/src/polar/{defaultPolarAngleAxisProps.js → defaultPolarAngleAxisProps.ts} +6 -6
  90. package/src/polar/{defaultPolarRadiusAxisProps.js → defaultPolarRadiusAxisProps.ts} +5 -4
  91. package/src/shape/Cross.tsrx +14 -2
  92. package/src/shape/Curve.tsrx +111 -23
  93. package/src/shape/Dot.tsrx +12 -1
  94. package/src/shape/Polygon.tsrx +28 -6
  95. package/src/shape/Rectangle.tsrx +30 -3
  96. package/src/shape/Sector.tsrx +48 -6
  97. package/src/shape/Symbols.tsrx +24 -6
  98. package/src/shape/Trapezoid.tsrx +33 -3
  99. package/src/state/RechartsStoreProvider.tsrx +11 -2
  100. package/src/state/ReportChartProps.ts +2 -2
  101. package/src/state/ReportMainChartProps.ts +2 -1
  102. package/src/state/SetGraphicalItem.ts +6 -4
  103. package/src/state/SetLegendPayload.ts +7 -4
  104. package/src/state/SetTooltipEntrySettings.ts +5 -2
  105. package/src/state/brushSlice.ts +40 -0
  106. package/src/state/cartesianAxisSlice.ts +291 -0
  107. package/src/state/chartDataSlice.ts +87 -0
  108. package/src/state/errorBarSlice.ts +78 -0
  109. package/src/state/eventSettingsSlice.ts +30 -0
  110. package/src/state/{externalEventsMiddleware.js → externalEventsMiddleware.ts} +55 -34
  111. package/src/state/graphicalItemsSlice.ts +180 -0
  112. package/src/state/{keyboardEventsMiddleware.js → keyboardEventsMiddleware.ts} +72 -57
  113. package/src/state/layoutSlice.ts +50 -0
  114. package/src/state/legendSlice.ts +109 -0
  115. package/src/state/{mouseEventsMiddleware.js → mouseEventsMiddleware.ts} +45 -35
  116. package/src/state/optionsSlice.ts +65 -0
  117. package/src/state/polarAxisSlice.ts +42 -0
  118. package/src/state/polarOptionsSlice.ts +43 -0
  119. package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +13 -0
  120. package/src/state/referenceElementsSlice.ts +100 -0
  121. package/src/state/renderedTicksSlice.ts +60 -0
  122. package/src/state/rootPropsSlice.ts +72 -0
  123. package/src/state/selectors/areaSelectors.ts +1 -2
  124. package/src/state/selectors/{arrayEqualityCheck.js → arrayEqualityCheck.ts} +4 -5
  125. package/src/state/selectors/axisSelectors.ts +2502 -0
  126. package/src/state/selectors/barSelectors.ts +373 -0
  127. package/src/state/selectors/barStackSelectors.ts +99 -0
  128. package/src/state/selectors/brushSelectors.ts +28 -0
  129. package/src/state/selectors/combiners/combineActiveLabel.ts +16 -0
  130. package/src/state/selectors/combiners/{combineActiveTooltipIndex.js → combineActiveTooltipIndex.ts} +45 -23
  131. package/src/state/selectors/combiners/combineAllBarPositions.ts +130 -0
  132. package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +16 -0
  133. package/src/state/selectors/combiners/combineBarPosition.ts +23 -0
  134. package/src/state/selectors/combiners/combineBarSizeList.ts +79 -0
  135. package/src/state/selectors/combiners/{combineCheckedDomain.js → combineCheckedDomain.ts} +9 -6
  136. package/src/state/selectors/combiners/combineConfiguredScale.ts +100 -0
  137. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +46 -0
  138. package/src/state/selectors/combiners/{combineDisplayedStackedData.js → combineDisplayedStackedData.ts} +23 -19
  139. package/src/state/selectors/combiners/combineInverseScaleFunction.ts +16 -0
  140. package/src/state/selectors/combiners/{combineRealScaleType.js → combineRealScaleType.ts} +16 -8
  141. package/src/state/selectors/combiners/combineStackedData.ts +27 -0
  142. package/src/state/selectors/combiners/combineTooltipInteractionState.ts +86 -0
  143. package/src/state/selectors/combiners/combineTooltipPayload.ts +201 -0
  144. package/src/state/selectors/combiners/{combineTooltipPayloadConfigurations.js → combineTooltipPayloadConfigurations.ts} +17 -18
  145. package/src/state/selectors/containerSelectors.ts +12 -0
  146. package/src/state/selectors/{dataSelectors.js → dataSelectors.ts} +43 -41
  147. package/src/state/selectors/funnelSelectors.ts +5 -5
  148. package/src/state/selectors/graphicalItemSelectors.ts +22 -0
  149. package/src/state/selectors/legendSelectors.ts +25 -0
  150. package/src/state/selectors/lineSelectors.ts +159 -0
  151. package/src/state/selectors/numberDomainEqualityCheck.ts +15 -0
  152. package/src/state/selectors/pickAxisId.ts +6 -0
  153. package/src/state/selectors/pickAxisType.ts +4 -0
  154. package/src/state/selectors/pieSelectors.ts +14 -13
  155. package/src/state/selectors/polarAxisSelectors.ts +223 -0
  156. package/src/state/selectors/polarSelectors.ts +1 -1
  157. package/src/state/selectors/radarSelectors.ts +1 -1
  158. package/src/state/selectors/radialBarSelectors.ts +17 -16
  159. package/src/state/selectors/rootPropsSelectors.ts +26 -0
  160. package/src/state/selectors/scatterSelectors.ts +11 -10
  161. package/src/state/selectors/{selectActivePropsFromChartPointer.js → selectActivePropsFromChartPointer.ts} +11 -4
  162. package/src/state/selectors/selectAllAxes.ts +20 -0
  163. package/src/state/selectors/selectChartOffset.ts +17 -0
  164. package/src/state/selectors/selectChartOffsetInternal.ts +147 -0
  165. package/src/state/selectors/{selectPlotArea.js → selectPlotArea.ts} +4 -3
  166. package/src/state/selectors/selectTooltipAxisId.ts +6 -0
  167. package/src/state/selectors/{selectTooltipAxisType.js → selectTooltipAxisType.ts} +10 -4
  168. package/src/state/selectors/selectTooltipEventType.ts +39 -0
  169. package/src/state/selectors/selectTooltipPayloadSearcher.ts +6 -0
  170. package/src/state/selectors/selectTooltipSettings.ts +6 -0
  171. package/src/state/selectors/selectTooltipState.ts +5 -0
  172. package/src/state/selectors/selectors.ts +315 -0
  173. package/src/state/selectors/tooltipSelectors.ts +611 -0
  174. package/src/state/selectors/touchSelectors.ts +52 -0
  175. package/src/state/{store.js → store.ts} +46 -36
  176. package/src/state/tooltipSlice.ts +507 -0
  177. package/src/state/{touchEventsMiddleware.js → touchEventsMiddleware.ts} +54 -42
  178. package/src/state/types/AreaSettings.ts +15 -0
  179. package/src/state/types/BarSettings.ts +15 -0
  180. package/src/state/types/LineSettings.ts +10 -0
  181. package/src/state/types/PieSettings.ts +32 -0
  182. package/src/state/types/RadarSettings.ts +6 -0
  183. package/src/state/types/RadialBarSettings.ts +10 -0
  184. package/src/state/types/ScatterSettings.ts +13 -0
  185. package/src/state/types/StackedGraphicalItem.ts +34 -0
  186. package/src/state/zIndexSlice.ts +137 -0
  187. package/src/synchronisation/syncSelectors.ts +7 -0
  188. package/src/synchronisation/types.ts +42 -0
  189. package/src/synchronisation/useChartSynchronisation.tsrx +26 -11
  190. package/src/types.ts +55 -0
  191. package/src/util/ActiveShapeUtils.tsrx +34 -10
  192. package/src/util/BarUtils.tsrx +43 -3
  193. package/src/util/{CartesianUtils.js → CartesianUtils.ts} +22 -39
  194. package/src/util/ChartUtils.ts +759 -0
  195. package/src/util/{Constants.js → Constants.ts} +6 -6
  196. package/src/util/DOMUtils.ts +135 -0
  197. package/src/util/{DataUtils.js → DataUtils.ts} +120 -47
  198. package/src/util/Events.ts +22 -0
  199. package/src/util/FunnelUtils.tsrx +3 -3
  200. package/src/util/Global.ts +13 -0
  201. package/src/util/IfOverflow.ts +16 -0
  202. package/src/util/LRUCache.ts +42 -0
  203. package/src/util/{LogUtils.js → LogUtils.ts} +7 -12
  204. package/src/util/OctaneTypes.ts +51 -0
  205. package/src/util/PolarUtils.ts +132 -0
  206. package/src/util/RadialBarUtils.tsrx +3 -3
  207. package/src/util/ReduceCSSCalc.ts +186 -0
  208. package/src/util/ScatterUtils.tsrx +9 -7
  209. package/src/util/{TickUtils.js → TickUtils.ts} +30 -13
  210. package/src/util/{YAxisUtils.js → YAxisUtils.ts} +27 -17
  211. package/src/util/axisPropsAreEqual.ts +49 -0
  212. package/src/util/createEventProxy.ts +20 -0
  213. package/src/util/{excludeEventProps.js → excludeEventProps.ts} +8 -6
  214. package/src/util/getActiveCoordinate.ts +210 -0
  215. package/src/util/{getAxisTypeBasedOnLayout.js → getAxisTypeBasedOnLayout.ts} +7 -3
  216. package/src/util/getClassNameFromUnknown.ts +7 -0
  217. package/src/util/{getEveryNth.js → getEveryNth.ts} +5 -6
  218. package/src/util/getRadiusAndStrokeWidthFromDot.ts +31 -0
  219. package/src/util/{getRelativeCoordinate.js → getRelativeCoordinate.ts} +26 -9
  220. package/src/util/getSliced.ts +14 -0
  221. package/src/util/{isDomainSpecifiedByUser.js → isDomainSpecifiedByUser.ts} +46 -100
  222. package/src/util/isWellBehavedNumber.ts +8 -0
  223. package/src/util/payload/getUniqPayload.ts +1 -1
  224. package/src/util/{propsAreEqual.js → propsAreEqual.ts} +10 -8
  225. package/src/util/{resolveDefaultProps.js → resolveDefaultProps.ts} +35 -57
  226. package/src/util/round.ts +33 -0
  227. package/src/util/scale/CustomScaleDefinition.ts +82 -0
  228. package/src/util/scale/RechartsScale.ts +131 -0
  229. package/src/util/scale/{createCategoricalInverse.js → createCategoricalInverse.ts} +24 -29
  230. package/src/util/scale/{getNiceTickValues.js → getNiceTickValues.ts} +125 -146
  231. package/src/util/scale/index.ts +2 -0
  232. package/src/util/scale/util/{arithmetic.js → arithmetic.ts} +12 -8
  233. package/src/util/stacks/getStackSeriesIdentifier.ts +21 -0
  234. package/src/util/stacks/stackTypes.ts +58 -0
  235. package/src/util/{svgPropertiesNoEvents.js → svgPropertiesNoEvents.ts} +52 -27
  236. package/src/util/tooltip/translate.ts +2 -1
  237. package/src/util/typedDataKey.ts +49 -0
  238. package/src/util/types.ts +1265 -7
  239. package/src/util/{useUniqueId.js → useUniqueId.ts} +9 -5
  240. package/src/zIndex/{DefaultZIndexes.js → DefaultZIndexes.ts} +13 -4
  241. package/src/zIndex/ZIndexLayer.tsrx +13 -4
  242. package/src/zIndex/ZIndexPortal.tsrx +14 -4
  243. package/src/zIndex/{getZIndexFromUnknown.js → getZIndexFromUnknown.ts} +3 -3
  244. package/src/zIndex/{zIndexSelectors.js → zIndexSelectors.ts} +17 -11
  245. package/src/animation/easing.js +0 -193
  246. package/src/animation/timeoutController.js +0 -49
  247. package/src/animation/util.js +0 -11
  248. package/src/cartesian/Area.tsrx.d.ts +0 -340
  249. package/src/cartesian/Bar.tsrx.d.ts +0 -4
  250. package/src/cartesian/BarStack.tsrx.d.ts +0 -6
  251. package/src/cartesian/CartesianAxis.tsrx.d.ts +0 -3
  252. package/src/cartesian/CartesianGrid.tsrx.d.ts +0 -219
  253. package/src/cartesian/ErrorBar.tsrx.d.ts +0 -131
  254. package/src/cartesian/Funnel.tsrx.d.ts +0 -274
  255. package/src/cartesian/Line.tsrx.d.ts +0 -4
  256. package/src/cartesian/LineDrawShape.tsrx.d.ts +0 -2
  257. package/src/cartesian/ReferenceLine.tsrx.d.ts +0 -178
  258. package/src/cartesian/Scatter.tsrx.d.ts +0 -351
  259. package/src/cartesian/XAxis.tsrx.d.ts +0 -3
  260. package/src/cartesian/YAxis.tsrx.d.ts +0 -3
  261. package/src/cartesian/ZAxis.tsrx.d.ts +0 -102
  262. package/src/cartesian/getCartesianPosition.js +0 -277
  263. package/src/cartesian/getEquidistantTicks.js +0 -133
  264. package/src/cartesian/getTicks.js +0 -280
  265. package/src/chart/AreaChart.tsrx.d.ts +0 -12
  266. package/src/chart/BarChart.tsrx.d.ts +0 -2
  267. package/src/chart/CartesianChart.tsrx.d.ts +0 -10
  268. package/src/chart/ComposedChart.tsrx.d.ts +0 -12
  269. package/src/chart/FunnelChart.tsrx.d.ts +0 -12
  270. package/src/chart/LineChart.tsrx.d.ts +0 -2
  271. package/src/chart/PieChart.tsrx.d.ts +0 -31
  272. package/src/chart/RadarChart.tsrx.d.ts +0 -31
  273. package/src/chart/RadialBarChart.tsrx.d.ts +0 -31
  274. package/src/chart/Sankey.tsrx.d.ts +0 -253
  275. package/src/chart/ScatterChart.tsrx.d.ts +0 -12
  276. package/src/chart/SunburstChart.tsrx.d.ts +0 -146
  277. package/src/component/DefaultLegendContent.tsrx.d.ts +0 -125
  278. package/src/component/DefaultTooltipContent.tsrx.d.ts +0 -87
  279. package/src/component/Label.tsrx.d.ts +0 -12
  280. package/src/component/LabelList.tsrx.d.ts +0 -8
  281. package/src/component/Legend.tsrx.d.ts +0 -88
  282. package/src/component/ResponsiveContainer.tsrx.d.ts +0 -81
  283. package/src/component/Text.tsrx.d.ts +0 -9
  284. package/src/component/Tooltip.tsrx.d.ts +0 -246
  285. package/src/container/Layer.tsrx.d.ts +0 -6
  286. package/src/container/Surface.tsrx.d.ts +0 -12
  287. package/src/context/accessibilityContext.js +0 -10
  288. package/src/context/tooltipContext.js +0 -55
  289. package/src/index.d.ts +0 -281
  290. package/src/polar/Pie.tsrx.d.ts +0 -436
  291. package/src/polar/PolarAngleAxis.tsrx.d.ts +0 -215
  292. package/src/polar/PolarGrid.tsrx.d.ts +0 -117
  293. package/src/polar/PolarRadiusAxis.tsrx.d.ts +0 -209
  294. package/src/polar/Radar.tsrx.d.ts +0 -215
  295. package/src/polar/RadialBar.tsrx.d.ts +0 -340
  296. package/src/shape/Cross.tsrx.d.ts +0 -12
  297. package/src/shape/Curve.tsrx.d.ts +0 -42
  298. package/src/shape/Dot.tsrx.d.ts +0 -9
  299. package/src/shape/Polygon.tsrx.d.ts +0 -13
  300. package/src/shape/Rectangle.tsrx.d.ts +0 -31
  301. package/src/shape/Sector.tsrx.d.ts +0 -29
  302. package/src/shape/Symbols.tsrx.d.ts +0 -15
  303. package/src/shape/Trapezoid.tsrx.d.ts +0 -29
  304. package/src/state/brushSlice.js +0 -36
  305. package/src/state/cartesianAxisSlice.js +0 -256
  306. package/src/state/chartDataSlice.js +0 -67
  307. package/src/state/errorBarSlice.js +0 -53
  308. package/src/state/eventSettingsSlice.js +0 -25
  309. package/src/state/graphicalItemsSlice.js +0 -91
  310. package/src/state/layoutSlice.js +0 -57
  311. package/src/state/legendSlice.js +0 -83
  312. package/src/state/optionsSlice.js +0 -45
  313. package/src/state/polarAxisSlice.js +0 -33
  314. package/src/state/polarOptionsSlice.js +0 -26
  315. package/src/state/reduxDevtoolsJsonStringifyReplacer.js +0 -14
  316. package/src/state/referenceElementsSlice.js +0 -51
  317. package/src/state/renderedTicksSlice.js +0 -41
  318. package/src/state/rootPropsSlice.js +0 -48
  319. package/src/state/selectors/axisSelectors.js +0 -2113
  320. package/src/state/selectors/barSelectors.js +0 -263
  321. package/src/state/selectors/barStackSelectors.js +0 -65
  322. package/src/state/selectors/brushSelectors.js +0 -21
  323. package/src/state/selectors/combiners/combineActiveLabel.js +0 -18
  324. package/src/state/selectors/combiners/combineAllBarPositions.js +0 -169
  325. package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +0 -11
  326. package/src/state/selectors/combiners/combineBarPosition.js +0 -17
  327. package/src/state/selectors/combiners/combineBarSizeList.js +0 -115
  328. package/src/state/selectors/combiners/combineConfiguredScale.js +0 -46
  329. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +0 -48
  330. package/src/state/selectors/combiners/combineInverseScaleFunction.js +0 -12
  331. package/src/state/selectors/combiners/combineStackedData.js +0 -22
  332. package/src/state/selectors/combiners/combineTooltipInteractionState.js +0 -121
  333. package/src/state/selectors/combiners/combineTooltipPayload.js +0 -248
  334. package/src/state/selectors/containerSelectors.js +0 -6
  335. package/src/state/selectors/graphicalItemSelectors.js +0 -25
  336. package/src/state/selectors/legendSelectors.js +0 -18
  337. package/src/state/selectors/lineSelectors.js +0 -106
  338. package/src/state/selectors/numberDomainEqualityCheck.js +0 -11
  339. package/src/state/selectors/pickAxisId.js +0 -3
  340. package/src/state/selectors/pickAxisType.js +0 -3
  341. package/src/state/selectors/polarAxisSelectors.js +0 -237
  342. package/src/state/selectors/rootPropsSelectors.js +0 -13
  343. package/src/state/selectors/selectAllAxes.js +0 -15
  344. package/src/state/selectors/selectChartOffset.js +0 -12
  345. package/src/state/selectors/selectChartOffsetInternal.js +0 -174
  346. package/src/state/selectors/selectTooltipAxisId.js +0 -3
  347. package/src/state/selectors/selectTooltipEventType.js +0 -27
  348. package/src/state/selectors/selectTooltipPayloadSearcher.js +0 -3
  349. package/src/state/selectors/selectTooltipSettings.js +0 -3
  350. package/src/state/selectors/selectTooltipState.js +0 -3
  351. package/src/state/selectors/selectors.js +0 -222
  352. package/src/state/selectors/tooltipSelectors.js +0 -471
  353. package/src/state/selectors/touchSelectors.js +0 -31
  354. package/src/state/tooltipSlice.js +0 -237
  355. package/src/state/types/StackedGraphicalItem.js +0 -18
  356. package/src/state/zIndexSlice.js +0 -167
  357. package/src/synchronisation/syncSelectors.js +0 -5
  358. package/src/util/ChartUtils.js +0 -630
  359. package/src/util/DOMUtils.js +0 -180
  360. package/src/util/Events.js +0 -7
  361. package/src/util/Global.js +0 -13
  362. package/src/util/LRUCache.js +0 -58
  363. package/src/util/PolarUtils.js +0 -190
  364. package/src/util/ReduceCSSCalc.js +0 -260
  365. package/src/util/axisPropsAreEqual.js +0 -63
  366. package/src/util/createEventProxy.js +0 -18
  367. package/src/util/getActiveCoordinate.js +0 -253
  368. package/src/util/getClassNameFromUnknown.js +0 -8
  369. package/src/util/getRadiusAndStrokeWidthFromDot.js +0 -28
  370. package/src/util/getSliced.js +0 -11
  371. package/src/util/isWellBehavedNumber.js +0 -8
  372. package/src/util/round.js +0 -39
  373. package/src/util/scale/RechartsScale.js +0 -68
  374. package/src/util/scale/index.js +0 -3
  375. package/src/util/stacks/getStackSeriesIdentifier.js +0 -10
  376. package/src/zIndex/ZIndexLayer.tsrx.d.ts +0 -2
package/src/util/types.ts CHANGED
@@ -1,9 +1,719 @@
1
- // Port of the runtime helpers from recharts' util/types.ts (the file is mostly
2
- // type definitions; these are the two runtime exports the components use).
3
- // octane events are NATIVE delegated DOM events — handlers receive the real
4
- // event, matching the platform (never a synthetic wrapper).
1
+ // Adapted from recharts@3.9.2, commit b3451050c027a23957ffa50a2665c9119df21e47.
2
+ import type {
3
+ AriaAttributes,
4
+ CSSProperties,
5
+ NativeMouseEvent,
6
+ OctaneElement,
7
+ OctaneNode,
8
+ SVGProps,
9
+ } from './OctaneTypes';
5
10
  import { isValidElement } from 'octane';
6
- import { isEventKey } from '../util/excludeEventProps';
11
+ import type * as d3Scales from 'victory-vendor/d3-scale';
12
+ import type { Props as DotProps } from '../shape/Dot.tsrx';
13
+ import { AxisRange } from '../state/selectors/axisSelectors';
14
+ import { ExternalMouseEvents } from '../chart/types';
15
+ import { SyncMethod } from '../synchronisation/types';
16
+ import { isEventKey, type EventKeysType } from './excludeEventProps';
17
+ import { DotPoint } from '../component/Dots.tsrx';
18
+ import { SVGPropsNoEvents } from './svgPropertiesNoEvents';
19
+ import { BaseValue } from '../cartesian/Area.tsrx';
20
+ import { ImplicitLabelType } from '../component/Label.tsrx';
21
+ import { CustomScaleDefinition } from './scale/CustomScaleDefinition';
22
+ import { ChartData } from '../state/chartDataSlice';
23
+ import {
24
+ XAxisOrientation,
25
+ XAxisPadding,
26
+ YAxisOrientation,
27
+ YAxisPadding,
28
+ } from '../state/cartesianAxisSlice';
29
+ import { TextAnchor, TextVerticalAnchor } from '../component/Text.tsrx';
30
+ import type { TickFormatter } from '../cartesian/CartesianAxis.tsrx';
31
+ import type { Props as TextProps } from '../component/Text.tsrx';
32
+ import { TypedDataKey } from './typedDataKey';
33
+ import type { EasingInput } from '../animation/easing';
34
+
35
+ /**
36
+ * Determines how values are stacked:
37
+ *
38
+ * - `none` is the default, it adds values on top of each other. No smarts. Negative values will overlap.
39
+ * - `expand` make it so that the values always add up to 1 - so the chart will look like a rectangle.
40
+ * - `wiggle` and `silhouette` tries to keep the chart centered.
41
+ * - `sign` stacks positive values above zero and negative values below zero. Similar to `none` but handles negatives.
42
+ * - `positive` ignores all negative values, and then behaves like \`none\`.
43
+ *
44
+ * @see {@link https://d3js.org/d3-shape/stack#stack-offsets}
45
+ * (note that the `diverging` offset in d3 is named `sign` in recharts)
46
+ *
47
+ * @inline
48
+ */
49
+ export type StackOffsetType = 'sign' | 'expand' | 'none' | 'wiggle' | 'silhouette' | 'positive';
50
+ export type CartesianLayout = 'horizontal' | 'vertical';
51
+ export type PolarLayout = 'centric' | 'radial';
52
+ /**
53
+ * @deprecated use either `CartesianLayout` or `PolarLayout` instead.
54
+ * Mixing both charts families leads to ambiguity in the type system.
55
+ * These two layouts share very few properties, so it is best to keep them separate.
56
+ */
57
+ export type LayoutType = CartesianLayout | PolarLayout;
58
+ export type AxisType = 'xAxis' | 'yAxis' | 'zAxis' | 'angleAxis' | 'radiusAxis';
59
+
60
+ /**
61
+ * The type of axis.
62
+ *
63
+ * `category`: Treats data as distinct values.
64
+ * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
65
+ *
66
+ * `number`: Treats data as continuous range.
67
+ * Values that are numerically closer are placed closer together on the axis.
68
+ *
69
+ * `auto`: the type is inferred based on the chart layout.
70
+ *
71
+ * This is external type - users will provide this type in props.
72
+ * Internally we will evaluate it to either 'category' or 'number' based on the layout,
73
+ * before sending it to the store.
74
+ *
75
+ * @inline
76
+ */
77
+ export type AxisDomainTypeInput = 'number' | 'category' | 'auto';
78
+
79
+ /**
80
+ * Individual axes are responsible for resolving the 'auto' type to either 'number' or 'category',
81
+ * based on the chart layout and axis kind. Then they can start using this type.
82
+ */
83
+ export type EvaluatedAxisDomainType = 'number' | 'category';
84
+
85
+ /**
86
+ * Extracts values from data objects.
87
+ *
88
+ * @inline
89
+ */
90
+ export type DataKey<DataPointType, DataValueType = any> = TypedDataKey<
91
+ DataPointType,
92
+ DataValueType
93
+ >;
94
+ export type PresentationAttributesWithProps<P, T> = AriaAttributes &
95
+ DOMAttributesWithProps<P, T> &
96
+ Omit<SVGProps<T>, NativeEventProp<T> | keyof DOMAttributesWithProps<P, T>>;
97
+ export type PresentationAttributesAdaptChildEvent<P, T> = AriaAttributes &
98
+ DOMAttributesAdaptChildEvent<P, T> &
99
+ Omit<SVGProps<T>, NativeEventProp<T> | keyof DOMAttributesAdaptChildEvent<P, T>>;
100
+
101
+ /**
102
+ * @inline
103
+ */
104
+ export type SymbolType = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
105
+
106
+ /**
107
+ * @inline
108
+ */
109
+ export type LegendType =
110
+ | 'circle'
111
+ | 'cross'
112
+ | 'diamond'
113
+ | 'line'
114
+ | 'plainline'
115
+ | 'rect'
116
+ | 'square'
117
+ | 'star'
118
+ | 'triangle'
119
+ | 'wye'
120
+ | 'none';
121
+ export type TooltipType = 'none';
122
+
123
+ export type AllowInDimension = {
124
+ x?: boolean;
125
+ y?: boolean;
126
+ };
127
+
128
+ export interface Coordinate {
129
+ x: number;
130
+ y: number;
131
+ }
132
+
133
+ export interface NullableCoordinate {
134
+ x: number | null;
135
+ y: number | null;
136
+ }
137
+
138
+ export type RectangleCoordinate = {
139
+ x1: number;
140
+ y1: number;
141
+ x2: number;
142
+ y2: number;
143
+ };
144
+
145
+ export type RectanglePosition = {
146
+ x: number;
147
+ y: number;
148
+ width: number;
149
+ height: number;
150
+ };
151
+
152
+ /**
153
+ * @deprecated do not use: too many properties, mixing too many concepts, cartesian and polar together, everything optional.
154
+ * Instead, use either `Coordinate` or `PolarCoordinate`.
155
+ */
156
+ export interface ChartCoordinate extends Coordinate {
157
+ xAxis?: any;
158
+ yAxis?: any;
159
+ width?: any;
160
+ height?: any;
161
+ offset?: ChartOffsetInternal;
162
+ angle?: number;
163
+ radius?: number;
164
+ cx?: number;
165
+ cy?: number;
166
+ startAngle?: number;
167
+ endAngle?: number;
168
+ innerRadius?: number;
169
+ outerRadius?: number;
170
+ }
171
+
172
+ export type PolarCoordinate = Coordinate & {
173
+ angle: number;
174
+ startAngle: number;
175
+ endAngle: number;
176
+ clockWise: boolean;
177
+ cx: number;
178
+ cy: number;
179
+ innerRadius: number;
180
+ outerRadius: number;
181
+ radius: number;
182
+ };
183
+
184
+ export const isPolarCoordinate = (c: Coordinate | PolarCoordinate): c is PolarCoordinate => {
185
+ return 'radius' in c && 'startAngle' in c && 'endAngle' in c;
186
+ };
187
+
188
+ export type RechartsScaleType =
189
+ | 'linear'
190
+ | 'pow'
191
+ | 'sqrt'
192
+ | 'log'
193
+ | 'symlog'
194
+ | 'identity'
195
+ | 'time'
196
+ | 'band'
197
+ | 'point'
198
+ | 'ordinal'
199
+ | 'quantile'
200
+ | 'quantize'
201
+ | 'utc'
202
+ | 'sequential'
203
+ | 'threshold';
204
+
205
+ export type D3ScaleType = Extract<keyof typeof d3Scales, `scale${string}`>;
206
+
207
+ /**
208
+ * String shortcuts for scale types.
209
+ * In case none of these does what you want you can also provide your own scale function
210
+ * @see {@link CustomScaleDefinition}
211
+ */
212
+ export type ScaleType = 'auto' | RechartsScaleType;
213
+
214
+ //
215
+ // Event Handler Types -- Copied from @types/react/index.d.ts and adapted for Props.
216
+ //
217
+
218
+ type NativeEventProp<T> = Extract<keyof SVGProps<T>, `on${string}`>;
219
+ type NativeEventFor<H> = NonNullable<H> extends (event: infer E) => unknown ? E : never;
220
+
221
+ type EventHandler<P, E> = {
222
+ bivarianceHack(props: P, event: E): void;
223
+ }['bivarianceHack'];
224
+
225
+ type AdaptChildEventHandler<P, E> = {
226
+ bivarianceHack(data: P, index: number, event: E): void;
227
+ }['bivarianceHack'];
228
+
229
+ export type RechartsMouseEventHandler<P, T = Element> = EventHandler<P, NativeMouseEvent<T>>;
230
+
231
+ // Rebind the supported native event surface. Omit other native handlers from
232
+ // inherited SVG props: the runtime adapter's whitelist does not forward them.
233
+ export type DOMAttributesWithProps<P, T> = Pick<
234
+ SVGProps<T>,
235
+ 'children' | 'dangerouslySetInnerHTML'
236
+ > & {
237
+ [K in Extract<NativeEventProp<T>, EventKeysType>]?: EventHandler<
238
+ P,
239
+ NativeEventFor<SVGProps<T>[K]>
240
+ >;
241
+ };
242
+
243
+ export type DOMAttributesAdaptChildEvent<P, T> = Pick<
244
+ SVGProps<T>,
245
+ 'children' | 'dangerouslySetInnerHTML'
246
+ > & {
247
+ [K in Extract<NativeEventProp<T>, EventKeysType>]?: AdaptChildEventHandler<
248
+ P,
249
+ NativeEventFor<SVGProps<T>[K]>
250
+ >;
251
+ };
252
+
253
+ export type { EasingInput };
254
+ /** @deprecated Use EasingInput instead */
255
+ export type AnimationTiming = EasingInput;
256
+ /** Specifies the duration of animation, the unit of this option is ms. */
257
+ export type AnimationDuration = number;
258
+
259
+ export type OffsetVertical = {
260
+ top: number;
261
+ bottom: number;
262
+ };
263
+
264
+ export type OffsetHorizontal = {
265
+ left: number;
266
+ right: number;
267
+ };
268
+
269
+ /**
270
+ * This object defines the offset of the chart area and width and height and brush and ... it's a bit too much information all in one.
271
+ * We use it internally but let's not expose it to the outside world.
272
+ * If you are looking for this information, instead import `ChartOffset` or `PlotArea` from `recharts`.
273
+ */
274
+ export type ChartOffsetInternal = {
275
+ top: number;
276
+ bottom: number;
277
+ left: number;
278
+ right: number;
279
+ width: number;
280
+ height: number;
281
+ brushBottom: number;
282
+ };
283
+
284
+ export interface Padding {
285
+ top: number;
286
+ bottom: number;
287
+ left: number;
288
+ right: number;
289
+ }
290
+
291
+ export interface GeometrySector {
292
+ cx: number;
293
+ cy: number;
294
+ innerRadius: number;
295
+ outerRadius: number;
296
+ startAngle: number;
297
+ endAngle: number;
298
+ }
299
+
300
+ export type GeometrySectorWithCornerRadius = GeometrySector & {
301
+ cornerRadius: number;
302
+ forceCornerRadius: boolean;
303
+ cornerIsExternal: boolean;
304
+ };
305
+
306
+ export type AxisDomainItem =
307
+ string | number | ((d: number) => string | number) | 'auto' | 'dataMin' | 'dataMax';
308
+
309
+ /**
310
+ * The domain of axis.
311
+ * This is the definition
312
+ *
313
+ * Numeric domain is always defined by an array of exactly two values, for the min and the max of the axis.
314
+ * Categorical domain is defined as array of all possible values.
315
+ *
316
+ * Can be specified in many ways:
317
+ * - array of numbers
318
+ * - with special strings like 'dataMin' and 'dataMax'
319
+ * - with special string math like 'dataMin - 100'
320
+ * - with keyword 'auto'
321
+ * - or a function
322
+ * - array of functions
323
+ * - or a combination of the above
324
+ */
325
+ export type AxisDomain =
326
+ | ReadonlyArray<string>
327
+ | ReadonlyArray<number>
328
+ | Readonly<[AxisDomainItem, AxisDomainItem]>
329
+ | (([dataMin, dataMax]: NumberDomain, allowDataOverflow: boolean) => NumberDomain);
330
+
331
+ /**
332
+ * NumberDomain is an evaluated {@link AxisDomain}.
333
+ * Unlike {@link AxisDomain}, it has no variety - it's a tuple of two number.
334
+ * This is after all the keywords and functions were evaluated and what is left is [min, max].
335
+ *
336
+ * Know that the min, max values are not guaranteed to be nice numbers - values like -Infinity or NaN are possible.
337
+ *
338
+ * There are also `category` axes that have different things than numbers in their domain.
339
+ */
340
+ export type NumberDomain = readonly [min: number, max: number];
341
+
342
+ export type CategoricalDomainItem = number | string | Date;
343
+
344
+ export type CategoricalDomain = ReadonlyArray<CategoricalDomainItem>;
345
+
346
+ export type BaseTickContentProps = {
347
+ angle: number;
348
+ className?: SVGProps<SVGElement>['className'];
349
+ fill: string | undefined;
350
+ height?: number | string;
351
+ index: number;
352
+ name?: string;
353
+ stroke: string;
354
+ payload: CartesianTickItem;
355
+ textAnchor: TextAnchor;
356
+ tickFormatter: TickFormatter | undefined;
357
+ verticalAnchor: TextVerticalAnchor;
358
+ visibleTicksCount: number;
359
+ width?: number | string;
360
+ x: number | string;
361
+ y: number | string;
362
+ };
363
+
364
+ /** Polar ticks do not receive cartesian tick counts or formatter callbacks. */
365
+ export type PolarTickContentProps = Omit<
366
+ BaseTickContentProps,
367
+ 'angle' | 'payload' | 'tickFormatter' | 'visibleTicksCount' | 'verticalAnchor'
368
+ > & {
369
+ angle?: number;
370
+ payload: TickItem;
371
+ verticalAnchor?: TextVerticalAnchor;
372
+ };
373
+
374
+ export type XAxisTickContentProps = BaseTickContentProps & {
375
+ orientation: XAxisOrientation;
376
+ padding: XAxisPadding | undefined;
377
+ };
378
+
379
+ export type YAxisTickContentProps = BaseTickContentProps & {
380
+ orientation: YAxisOrientation;
381
+ padding: YAxisPadding | undefined;
382
+ };
383
+
384
+ /**
385
+ * @inline
386
+ */
387
+ export type TickProp<T> = TextProps | OctaneElement | ((props: T) => OctaneNode) | boolean;
388
+
389
+ export interface BaseAxisProps<DataPointType, DataValueType> extends DataConsumer<
390
+ DataPointType,
391
+ DataValueType
392
+ > {
393
+ /**
394
+ * The type of axis.
395
+ *
396
+ * `category`: Treats data as distinct values.
397
+ * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
398
+ *
399
+ * `number`: Treats data as continuous range.
400
+ * Values that are numerically closer are placed closer together on the axis.
401
+ *
402
+ * `auto`: the type is inferred based on the chart layout.
403
+ */
404
+ type?: AxisDomainTypeInput;
405
+ /**
406
+ * The name of data.
407
+ * This option will be used in tooltip.
408
+ * If no value was set to this option, the value of dataKey will be used alternatively.
409
+ */
410
+ name?: string;
411
+ /**
412
+ * The unit of data. This option will be used in tooltip.
413
+ */
414
+ unit?: string;
415
+ /**
416
+ * The data that you provide via the `data` prop is an array of objects.
417
+ * Each object can have multiple properties, each representing a different data dimension.
418
+ * Use the `dataKey` prop to specify which property (or dimension) to use for this component.
419
+ *
420
+ * Typically, you will want to have one dataKey on the X axis, and different dataKey on the Y axis,
421
+ * where they extract different values from the same data objects.
422
+ *
423
+ * Decides how to extract the value of this Axis from the data:
424
+ * - `string`: the name of the field in the data object;
425
+ * - `number`: the index of the field in the data;
426
+ * - `function`: a function that receives the data object and returns the value of this Axis.
427
+ *
428
+ * If undefined, it will reuse the dataKey of graphical items.
429
+ */
430
+ dataKey?: DataKey<DataPointType, DataValueType>;
431
+ /**
432
+ * Specify the domain of axis when the axis is a number axis.
433
+ *
434
+ * If undefined, then the domain is calculated based on the data and dataKeys.
435
+ *
436
+ * The length of domain should be 2, and we will validate the values in domain.
437
+ *
438
+ * Each element in the array can be a number, 'auto', 'dataMin', 'dataMax', a string like 'dataMin - 20', 'dataMax + 100',
439
+ * or a function that accepts a single argument and returns a number.
440
+ *
441
+ * If any element of domain is set to be 'auto', comprehensible scale ticks will be calculated, and the final domain of axis is generated by the ticks.
442
+ * If a function, receives '[dataMin, dataMax]', and must return a computed domain as '[min, max]'.
443
+ *
444
+ * @example <XAxis type="number" domain={['dataMin', 'dataMax']} />
445
+ * @example <XAxis type="number" domain={[0, 'dataMax']} />
446
+ * @example <XAxis type="number" domain={['auto', 'auto']} />
447
+ * @example <XAxis type="number" domain={[0, 'dataMax + 1000']} />
448
+ * @example <XAxis type="number" domain={['dataMin - 100', 'dataMax + 100']} />
449
+ * @example <XAxis type="number" domain={[dataMin => (0 - Math.abs(dataMin)), dataMax => (dataMax * 2)]} />
450
+ * @example <XAxis type="number" domain={([dataMin, dataMax]) => { const absMax = Math.max(Math.abs(dataMin), Math.abs(dataMax)); return [-absMax, absMax]; }} />
451
+ * @example <XAxis type="number" domain={[0, 100]} allowDataOverflow />
452
+ */
453
+ domain?: AxisDomain;
454
+ /**
455
+ * Scale function determines how data values are mapped to visual values.
456
+ * In other words, decided the mapping between data domain and coordinate range.
457
+ *
458
+ * If undefined, or 'auto', the scale function is created internally according to the type of axis and data.
459
+ *
460
+ * You can define a custom scale, either as a string shortcut to a d3 scale, or as a complete scale definition object.
461
+ *
462
+ * @defaultValue auto
463
+ * @example <XAxis scale="log" />
464
+ * @example
465
+ * import { scaleLog } from 'd3-scale';
466
+ * const scale = scaleLog().base(Math.E);
467
+ * <YAxis scale={scale} />
468
+ */
469
+ scale?:
470
+ | ScaleType
471
+ | CustomScaleDefinition
472
+ | CustomScaleDefinition<string>
473
+ | CustomScaleDefinition<number>
474
+ | CustomScaleDefinition<Date>;
475
+ }
476
+
477
+ /**
478
+ * Props shared in all renderable axes - meaning the ones that are drawn on the chart,
479
+ * can have ticks, axis line, etc.
480
+ */
481
+ export interface RenderableAxisProps<DataPointType, DataValueType> extends BaseAxisProps<
482
+ DataPointType,
483
+ DataValueType
484
+ > {
485
+ /**
486
+ * Tick text rotation angle in degrees.
487
+ * Positive values rotate clockwise, negative values rotate counterclockwise.
488
+ *
489
+ * @defaultValue 0
490
+ */
491
+ angle?: number;
492
+ /**
493
+ * If set true, the axis do not display in the chart.
494
+ *
495
+ * @defaultValue false
496
+ */
497
+ hide?: boolean;
498
+ /**
499
+ * Defines how the individual label text is rendered.
500
+ * This controls the settings for individual ticks; on a typical axis, there are multiple ticks, depending on your data.
501
+ *
502
+ * If you want to customize the overall axis label, use the `label` prop instead.
503
+ *
504
+ * Options:
505
+ * - `false`: Do not render any tick labels.
506
+ * - `true`: Render tick labels with default settings.
507
+ * - `object`: An object of props to be merged into the internally calculated tick props.
508
+ * - `OctaneElement`: A custom React element to be used as the tick label.
509
+ * - `function`: A function that returns a React element for custom rendering of tick labels.
510
+ *
511
+ * @defaultValue true
512
+ */
513
+ tick?: TickProp<unknown>;
514
+
515
+ /**
516
+ * The count of axis ticks. Not used if 'type' is 'category'.
517
+ *
518
+ * @see {@link https://recharts.github.io/guide/axisTicks/}
519
+ * @defaultValue 5
520
+ */
521
+ tickCount?: number;
522
+ /**
523
+ * Determines how the axis line is drawn. Options:
524
+ * - `true`: the axis line is drawn with default props;
525
+ * - `false`: the axis line is not visible;
526
+ * - `object`: passed as props to SVG `<line>` element representing the axis line.
527
+ *
528
+ * @defaultValue true
529
+ */
530
+ axisLine?: boolean | SVGProps<SVGLineElement>;
531
+
532
+ /**
533
+ * If false set, tick lines will not be drawn.
534
+ * If true set, tick lines will be drawn which have the props calculated internally.
535
+ * If object set, tick lines will be drawn which have the props merged
536
+ * by the internal calculated props and the option.
537
+ * @defaultValue true
538
+ */
539
+ tickLine?: boolean | SVGProps<SVGLineElement>;
540
+ /**
541
+ * The length of tick line.
542
+ * @defaultValue 6
543
+ */
544
+ tickSize?: number;
545
+ /**
546
+ * The formatter function of tick.
547
+ */
548
+ tickFormatter?: (value: any, index: number) => string;
549
+ /**
550
+ * When domain of the axis is specified and the type of the axis is 'number',
551
+ * if allowDataOverflow is set to be false,
552
+ * the domain will be adjusted when the minimum value of data is smaller than domain[0] or
553
+ * the maximum value of data is greater than domain[1] so that the axis displays all data values.
554
+ * If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
555
+ *
556
+ * @defaultValue false
557
+ */
558
+ allowDataOverflow?: boolean;
559
+ /**
560
+ * Allow the axis has duplicated categories or not when the type of axis is "category".
561
+ * @defaultValue true
562
+ */
563
+ allowDuplicatedCategory?: boolean;
564
+ /**
565
+ * Allow the ticks of axis to be decimals or not.
566
+ *
567
+ * @defaultValue true
568
+ */
569
+ allowDecimals?: boolean;
570
+ /**
571
+ * Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden
572
+ * @defaultValue false
573
+ */
574
+ includeHidden?: boolean;
575
+ /**
576
+ * @deprecated Recharts computes the range automatically based on chart width or height
577
+ *
578
+ * Recharts ignores this prop since 3.0
579
+ */
580
+ range?: AxisRange;
581
+ /**
582
+ * Defines a single label for the whole axis.
583
+ * This prop renders one label in the center of the axis line.
584
+ * Useful for labeling the axis as a whole, like "Time (in seconds)" or "Distance (in meters)".
585
+ *
586
+ * This is not controlling tick labels.
587
+ * If you want to customize tick labels, please see `tickFormatter` or `tick` props.
588
+ *
589
+ * - `false`: no label is rendered
590
+ * - `string` | `number`: the content of the label
591
+ * - `object`: the props of LabelList component
592
+ * - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
593
+ * HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
594
+ * - `function`: a render function of custom label
595
+ *
596
+ * @defaultValue false
597
+ */
598
+ label?: ImplicitLabelType;
599
+ /** The HTML element's class name */
600
+ className?: string;
601
+ /**
602
+ * If set to true, the ticks of this axis are reversed.
603
+ * @defaultValue false
604
+ */
605
+ reversed?: boolean;
606
+ }
607
+
608
+ /** Defines how ticks are placed and whether / how tick collisions are handled.
609
+ * 'preserveStart' keeps the left tick on collision and ensures that the first tick is always shown.
610
+ * 'preserveEnd' keeps the right tick on collision and ensures that the last tick is always shown.
611
+ * 'preserveStartEnd' keeps the left tick on collision and ensures that the first and last ticks always show.
612
+ * 'equidistantPreserveStart' selects a number N such that every nTh tick will be shown without collision.
613
+ * 'equidistantPreserveEnd' selects a number N such that every nTh tick will be shown, ensuring the last tick is always visible.
614
+ */
615
+ export type AxisInterval =
616
+ | number
617
+ | 'preserveStart'
618
+ | 'preserveEnd'
619
+ | 'preserveStartEnd'
620
+ | 'equidistantPreserveStart'
621
+ | 'equidistantPreserveEnd';
622
+
623
+ /**
624
+ * Ticks can be any type when the axis is the type of category.
625
+ *
626
+ * Ticks must be numbers when the axis is the type of number.
627
+ *
628
+ * @inline
629
+ */
630
+ export type AxisTick = number | string;
631
+
632
+ export interface TickItem {
633
+ value: any;
634
+ coordinate: number;
635
+ index: number;
636
+ /**
637
+ * How far this tick is offset from the start of a category band.
638
+ * On axes that do not have bands, this will always be zero.
639
+ *
640
+ * We never read offset internally in Recharts,
641
+ * but it has been part of the external API so let's keep it here for people who do use it.
642
+ */
643
+ offset?: number;
644
+ }
645
+
646
+ export interface CartesianTickItem extends TickItem {
647
+ tickCoord?: number;
648
+ tickSize?: number;
649
+ isShow?: boolean;
650
+ }
651
+
652
+ export interface Margin {
653
+ top: number;
654
+ right: number;
655
+ bottom: number;
656
+ left: number;
657
+ }
658
+
659
+ /**
660
+ * @inline
661
+ */
662
+ export interface CartesianViewBox {
663
+ x?: number;
664
+ y?: number;
665
+ width?: number;
666
+ height?: number;
667
+ }
668
+
669
+ export type CartesianViewBoxRequired = Required<CartesianViewBox>;
670
+
671
+ interface PolarViewBox {
672
+ cx?: number;
673
+ cy?: number;
674
+ innerRadius?: number;
675
+ outerRadius?: number;
676
+ startAngle?: number;
677
+ endAngle?: number;
678
+ clockWise?: boolean;
679
+ }
680
+
681
+ export type PolarViewBoxRequired = Required<PolarViewBox>;
682
+
683
+ export type TrapezoidViewBox = {
684
+ /**
685
+ * The x-coordinate of the upper left corner of the trapezoid.
686
+ * If the upper side is shorter than the lower side, this will be the x-coordinate of the upper left corner,
687
+ * meaning that the X does take into account the varying width of the trapezoid.
688
+ */
689
+ x: number;
690
+ /**
691
+ * The y-coordinate of the upper side of the trapezoid.
692
+ * Nothing exciting happening here.
693
+ */
694
+ y: number;
695
+ /**
696
+ * The width of the upper side of the trapezoid.
697
+ */
698
+ upperWidth: number;
699
+ /**
700
+ * The width of the lower side of the trapezoid.
701
+ */
702
+ lowerWidth: number;
703
+ /**
704
+ * The overall width of the trapezoid: `Math.max(upperWidth, lowerWidth)`.
705
+ */
706
+ width: number;
707
+ /**
708
+ * The height of the trapezoid.
709
+ */
710
+ height: number;
711
+ };
712
+
713
+ /**
714
+ * @inline
715
+ */
716
+ export type ViewBox = CartesianViewBoxRequired | PolarViewBoxRequired;
7
717
 
8
718
  // Collect the event handlers off a props bag (or element), rebinding each to
9
719
  // `(e) => handler(props, e)` — recharts item components pass their own props as
@@ -58,5 +768,553 @@ export function adaptEventsOfChild(
58
768
  return out;
59
769
  }
60
770
 
61
- export const isNonEmptyArray = <T>(arr: ReadonlyArray<T> | null | undefined): arr is [T, ...T[]] =>
62
- Array.isArray(arr) && arr.length > 0;
771
+ /**
772
+ * 'axis' means that all graphical items belonging to this axis tick will be highlighted,
773
+ * and all will be present in the tooltip.
774
+ * Tooltip with 'axis' will display when hovering on the chart background.
775
+ *
776
+ * 'item' means only the one graphical item being hovered will show in the tooltip.
777
+ * Tooltip with 'item' will display when hovering over individual graphical items.
778
+ *
779
+ * This is calculated internally;
780
+ * charts have a `defaultTooltipEventType` and `validateTooltipEventTypes` options.
781
+ *
782
+ * Users then use <Tooltip shared={true} /> or <Tooltip shared={false} /> to control their preference,
783
+ * and charts will then see what is allowed and what is not.
784
+ */
785
+ export type TooltipEventType = 'axis' | 'item';
786
+
787
+ export interface SankeyNode {
788
+ // node attributes
789
+ dx: number;
790
+ dy: number;
791
+ name: string;
792
+ value: any;
793
+ x: number;
794
+ y: number;
795
+ // tree attributes
796
+ depth: number;
797
+ targetNodes: number[];
798
+ targetLinks: number[];
799
+ sourceNodes: number[];
800
+ sourceLinks: number[];
801
+ }
802
+
803
+ export interface SankeyLink {
804
+ target: number;
805
+ source: number;
806
+ value: number;
807
+ sy: number;
808
+ dy: number;
809
+ ty: number;
810
+ }
811
+
812
+ export type Size = { width: number; height: number };
813
+
814
+ /**
815
+ * These are the props we are going to pass to an `activeDot` or `dot` if it is a function or a custom ComponentType
816
+ */
817
+ export type ActiveDotProps = DotProps & {
818
+ payload: any;
819
+ index: number;
820
+ dataKey: DataKey<any> | undefined;
821
+ cx: number | undefined;
822
+ cy: number | undefined;
823
+ r: number | string | undefined;
824
+ fill: string;
825
+ strokeWidth: number;
826
+ stroke: string;
827
+ value: any;
828
+ };
829
+
830
+ /**
831
+ * This is the type of `activeDot` prop on:
832
+ * - Area
833
+ * - Line
834
+ * - Radar
835
+ *
836
+ * @inline
837
+ */
838
+ export type ActiveDotType =
839
+ /**
840
+ * true | false will turn the default activeDot on and off, respectively
841
+ */
842
+ | boolean
843
+ /**
844
+ * activeDot can be a custom React ComponentType.
845
+ * It should return an SVG element because we are in SVG context - HTML won't work here.
846
+ * Unfortunately, if you write a regular old functional component and have it return SVG element,
847
+ * its default, inferred return type is `JSX.Element` and so if this return type was `SVGElement`
848
+ * then it would look like a type error (even when doing the right thing).
849
+ * So instead here we have OctaneNode return type which is invalid in runtime
850
+ * (remember, we are in SVG context so HTML elements won't work, we need SVGElement).
851
+ * But better than forcing everyone to re-type their components I guess.
852
+ */
853
+ | ((props: ActiveDotProps) => OctaneNode)
854
+ /**
855
+ * activeDot can be an object; props from here will be appended to the default active dot
856
+ */
857
+ | Partial<ActiveDotProps>
858
+ /**
859
+ * activeDot can be an element; it will get cloned and will receive new extra props.
860
+ * I do not recommend this way! Use React component instead, that way you get more predictable props.
861
+ */
862
+ | OctaneElement<Partial<ActiveDotProps> & Omit<SVGProps<SVGCircleElement>, keyof ActiveDotProps>>;
863
+
864
+ /**
865
+ * Inside the dot event handlers we provide extra information about the dot point
866
+ * that the Dot component itself does not need but users might find useful.
867
+ */
868
+ export type DotItemDotProps = SVGPropsNoEvents<Omit<DotProps, 'points' | 'ref'>> & {
869
+ points: ReadonlyArray<DotPoint>;
870
+ index: number;
871
+ payload: any;
872
+ dataKey: DataKey<any> | undefined;
873
+ value: any;
874
+ };
875
+
876
+ /**
877
+ * This is the type of `dot` prop on:
878
+ * - Area
879
+ * - Line
880
+ * - Radar
881
+ *
882
+ * @inline
883
+ */
884
+ export type DotType =
885
+ /**
886
+ * true | false will turn the default dot on and off, respectively
887
+ */
888
+ | boolean
889
+ /**
890
+ * dot can be a custom React ComponentType.
891
+ * It should return an SVG element because we are in SVG context - HTML won't work here.
892
+ * Unfortunately, if you write a regular old functional component and have it return SVG element,
893
+ * its default, inferred return type is `JSX.Element` and so if this return type was `SVGElement`
894
+ * then it would look like a type error (even when doing the right thing).
895
+ * So instead here we have OctaneNode return type which is invalid in runtime
896
+ * (remember, we are in SVG context so HTML elements won't work, we need SVGElement).
897
+ * But better than forcing everyone to re-type their components I guess.
898
+ *
899
+ * Not that when a function, or a component is used, the props received are {@link DotItemDotProps}
900
+ * which contain some extra information compared to {@link DotProps}.
901
+ */
902
+ | ((props: DotItemDotProps) => OctaneNode)
903
+ /**
904
+ * dot can be an object; props from here will be appended to the default dot
905
+ */
906
+ | Partial<DotProps>
907
+ /**
908
+ * dot can be an element; it will get cloned and will receive new extra props.
909
+ * I do not recommend this way! Use React component instead, that way you get more predictable props.
910
+ */
911
+ | OctaneElement<
912
+ Partial<DotItemDotProps> & Omit<SVGProps<SVGCircleElement>, keyof DotItemDotProps>
913
+ >;
914
+
915
+ /**
916
+ * Animation metadata forwarded to custom chart shapes.
917
+ *
918
+ * These props let a shape react to the current animation state without needing
919
+ * to know how its parent chart component computes the animated geometry.
920
+ */
921
+ export interface ShapeAnimationProps {
922
+ /**
923
+ * Normalized animation progress time in the approximately `[0, 1]` range.
924
+ * 0 = start of animation
925
+ * 1 = end of animation
926
+ * Why approximately? This number already includes easing. The typical easing functions are in 0, 1
927
+ * but you may construct a custom Bézier curve that goes out of the range
928
+ * and so this number may too be out of the range.
929
+ */
930
+ animationElapsedTime?: number;
931
+ /**
932
+ * Whether the parent chart element is currently animating.
933
+ */
934
+ isAnimating?: boolean;
935
+ /**
936
+ * Whether the current animation pass is the initial entrance animation.
937
+ * Some Recharts components have different "first render" and "data update" animations
938
+ * and this is the property that tracks it. You may choose to override it and control
939
+ * which animation renders that way.
940
+ */
941
+ isEntrance?: boolean;
942
+ }
943
+
944
+ export type ActiveShape<PropsType = Record<string, unknown>, ElementType = SVGElement> =
945
+ | OctaneElement<Partial<PropsType> & SVGProps<ElementType>>
946
+ | ((props: PropsType, index?: string | number) => OctaneNode)
947
+ | (Partial<PropsType> & SVGProps<ElementType>)
948
+ | boolean;
949
+
950
+ export type RangeObj = PolarViewBoxRequired & {
951
+ angle: number;
952
+ radius: number;
953
+ };
954
+
955
+ type HTMLElementTarget = Pick<
956
+ HTMLElement,
957
+ 'getBoundingClientRect' | 'offsetWidth' | 'offsetHeight'
958
+ >;
959
+ type SVGElementTarget = Pick<SVGGraphicsElement, 'getBoundingClientRect' | 'getBBox'>;
960
+
961
+ /**
962
+ * Simplified version of the NativeMouseEvent so that we don't have to mock the whole thing in tests.
963
+ *
964
+ * This is meant to represent the NativeMouseEvent
965
+ * which is a wrapper on top of https://developer.mozilla.org/en-US/docs/Web/API/NativeMouseEvent
966
+ */
967
+ export interface HTMLMousePointer {
968
+ clientX: number;
969
+ clientY: number;
970
+ currentTarget: HTMLElementTarget;
971
+ }
972
+
973
+ export interface HTMLTouchPointer {
974
+ touches: ArrayLike<Pick<Touch, 'clientX' | 'clientY'>>;
975
+ currentTarget: HTMLElementTarget;
976
+ }
977
+
978
+ /**
979
+ * Simplified version of the NativeMouseEvent for SVG elements.
980
+ *
981
+ * Similar to MousePointer but uses SVGGraphicsElement properties instead of HTMLElement properties.
982
+ * SVG elements use getBBox() to get the intrinsic size instead of offsetWidth/offsetHeight.
983
+ */
984
+ export interface SVGMousePointer {
985
+ clientX: number;
986
+ clientY: number;
987
+ currentTarget: SVGElementTarget;
988
+ }
989
+
990
+ export interface SVGTouchPointer {
991
+ touches: ArrayLike<Pick<Touch, 'clientX' | 'clientY'>>;
992
+ currentTarget: SVGElementTarget;
993
+ }
994
+
995
+ /**
996
+ * Recharts accepts mouse events from both HTML and SVG elements.
997
+ */
998
+ export type MousePointer = HTMLMousePointer | SVGMousePointer;
999
+ export type TouchPointer = HTMLTouchPointer | SVGTouchPointer;
1000
+
1001
+ /**
1002
+ * Coordinates relative to the top-left corner of the active element.
1003
+ * Also include scale which means that element that's scaled will return the same coordinates as element that's not scaled.
1004
+ */
1005
+ export interface RelativePointer {
1006
+ relativeX: number;
1007
+ relativeY: number;
1008
+ }
1009
+
1010
+ /**
1011
+ * Data provider means that this component accepts a `data` prop which is where you can input your data into the chart state.
1012
+ * The data is an array of objects, where each object represents a data point.
1013
+ *
1014
+ * DataPointType is the type of each data point object in the data array.
1015
+ *
1016
+ * The data is reused in multiple charts and components. Meaning if you provide data on the chart level,
1017
+ * then all child components, graphical items, legend, tooltip, axes ... will be able to access the data.
1018
+ *
1019
+ * Same goes for the graphical item. If you provide data on the graphical item level,
1020
+ * then that data is visible for the main chart, and all axes, tooltip, legend ... in the whole chart.
1021
+ * This is not scoped to the graphical item only.
1022
+ */
1023
+ export interface DataProvider<DataPointType> {
1024
+ /**
1025
+ * The source data. Each element should be an object.
1026
+ * The properties of each object represent the values of different data dimensions.
1027
+ *
1028
+ * Use the `dataKey` prop to specify which properties to use.
1029
+ *
1030
+ * @example data={[{ name: 'a', value: 12 }]}
1031
+ * @example data={[{ label: 'foo', measurements: [5, 12] }]}
1032
+ */
1033
+ data?: ChartData<DataPointType>;
1034
+ }
1035
+
1036
+ /**
1037
+ * Data consumer means that this component accepts a `dataKey` prop which is how you specify
1038
+ * which dimension of the data to use for this component.
1039
+ *
1040
+ * DataPointType is the type of each data point object in the data array.
1041
+ * DataValueType is the type of the value that this dataKey extracts from each data point.
1042
+ */
1043
+ export interface DataConsumer<DataPointType, DataValueType> {
1044
+ /**
1045
+ * The data that you provide via the `data` prop is an array of objects.
1046
+ * Each object can have multiple properties, each representing a different data dimension.
1047
+ * Use the `dataKey` prop to specify which property (or dimension) to use for this component.
1048
+ *
1049
+ * Typically, you will want to have one dataKey on the X axis, and different dataKey on the Y axis,
1050
+ * where they extract different values from the same data objects.
1051
+ *
1052
+ * Decides how to extract the value from the data:
1053
+ * - `string`: the name of the field in the data object;
1054
+ * - `number`: the index of the field in the data;
1055
+ * - `function`: a function that receives the data object and returns the value.
1056
+ */
1057
+ dataKey?: DataKey<DataPointType, DataValueType>;
1058
+ }
1059
+
1060
+ /**
1061
+ * Props shared with all Cartesian and Polar charts.
1062
+ * There are three charts that do not use these base props, and define their own:
1063
+ * - Treemap
1064
+ * - Sunburst
1065
+ * - Sankey
1066
+ */
1067
+ interface BaseChartProps<DataPointType> extends DataProvider<DataPointType>, ExternalMouseEvents {
1068
+ /**
1069
+ * The width of chart container.
1070
+ * Can be a number or a percent string like "100%".
1071
+ *
1072
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1073
+ */
1074
+ width?: number | Percent;
1075
+ /**
1076
+ * The height of chart container.
1077
+ * Can be a number or a percent string like "100%".
1078
+ *
1079
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1080
+ */
1081
+ height?: number | Percent;
1082
+ id?: string;
1083
+ children?: OctaneNode;
1084
+ className?: string;
1085
+ /**
1086
+ * Turn on accessibility support for keyboard-only and screen reader users.
1087
+ *
1088
+ * @defaultValue true
1089
+ */
1090
+ accessibilityLayer?: boolean;
1091
+ desc?: string;
1092
+ /**
1093
+ * Empty space around the container.
1094
+ *
1095
+ * @defaultValue {"top":5,"right":5,"bottom":5,"left":5}
1096
+ */
1097
+ margin?: Partial<Margin>;
1098
+ style?: CSSProperties;
1099
+ /**
1100
+ * The CSS cursor style applied to the chart container.
1101
+ * Useful for setting the mouse cursor when hovering over the chart (e.g. `"pointer"`, `"crosshair"`).
1102
+ */
1103
+ cursor?: CSSProperties['cursor'];
1104
+ /**
1105
+ * Charts with the same syncId will synchronize Tooltip and Brush events.
1106
+ *
1107
+ * @see {@link https://recharts.github.io/en-US/examples/SynchronizedAreaChart/ Synchronized Charts Example}
1108
+ */
1109
+ syncId?: number | string;
1110
+ /**
1111
+ * Customize how the charts will synchronize tooltips and brushes.
1112
+ * `index`: synchronize using the data index in the data array. Index expects that all data has the same length.
1113
+ * `value`: synchronize using the data value on categorical axis (categorical: XAxis in horizontal layout, YAxis in vertical layout).
1114
+ * function: a custom sync method which receives tick and data as argument and returns an index.
1115
+ *
1116
+ * @defaultValue index
1117
+ */
1118
+ syncMethod?: SyncMethod;
1119
+ /**
1120
+ * If and where the chart should appear in the tab order
1121
+ */
1122
+ tabIndex?: number;
1123
+ /**
1124
+ * If true, then it will listen to container size changes and adapt the SVG chart accordingly.
1125
+ * If false, then it renders the chart at the specified width and height and will stay that way
1126
+ * even if the container size changes.
1127
+ *
1128
+ * This is similar to ResponsiveContainer but without the need for an extra wrapper component.
1129
+ * The `responsive` prop also uses standard CSS sizing rules, instead of custom resolution logic (like ResponsiveContainer does).
1130
+ * @default false
1131
+ *
1132
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1133
+ */
1134
+ responsive?: boolean;
1135
+ }
1136
+
1137
+ export interface EventThrottlingProps {
1138
+ /**
1139
+ * Decides the time interval to throttle events.
1140
+ * Only events defined in `throttledEvents` prop are throttled.
1141
+ * All other events are executed immediately/synchronously.
1142
+ *
1143
+ * Options:
1144
+ * - `number`: the time interval in milliseconds
1145
+ * - `'raf'`: use requestAnimationFrame to schedule updates.
1146
+ *
1147
+ * @defaultValue 'raf'
1148
+ */
1149
+ throttleDelay?: number | 'raf';
1150
+ /**
1151
+ * Defines which events should be throttled.
1152
+ * Events not in this list will not be throttled.
1153
+ *
1154
+ * Use the special value `'all'` to throttle all events. Empty array means no events are throttled.
1155
+ *
1156
+ * Use the prop `throttleDelay` to define the throttling interval.
1157
+ *
1158
+ * If an event is on this list, then you lose the opportunity to access the event synchronously.
1159
+ * Which means that if you want to call `e.preventDefault()` or `e.stopPropagation()` inside the event handler,
1160
+ * then that event handler must not be in this list.
1161
+ *
1162
+ * @defaultValue ["mousemove","touchmove","pointermove","scroll","wheel"]
1163
+ */
1164
+ throttledEvents?: ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all';
1165
+ }
1166
+
1167
+ export interface CartesianChartProps<DataPointType = unknown>
1168
+ extends BaseChartProps<DataPointType>, EventThrottlingProps {
1169
+ /**
1170
+ * The gap between two bar categories, which can be a percent value or a fixed value.
1171
+ *
1172
+ * @defaultValue 10%
1173
+ *
1174
+ * @see {@link https://recharts.github.io/en-US/guide/barAlignment/ Bar Alignment Guide}
1175
+ */
1176
+ barCategoryGap?: number | string;
1177
+ /**
1178
+ * The gap between two bars in the same category.
1179
+ *
1180
+ * @defaultValue 4
1181
+ *
1182
+ * @see {@link https://recharts.github.io/en-US/guide/barAlignment/ Bar Alignment Guide}
1183
+ */
1184
+ barGap?: number | string;
1185
+ /**
1186
+ * The width or height of each bar. If the barSize is not specified, the size of the
1187
+ * bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
1188
+ */
1189
+ barSize?: number | string;
1190
+ /**
1191
+ * Configures the starting value used to build the internal baseline for non-ranged, non-stacked areas.
1192
+ *
1193
+ * WARNING despite the name `dataMin`|`dataMax` this actually reads the domain instead, so it should rather be
1194
+ * `domainMin`|`domainMax`. This looks like a small detail,
1195
+ * but it's actually important because domains are usually extended automatically.
1196
+ * For example the default numerical domain starts from 0.
1197
+ *
1198
+ * - `number`: uses the corresponding axis value as a flat baseline
1199
+ * - `dataMin`: uses the minimum of the value-axis domain
1200
+ * - `dataMax`: uses the maximum of the value-axis domain
1201
+ *
1202
+ * This uses the same `BaseValue` resolution as the `baseValue` prop on `<Area />`, but acts as a fallback:
1203
+ * item-level `Area.baseValue` takes precedence over the chart-level `baseValue`.
1204
+ *
1205
+ * Ignored for stacked areas and for ranged areas where `dataKey` already returns `[min, max]` tuples.
1206
+ *
1207
+ * Note that the baseValue does not interact with `animationInterpolateFn`;
1208
+ * baseValue is always animated by linear interpolation.
1209
+ * If you want a custom animation then have your `dataKey` return a tuple of two values instead of a single number
1210
+ * which will also render a ranged Area, and that does work with your custom `animationInterpolateFn`.
1211
+ */
1212
+ baseValue?: BaseValue;
1213
+ compact?: boolean;
1214
+ dataKey?: DataKey<any>;
1215
+ /**
1216
+ * The layout of chart defines the orientation of axes, graphical items, and tooltip.
1217
+ *
1218
+ * @defaultValue horizontal
1219
+ */
1220
+ layout?: CartesianLayout;
1221
+ /**
1222
+ * The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart.
1223
+ */
1224
+ maxBarSize?: number;
1225
+ /**
1226
+ * If `false`, stacked items will be rendered left to right.
1227
+ * If `true`, stacked items will be rendered right to left.
1228
+ *
1229
+ * Render direction affects SVG layering, not x position.
1230
+ *
1231
+ * @defaultValue false
1232
+ */
1233
+ reverseStackOrder?: boolean;
1234
+ /**
1235
+ * The ARIA role for the chart, which provides semantic information for screen reader users.
1236
+ */
1237
+ role?: string;
1238
+ /**
1239
+ * The type of offset function used to generate the lower and upper values in the series array.
1240
+ * The types are built-in offsets in d3-shape.
1241
+ * Only applicable for stacked Area or Bar charts.
1242
+ * Has no effect when the stackId prop is not set on Area or Bar components.
1243
+ *
1244
+ * @link https://d3js.org/d3-shape/stack#stack_offset
1245
+ * @see {@link https://recharts.github.io/en-US/examples/BarChartStackedBySign/ Chart with stackOffset=sign example}
1246
+ *
1247
+ * @defaultValue none
1248
+ */
1249
+ stackOffset?: StackOffsetType;
1250
+ title?: string;
1251
+ }
1252
+
1253
+ export interface PolarChartProps<DataPointType = unknown>
1254
+ extends BaseChartProps<DataPointType>, EventThrottlingProps {
1255
+ /**
1256
+ * The gap between two bar categories, which can be a percent value or a fixed value.
1257
+ *
1258
+ * @defaultValue 10%
1259
+ */
1260
+ barCategoryGap?: number | string;
1261
+ /**
1262
+ * The gap between two bars in the same category.
1263
+ *
1264
+ * @defaultValue 4
1265
+ */
1266
+ barGap?: number | string;
1267
+ /**
1268
+ * The width or height of each bar. If the barSize is not specified, the size of the
1269
+ * bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
1270
+ */
1271
+ barSize?: number | string;
1272
+ /**
1273
+ * The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width.
1274
+ * @defaultValue 50%
1275
+ */
1276
+ cx?: number | string;
1277
+ /**
1278
+ * The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height.
1279
+ * @defaultValue 50%
1280
+ */
1281
+ cy?: number | string;
1282
+ dataKey?: DataKey<any>;
1283
+ /**
1284
+ * Angle, in degrees, at which the chart should end.
1285
+ */
1286
+ endAngle?: number;
1287
+ /**
1288
+ * The inner radius of the chart.
1289
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
1290
+ * @defaultValue 0
1291
+ */
1292
+ innerRadius?: number | string;
1293
+ /**
1294
+ * The layout of chart defines the orientation of axes, graphical items, and tooltip.
1295
+ */
1296
+ layout?: PolarLayout;
1297
+ maxBarSize?: number;
1298
+ /**
1299
+ * The outer radius of the chart.
1300
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
1301
+ * @defaultValue 80%
1302
+ */
1303
+ outerRadius?: number | string;
1304
+ reverseStackOrder?: boolean;
1305
+ role?: string;
1306
+ stackOffset?: StackOffsetType;
1307
+ /**
1308
+ * Angle in degrees from which the chart should start.
1309
+ */
1310
+ startAngle?: number;
1311
+ title?: string;
1312
+ }
1313
+
1314
+ export type Percent = `${number}%`;
1315
+
1316
+ export type NonEmptyArray<T> = readonly [T, ...T[]];
1317
+
1318
+ export const isNonEmptyArray = <T>(
1319
+ arr: ReadonlyArray<T> | null | undefined,
1320
+ ): arr is NonEmptyArray<T> => Array.isArray(arr) && arr.length > 0;