@solidports/recharts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/LICENSE +22 -0
  2. package/NOTICE +19 -0
  3. package/README.md +102 -0
  4. package/dist/dev.js +28564 -0
  5. package/dist/index.d.ts +7859 -0
  6. package/dist/index.js +28546 -0
  7. package/package.json +98 -0
  8. package/src/animation/AnimatedItems.tsx +183 -0
  9. package/src/animation/AnimationController.ts +33 -0
  10. package/src/animation/AnimationControllerImpl.ts +36 -0
  11. package/src/animation/AnimationHandle.ts +307 -0
  12. package/src/animation/CSSTransitionAnimate.tsx +170 -0
  13. package/src/animation/JavascriptAnimate.tsx +119 -0
  14. package/src/animation/easing.ts +221 -0
  15. package/src/animation/matchBy.ts +164 -0
  16. package/src/animation/timeoutController.ts +70 -0
  17. package/src/animation/useAnimationController.tsx +34 -0
  18. package/src/animation/useAnimationStartSnapshot.ts +118 -0
  19. package/src/animation/util.ts +41 -0
  20. package/src/cartesian/Area.tsx +915 -0
  21. package/src/cartesian/AreaRevealShape.tsx +190 -0
  22. package/src/cartesian/Bar.tsx +1369 -0
  23. package/src/cartesian/BarStack.tsx +152 -0
  24. package/src/cartesian/Brush.tsx +951 -0
  25. package/src/cartesian/CartesianAxis.tsx +722 -0
  26. package/src/cartesian/CartesianGrid.tsx +711 -0
  27. package/src/cartesian/ErrorBar.tsx +361 -0
  28. package/src/cartesian/Funnel.tsx +803 -0
  29. package/src/cartesian/GraphicalItemClipPath.tsx +67 -0
  30. package/src/cartesian/Line.tsx +863 -0
  31. package/src/cartesian/LineDrawShape.tsx +89 -0
  32. package/src/cartesian/ReferenceArea.tsx +331 -0
  33. package/src/cartesian/ReferenceDot.tsx +304 -0
  34. package/src/cartesian/ReferenceLine.tsx +474 -0
  35. package/src/cartesian/Scatter.tsx +888 -0
  36. package/src/cartesian/XAxis.tsx +433 -0
  37. package/src/cartesian/YAxis.tsx +443 -0
  38. package/src/cartesian/ZAxis.tsx +155 -0
  39. package/src/cartesian/cartesianPositionToCSSTranslate.tsx +29 -0
  40. package/src/cartesian/cartesianViewBoxToTrapezoid.tsx +21 -0
  41. package/src/cartesian/getCartesianPosition.tsx +267 -0
  42. package/src/cartesian/getEquidistantTicks.ts +144 -0
  43. package/src/cartesian/getTicks.ts +225 -0
  44. package/src/cartesian/isOutsidePosition.ts +15 -0
  45. package/src/cartesian/useAnimatedLineLength.ts +54 -0
  46. package/src/chart/AreaChart.tsx +29 -0
  47. package/src/chart/BarChart.tsx +29 -0
  48. package/src/chart/CartesianChart.tsx +131 -0
  49. package/src/chart/CategoricalChart.tsx +94 -0
  50. package/src/chart/ComposedChart.tsx +29 -0
  51. package/src/chart/FunnelChart.tsx +29 -0
  52. package/src/chart/LineChart.tsx +29 -0
  53. package/src/chart/PieChart.tsx +50 -0
  54. package/src/chart/PolarChart.tsx +164 -0
  55. package/src/chart/RadarChart.tsx +70 -0
  56. package/src/chart/RadialBarChart.tsx +46 -0
  57. package/src/chart/RechartsWrapper.tsx +551 -0
  58. package/src/chart/Sankey.tsx +1534 -0
  59. package/src/chart/ScatterChart.tsx +29 -0
  60. package/src/chart/SunburstChart.tsx +504 -0
  61. package/src/chart/Treemap.tsx +1223 -0
  62. package/src/chart/createInitialRootProps.ts +24 -0
  63. package/src/chart/types.ts +53 -0
  64. package/src/component/ActivePoints.tsx +144 -0
  65. package/src/component/Cell.tsx +37 -0
  66. package/src/component/Cursor.tsx +185 -0
  67. package/src/component/Customized.tsx +50 -0
  68. package/src/component/DefaultLegendContent.tsx +348 -0
  69. package/src/component/DefaultTooltipContent.tsx +224 -0
  70. package/src/component/Dots.tsx +157 -0
  71. package/src/component/Label.tsx +636 -0
  72. package/src/component/LabelList.tsx +375 -0
  73. package/src/component/Legend.tsx +512 -0
  74. package/src/component/ResponsiveContainer.tsx +348 -0
  75. package/src/component/Text.tsx +541 -0
  76. package/src/component/Tooltip.tsx +470 -0
  77. package/src/component/TooltipBoundingBox.tsx +146 -0
  78. package/src/component/responsiveContainerUtils.ts +134 -0
  79. package/src/container/ClipPathProvider.tsx +51 -0
  80. package/src/container/Layer.tsx +38 -0
  81. package/src/container/RootSurface.tsx +120 -0
  82. package/src/container/Surface.tsx +61 -0
  83. package/src/context/CellsContext.tsx +54 -0
  84. package/src/context/ErrorBarContext.tsx +146 -0
  85. package/src/context/GraphicalItemChildrenScope.tsx +18 -0
  86. package/src/context/PanoramaContext.tsx +9 -0
  87. package/src/context/RegisterGraphicalItemId.tsx +30 -0
  88. package/src/context/accessibilityContext.tsx +6 -0
  89. package/src/context/brushUpdateContext.tsx +9 -0
  90. package/src/context/chartDataContext.tsx +97 -0
  91. package/src/context/chartLayoutContext.tsx +201 -0
  92. package/src/context/legendPayloadContext.tsx +20 -0
  93. package/src/context/legendPortalContext.tsx +12 -0
  94. package/src/context/tooltipContext.tsx +89 -0
  95. package/src/context/tooltipPortalContext.tsx +12 -0
  96. package/src/context/useTooltipAxis.ts +22 -0
  97. package/src/hooks.ts +476 -0
  98. package/src/index.ts +280 -0
  99. package/src/polar/Pie.tsx +1360 -0
  100. package/src/polar/PolarAngleAxis.tsx +616 -0
  101. package/src/polar/PolarGrid.tsx +312 -0
  102. package/src/polar/PolarRadiusAxis.tsx +547 -0
  103. package/src/polar/Radar.tsx +734 -0
  104. package/src/polar/RadialBar.tsx +917 -0
  105. package/src/polar/defaultPolarAngleAxisProps.tsx +27 -0
  106. package/src/polar/defaultPolarRadiusAxisProps.tsx +25 -0
  107. package/src/shape/Cross.tsx +89 -0
  108. package/src/shape/Curve.tsx +343 -0
  109. package/src/shape/Dot.tsx +70 -0
  110. package/src/shape/Polygon.tsx +195 -0
  111. package/src/shape/Rectangle.tsx +470 -0
  112. package/src/shape/Sector.tsx +347 -0
  113. package/src/shape/Symbols.tsx +139 -0
  114. package/src/shape/Trapezoid.tsx +280 -0
  115. package/src/state/RechartsStateContext.tsx +12 -0
  116. package/src/state/RechartsStateProvider.tsx +87 -0
  117. package/src/state/RechartsStoreContext.tsx +25 -0
  118. package/src/state/RechartsStoreProvider.tsx +35 -0
  119. package/src/state/ReportChartProps.tsx +40 -0
  120. package/src/state/ReportEventSettings.tsx +30 -0
  121. package/src/state/ReportMainChartProps.tsx +61 -0
  122. package/src/state/ReportPolarOptions.tsx +35 -0
  123. package/src/state/SetGraphicalItem.ts +79 -0
  124. package/src/state/SetLegendPayload.ts +134 -0
  125. package/src/state/SetTooltipEntrySettings.tsx +72 -0
  126. package/src/state/actions.ts +464 -0
  127. package/src/state/brushSlice.ts +13 -0
  128. package/src/state/cartesianAxisSlice.ts +141 -0
  129. package/src/state/chartDataSlice.ts +50 -0
  130. package/src/state/chartState.ts +297 -0
  131. package/src/state/errorBarSlice.ts +29 -0
  132. package/src/state/eventSettingsSlice.ts +8 -0
  133. package/src/state/events.ts +76 -0
  134. package/src/state/externalEventsMiddleware.ts +255 -0
  135. package/src/state/graphicalItemsSlice.ts +74 -0
  136. package/src/state/hooks/useChartSelectors.tsx +45 -0
  137. package/src/state/keyboardEventsMiddleware.ts +228 -0
  138. package/src/state/layoutSlice.ts +21 -0
  139. package/src/state/legendSlice.ts +57 -0
  140. package/src/state/mouseEventsMiddleware.ts +185 -0
  141. package/src/state/optionsSlice.ts +47 -0
  142. package/src/state/polarAxisSlice.ts +10 -0
  143. package/src/state/polarOptionsSlice.ts +12 -0
  144. package/src/state/rawData.ts +26 -0
  145. package/src/state/referenceElementsSlice.ts +40 -0
  146. package/src/state/renderedTicksSlice.ts +15 -0
  147. package/src/state/rootPropsSlice.ts +47 -0
  148. package/src/state/selectors/areaSelectors.ts +240 -0
  149. package/src/state/selectors/arrayEqualityCheck.ts +29 -0
  150. package/src/state/selectors/axisSelectors.ts +2157 -0
  151. package/src/state/selectors/barSelectors.ts +310 -0
  152. package/src/state/selectors/barStackSelectors.ts +77 -0
  153. package/src/state/selectors/brushSelectors.ts +33 -0
  154. package/src/state/selectors/chartSelector.ts +185 -0
  155. package/src/state/selectors/combiners/combineActiveLabel.ts +16 -0
  156. package/src/state/selectors/combiners/combineActiveTooltipIndex.ts +95 -0
  157. package/src/state/selectors/combiners/combineAllBarPositions.ts +122 -0
  158. package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +16 -0
  159. package/src/state/selectors/combiners/combineBarPosition.ts +23 -0
  160. package/src/state/selectors/combiners/combineBarSizeList.ts +80 -0
  161. package/src/state/selectors/combiners/combineCheckedDomain.ts +48 -0
  162. package/src/state/selectors/combiners/combineConfiguredScale.ts +111 -0
  163. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +45 -0
  164. package/src/state/selectors/combiners/combineDisplayedStackedData.ts +50 -0
  165. package/src/state/selectors/combiners/combineInverseScaleFunction.ts +16 -0
  166. package/src/state/selectors/combiners/combineRealScaleType.ts +44 -0
  167. package/src/state/selectors/combiners/combineStackedData.ts +27 -0
  168. package/src/state/selectors/combiners/combineTooltipInteractionState.ts +86 -0
  169. package/src/state/selectors/combiners/combineTooltipPayload.ts +205 -0
  170. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts +58 -0
  171. package/src/state/selectors/containerSelectors.ts +12 -0
  172. package/src/state/selectors/dataSelectors.ts +88 -0
  173. package/src/state/selectors/funnelSelectors.ts +75 -0
  174. package/src/state/selectors/graphicalItemSelectors.ts +30 -0
  175. package/src/state/selectors/legendSelectors.ts +29 -0
  176. package/src/state/selectors/lineSelectors.ts +134 -0
  177. package/src/state/selectors/numberDomainEqualityCheck.ts +14 -0
  178. package/src/state/selectors/pickAxisId.ts +5 -0
  179. package/src/state/selectors/pickAxisType.ts +3 -0
  180. package/src/state/selectors/pieSelectors.ts +97 -0
  181. package/src/state/selectors/polarAxisSelectors.ts +201 -0
  182. package/src/state/selectors/polarGridSelectors.ts +28 -0
  183. package/src/state/selectors/polarScaleSelectors.ts +133 -0
  184. package/src/state/selectors/polarSelectors.ts +219 -0
  185. package/src/state/selectors/radarSelectors.ts +191 -0
  186. package/src/state/selectors/radialBarSelectors.ts +435 -0
  187. package/src/state/selectors/rootPropsSelectors.ts +25 -0
  188. package/src/state/selectors/scatterSelectors.ts +96 -0
  189. package/src/state/selectors/selectActivePropsFromChartPointer.ts +26 -0
  190. package/src/state/selectors/selectAllAxes.ts +17 -0
  191. package/src/state/selectors/selectChartOffset.ts +16 -0
  192. package/src/state/selectors/selectChartOffsetInternal.ts +136 -0
  193. package/src/state/selectors/selectLegendArea.ts +20 -0
  194. package/src/state/selectors/selectPlotArea.ts +22 -0
  195. package/src/state/selectors/selectTooltipAxisId.ts +7 -0
  196. package/src/state/selectors/selectTooltipAxisType.ts +32 -0
  197. package/src/state/selectors/selectTooltipEventType.ts +48 -0
  198. package/src/state/selectors/selectTooltipPayloadSearcher.ts +6 -0
  199. package/src/state/selectors/selectTooltipSettings.ts +39 -0
  200. package/src/state/selectors/selectTooltipState.ts +8 -0
  201. package/src/state/selectors/selectors.ts +271 -0
  202. package/src/state/selectors/tooltipSelectors.ts +578 -0
  203. package/src/state/selectors/touchSelectors.ts +31 -0
  204. package/src/state/store.ts +29 -0
  205. package/src/state/storeIdentity.ts +9 -0
  206. package/src/state/teardownWrite.ts +10 -0
  207. package/src/state/tooltipInteraction.ts +23 -0
  208. package/src/state/tooltipSlice.ts +334 -0
  209. package/src/state/touchEventsMiddleware.ts +214 -0
  210. package/src/state/types/AnimationSettings.ts +20 -0
  211. package/src/state/types/AreaSettings.ts +14 -0
  212. package/src/state/types/BarSettings.ts +15 -0
  213. package/src/state/types/LineSettings.ts +9 -0
  214. package/src/state/types/PieSettings.ts +34 -0
  215. package/src/state/types/RadarSettings.ts +5 -0
  216. package/src/state/types/RadialBarSettings.ts +10 -0
  217. package/src/state/types/ScatterSettings.ts +12 -0
  218. package/src/state/types/StackedGraphicalItem.ts +34 -0
  219. package/src/state/useChartState.ts +17 -0
  220. package/src/state/zIndexSlice.ts +39 -0
  221. package/src/synchronisation/syncSelectors.ts +7 -0
  222. package/src/synchronisation/types.ts +44 -0
  223. package/src/synchronisation/useChartSynchronisation.tsx +404 -0
  224. package/src/theme/RechartsTheme.ts +16 -0
  225. package/src/theme/RechartsThemeContext.ts +19 -0
  226. package/src/theme/darkTheme.ts +13 -0
  227. package/src/theme/graphicalItemIdentity.ts +70 -0
  228. package/src/theme/legacyTheme.ts +17 -0
  229. package/src/theme/lightTheme.ts +13 -0
  230. package/src/types.ts +54 -0
  231. package/src/util/ActiveShapeUtils.tsx +162 -0
  232. package/src/util/BarUtils.tsx +62 -0
  233. package/src/util/BarePortal.tsx +50 -0
  234. package/src/util/CamelCaseSVGAttrs.ts +34 -0
  235. package/src/util/CartesianUtils.ts +48 -0
  236. package/src/util/ChartUtils.ts +802 -0
  237. package/src/util/Constants.ts +42 -0
  238. package/src/util/CssPrefixUtils.ts +20 -0
  239. package/src/util/DOMUtils.ts +129 -0
  240. package/src/util/DataUtils.ts +216 -0
  241. package/src/util/Events.ts +16 -0
  242. package/src/util/FunnelUtils.tsx +15 -0
  243. package/src/util/Global.ts +12 -0
  244. package/src/util/IfOverflow.ts +15 -0
  245. package/src/util/LRUCache.ts +41 -0
  246. package/src/util/LogUtils.ts +22 -0
  247. package/src/util/PolarUtils.ts +132 -0
  248. package/src/util/RadialBarUtils.tsx +24 -0
  249. package/src/util/ReactUtils.ts +95 -0
  250. package/src/util/ReduceCSSCalc.ts +187 -0
  251. package/src/util/ScatterUtils.tsx +52 -0
  252. package/src/util/ShapeElementProps.tsx +87 -0
  253. package/src/util/TickUtils.ts +60 -0
  254. package/src/util/XAxisUtils.ts +48 -0
  255. package/src/util/YAxisUtils.ts +48 -0
  256. package/src/util/axisPropsAreEqual.ts +48 -0
  257. package/src/util/createCartesianCharts.tsx +150 -0
  258. package/src/util/createEventProxy.ts +20 -0
  259. package/src/util/createPolarCharts.tsx +112 -0
  260. package/src/util/cursor/getCursorPoints.ts +46 -0
  261. package/src/util/cursor/getCursorRectangle.ts +28 -0
  262. package/src/util/cursor/getRadialCursorPoints.ts +32 -0
  263. package/src/util/excludeEventProps.ts +171 -0
  264. package/src/util/getActiveCoordinate.ts +213 -0
  265. package/src/util/getAxisTypeBasedOnLayout.ts +21 -0
  266. package/src/util/getClassNameFromUnknown.ts +6 -0
  267. package/src/util/getEveryNth.ts +27 -0
  268. package/src/util/getRadiusAndStrokeWidthFromDot.ts +35 -0
  269. package/src/util/getRelativeCoordinate.ts +80 -0
  270. package/src/util/getSliced.ts +13 -0
  271. package/src/util/hoverDedupe.ts +41 -0
  272. package/src/util/isDomainSpecifiedByUser.ts +219 -0
  273. package/src/util/isWellBehavedNumber.ts +7 -0
  274. package/src/util/pathTotalLength.ts +25 -0
  275. package/src/util/payload/getUniqPayload.ts +28 -0
  276. package/src/util/propsAreEqual.ts +121 -0
  277. package/src/util/resolveDefaultProps.ts +161 -0
  278. package/src/util/round.ts +32 -0
  279. package/src/util/scale/CartesianScaleHelper.ts +72 -0
  280. package/src/util/scale/CustomScaleDefinition.ts +81 -0
  281. package/src/util/scale/RechartsScale.ts +130 -0
  282. package/src/util/scale/createCategoricalInverse.ts +72 -0
  283. package/src/util/scale/getNiceTickValues.ts +311 -0
  284. package/src/util/scale/index.ts +2 -0
  285. package/src/util/scale/util/arithmetic.ts +54 -0
  286. package/src/util/solid-1-compat.ts +310 -0
  287. package/src/util/solidJsxCamelAugment.d.ts +84 -0
  288. package/src/util/stacks/getStackSeriesIdentifier.ts +21 -0
  289. package/src/util/stacks/stackTypes.ts +60 -0
  290. package/src/util/structurallyEqual.ts +31 -0
  291. package/src/util/svgPropertiesAndEvents.ts +53 -0
  292. package/src/util/svgPropertiesNoEvents.ts +571 -0
  293. package/src/util/tooltip/translate.ts +171 -0
  294. package/src/util/typedDataKey.ts +48 -0
  295. package/src/util/types.ts +1560 -0
  296. package/src/util/useAnimationId.ts +31 -0
  297. package/src/util/useElementOffset.ts +110 -0
  298. package/src/util/useId.ts +8 -0
  299. package/src/util/usePrefersReducedMotion.ts +48 -0
  300. package/src/util/useReportScale.ts +24 -0
  301. package/src/util/useUniqueId.ts +30 -0
  302. package/src/zIndex/DefaultZIndexes.ts +84 -0
  303. package/src/zIndex/ZIndexLayer.tsx +121 -0
  304. package/src/zIndex/ZIndexPortal.tsx +79 -0
  305. package/src/zIndex/getZIndexFromUnknown.ts +14 -0
  306. package/src/zIndex/zIndexSelectors.ts +48 -0
@@ -0,0 +1,1560 @@
1
+ /* eslint-disable import/no-cycle */
2
+ import type { JSX } from '@solidjs/web';
3
+ import type { NiceTicksAlgorithm } from "../state/cartesianAxisSlice"
4
+ import type { Props as DotProps } from "../shape/Dot"
5
+ import { AxisRange } from "../state/selectors/axisSelectors"
6
+ import { ExternalMouseEvents } from "../chart/types"
7
+ import { SyncMethod } from "../synchronisation/types"
8
+ import { isEventKey } from "./excludeEventProps"
9
+ import { DotPoint } from "../component/Dots"
10
+ import { camelizeSvgPropsForHandler, ownStringKeys, SVGPropsNoEvents } from "./svgPropertiesNoEvents"
11
+ import type { CamelCaseSVGAttrs } from "./CamelCaseSVGAttrs"
12
+ import { BaseValue } from "../cartesian/Area"
13
+ import { ImplicitLabelType } from "../component/Label"
14
+ import { CustomScaleDefinition } from "./scale/CustomScaleDefinition"
15
+ import { ChartData } from "../state/chartDataSlice"
16
+ import {
17
+ XAxisOrientation,
18
+ XAxisPadding,
19
+ YAxisOrientation,
20
+ YAxisPadding,
21
+ } from "../state/cartesianAxisSlice"
22
+ import { TextAnchor, TextVerticalAnchor } from "../component/Text"
23
+ import type { TickFormatter } from "../cartesian/CartesianAxis"
24
+ import { TextProps } from "../index"
25
+ import { TypedDataKey } from "./typedDataKey"
26
+
27
+ /**
28
+ * Determines how values are stacked:
29
+ *
30
+ * - `none` is the default, it adds values on top of each other. No smarts. Negative values will overlap.
31
+ * - `expand` make it so that the values always add up to 1 - so the chart will look like a rectangle.
32
+ * - `wiggle` and `silhouette` tries to keep the chart centered.
33
+ * - `sign` stacks positive values above zero and negative values below zero. Similar to `none` but handles negatives.
34
+ * - `positive` ignores all negative values, and then behaves like \`none\`.
35
+ *
36
+ * @see {@link https://d3js.org/d3-shape/stack#stack-offsets}
37
+ * (note that the `diverging` offset in d3 is named `sign` in recharts)
38
+ *
39
+ * @inline
40
+ */
41
+ export type StackOffsetType = "sign" | "expand" | "none" | "wiggle" | "silhouette" | "positive"
42
+ export type CartesianLayout = "horizontal" | "vertical"
43
+ export type PolarLayout = "centric" | "radial"
44
+ /**
45
+ * @deprecated use either `CartesianLayout` or `PolarLayout` instead.
46
+ * Mixing both charts families leads to ambiguity in the type system.
47
+ * These two layouts share very few properties, so it is best to keep them separate.
48
+ */
49
+ export type LayoutType = CartesianLayout | PolarLayout
50
+ export type AxisType = "xAxis" | "yAxis" | "zAxis" | "angleAxis" | "radiusAxis"
51
+
52
+ /**
53
+ * The type of axis.
54
+ *
55
+ * `category`: Treats data as distinct values.
56
+ * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
57
+ *
58
+ * `number`: Treats data as continuous range.
59
+ * Values that are numerically closer are placed closer together on the axis.
60
+ *
61
+ * `auto`: the type is inferred based on the chart layout.
62
+ *
63
+ * This is external type - users will provide this type in props.
64
+ * Internally we will evaluate it to either 'category' or 'number' based on the layout,
65
+ * before sending it to the store.
66
+ *
67
+ * @inline
68
+ */
69
+ export type AxisDomainTypeInput = "number" | "category" | "auto"
70
+
71
+ /**
72
+ * Individual axes are responsible for resolving the 'auto' type to either 'number' or 'category',
73
+ * based on the chart layout and axis kind. Then they can start using this type.
74
+ */
75
+ export type EvaluatedAxisDomainType = "number" | "category"
76
+
77
+ /**
78
+ * Extracts values from data objects.
79
+ *
80
+ * @inline
81
+ */
82
+ /* eslint-disable-next-line typescript-eslint/no-explicit-any -- recharts public API contract: DataValueType defaults to any so downstream charts can pass unconstrained value extractors without ceremony */
83
+ export type DataKey<DataPointType, DataValueType = any> = TypedDataKey<DataPointType, DataValueType>
84
+
85
+ /*
86
+ * 1:1 React parity — upstream recharts API is camelCase (`fillOpacity`, `strokeWidth`)
87
+ * but Solid's `JSX.SvgSVGAttributes` only declares kebab-case. `CamelCaseSVGAttrs`
88
+ * is intersected so users may pass either form at the public chart-component surface.
89
+ * Runtime rekeys camel → kebab via `SVG_CAMEL_TO_KEBAB`.
90
+ */
91
+ /*
92
+ * Solid's attribute types admit `false` (its `RemoveAttribute`) on string-valued SVG
93
+ * attributes; React's `SVGProps` (the upstream contract) do not. Strip it there and keep
94
+ * it on genuinely boolean attributes.
95
+ */
96
+ export type WithoutRemoveFalse<A> = {
97
+ [K in keyof A]: K extends "children" ? A[K] : string extends NonNullable<A[K]> ? Exclude<A[K], false> : A[K]
98
+ }
99
+
100
+ export type PresentationAttributesWithProps<P, T extends Element> = WithoutRemoveFalse<JSX.AriaAttributes> &
101
+ DOMAttributesWithProps<P, T> &
102
+ WithoutRemoveFalse<Omit<JSX.SvgSVGAttributes<T>, keyof DOMAttributesWithProps<P, T>>> &
103
+ CamelCaseSVGAttrs
104
+
105
+ export type PresentationAttributesAdaptChildEvent<P, T extends Element> = WithoutRemoveFalse<JSX.AriaAttributes> &
106
+ DOMAttributesAdaptChildEvent<P, T> &
107
+ WithoutRemoveFalse<Omit<JSX.SvgSVGAttributes<T>, keyof DOMAttributesAdaptChildEvent<P, T>>> &
108
+ CamelCaseSVGAttrs
109
+
110
+ /**
111
+ * @inline
112
+ */
113
+ export type SymbolType = "circle" | "cross" | "diamond" | "square" | "star" | "triangle" | "wye"
114
+
115
+ /**
116
+ * @inline
117
+ */
118
+ export type LegendType =
119
+ | "circle"
120
+ | "cross"
121
+ | "diamond"
122
+ | "line"
123
+ | "plainline"
124
+ | "rect"
125
+ | "square"
126
+ | "star"
127
+ | "triangle"
128
+ | "wye"
129
+ | "none"
130
+ export type TooltipType = "none"
131
+
132
+ export type AllowInDimension = {
133
+ x?: boolean
134
+ y?: boolean
135
+ }
136
+
137
+ export interface Coordinate {
138
+ x: number
139
+ y: number
140
+ }
141
+
142
+ export interface NullableCoordinate {
143
+ x: number | null
144
+ y: number | null
145
+ }
146
+
147
+ export type RectangleCoordinate = {
148
+ x1: number
149
+ y1: number
150
+ x2: number
151
+ y2: number
152
+ }
153
+
154
+ export type RectanglePosition = {
155
+ x: number
156
+ y: number
157
+ width: number
158
+ height: number
159
+ }
160
+
161
+ /**
162
+ * @deprecated do not use: too many properties, mixing too many concepts, cartesian and polar together, everything optional.
163
+ * Instead, use either `Coordinate` or `PolarCoordinate`.
164
+ */
165
+ export interface ChartCoordinate extends Coordinate {
166
+ /* eslint-disable typescript-eslint/no-explicit-any -- axis runtime values are heterogeneous (BaseAxisWithScale | undefined | numeric); narrowing breaks Pie/Polar consumers */
167
+ xAxis?: any
168
+ yAxis?: any
169
+ width?: any
170
+ height?: any
171
+ /* eslint-enable typescript-eslint/no-explicit-any */
172
+ offset?: ChartOffsetInternal
173
+ angle?: number
174
+ radius?: number
175
+ cx?: number
176
+ cy?: number
177
+ startAngle?: number
178
+ endAngle?: number
179
+ innerRadius?: number
180
+ outerRadius?: number
181
+ }
182
+
183
+ export type PolarCoordinate = Coordinate & {
184
+ angle: number
185
+ startAngle: number
186
+ endAngle: number
187
+ clockWise: boolean
188
+ cx: number
189
+ cy: number
190
+ innerRadius: number
191
+ outerRadius: number
192
+ radius: number
193
+ }
194
+
195
+ export const isPolarCoordinate = (c: Coordinate | PolarCoordinate): c is PolarCoordinate => {
196
+ return "radius" in c && "startAngle" in c && "endAngle" in c
197
+ }
198
+
199
+ export type D3ScaleType =
200
+ | "linear"
201
+ | "pow"
202
+ | "sqrt"
203
+ | "log"
204
+ | "symlog"
205
+ | "identity"
206
+ | "time"
207
+ | "band"
208
+ | "point"
209
+ | "ordinal"
210
+ | "quantile"
211
+ | "quantize"
212
+ | "utc"
213
+ | "sequential"
214
+ | "threshold"
215
+
216
+ /** Upstream name for the scale shortcut strings. */
217
+ export type RechartsScaleType = D3ScaleType
218
+
219
+ /**
220
+ * String shortcuts for scale types.
221
+ * In case none of these does what you want you can also provide your own scale function
222
+ * @see {@link CustomScaleDefinition}
223
+ */
224
+ export type ScaleType = "auto" | D3ScaleType
225
+
226
+ /*
227
+ * Event Handler Types -- Solid uses native DOM events directly.
228
+ * The P generic carries recharts-specific props passed to the handler alongside the event.
229
+ */
230
+
231
+ type EventHandler<P, E extends Event> = {
232
+ bivarianceHack(props: P, event: E): void
233
+ }["bivarianceHack"]
234
+
235
+ type GenericEventHandler<P> = EventHandler<P, Event>
236
+ type ClipboardEventHandler<P> = EventHandler<P, ClipboardEvent>
237
+ type CompositionEventHandler<P> = EventHandler<P, CompositionEvent>
238
+ type DragEventHandler<P> = EventHandler<P, DragEvent>
239
+ type FocusEventHandler<P> = EventHandler<P, FocusEvent>
240
+ type InputEventHandler<P> = EventHandler<P, InputEvent>
241
+ type KeyboardEventHandler<P> = EventHandler<P, KeyboardEvent>
242
+ /* currentTarget carries the element type, like React's `MouseEvent<T>`, so handlers can pass the event to getRelativeCoordinate. */
243
+ export type RechartsMouseEventHandler<P, T = Element> = EventHandler<P, MouseEvent & { currentTarget: T }>
244
+ type TouchEventHandler<P, T = Element> = EventHandler<P, TouchEvent & { currentTarget: T }>
245
+ type PointerEventHandler<P, T = Element> = EventHandler<P, PointerEvent & { currentTarget: T }>
246
+ type UIEventHandler<P> = EventHandler<P, UIEvent>
247
+ type WheelEventHandler<P> = EventHandler<P, WheelEvent>
248
+ type AnimationEventHandler<P> = EventHandler<P, AnimationEvent>
249
+ type TransitionEventHandler<P> = EventHandler<P, TransitionEvent>
250
+
251
+ export interface DOMAttributesWithProps<P, T extends Element> {
252
+ children?: JSX.Element
253
+ innerHTML?: string
254
+
255
+ /* Clipboard Events */
256
+ onCopy?: ClipboardEventHandler<P>
257
+ onCut?: ClipboardEventHandler<P>
258
+ onPaste?: ClipboardEventHandler<P>
259
+
260
+ /* Composition Events */
261
+ onCompositionEnd?: CompositionEventHandler<P>
262
+ onCompositionStart?: CompositionEventHandler<P>
263
+ onCompositionUpdate?: CompositionEventHandler<P>
264
+
265
+ /* Focus Events */
266
+ onFocus?: FocusEventHandler<P>
267
+ onBlur?: FocusEventHandler<P>
268
+
269
+ /* Form Events */
270
+ onChange?: GenericEventHandler<P>
271
+ onBeforeInput?: InputEventHandler<P>
272
+ onInput?: InputEventHandler<P>
273
+ onReset?: GenericEventHandler<P>
274
+ onSubmit?: GenericEventHandler<P>
275
+ onInvalid?: GenericEventHandler<P>
276
+
277
+ /* Image Events */
278
+ onLoad?: GenericEventHandler<P>
279
+ onError?: GenericEventHandler<P>
280
+
281
+ /* Keyboard Events */
282
+ onKeyDown?: KeyboardEventHandler<P>
283
+ onKeyPress?: KeyboardEventHandler<P>
284
+ onKeyUp?: KeyboardEventHandler<P>
285
+
286
+ /* Media Events */
287
+ onAbort?: GenericEventHandler<P>
288
+ onCanPlay?: GenericEventHandler<P>
289
+ onCanPlayThrough?: GenericEventHandler<P>
290
+ onDurationChange?: GenericEventHandler<P>
291
+ onEmptied?: GenericEventHandler<P>
292
+ onEncrypted?: GenericEventHandler<P>
293
+ onEnded?: GenericEventHandler<P>
294
+ onLoadedData?: GenericEventHandler<P>
295
+ onLoadedMetadata?: GenericEventHandler<P>
296
+ onLoadStart?: GenericEventHandler<P>
297
+ onPause?: GenericEventHandler<P>
298
+ onPlay?: GenericEventHandler<P>
299
+ onPlaying?: GenericEventHandler<P>
300
+ onProgress?: GenericEventHandler<P>
301
+ onRateChange?: GenericEventHandler<P>
302
+ onSeeked?: GenericEventHandler<P>
303
+ onSeeking?: GenericEventHandler<P>
304
+ onStalled?: GenericEventHandler<P>
305
+ onSuspend?: GenericEventHandler<P>
306
+ onTimeUpdate?: GenericEventHandler<P>
307
+ onVolumeChange?: GenericEventHandler<P>
308
+ onWaiting?: GenericEventHandler<P>
309
+
310
+ /* Mouse Events */
311
+ onAuxClick?: RechartsMouseEventHandler<P, T>
312
+ onClick?: RechartsMouseEventHandler<P, T>
313
+ onContextMenu?: RechartsMouseEventHandler<P, T>
314
+ onDoubleClick?: RechartsMouseEventHandler<P, T>
315
+ onDrag?: DragEventHandler<P>
316
+ onDragEnd?: DragEventHandler<P>
317
+ onDragEnter?: DragEventHandler<P>
318
+ onDragExit?: DragEventHandler<P>
319
+ onDragLeave?: DragEventHandler<P>
320
+ onDragOver?: DragEventHandler<P>
321
+ onDragStart?: DragEventHandler<P>
322
+ onDrop?: DragEventHandler<P>
323
+ /**
324
+ * The customized event handler of mousedown in this chart.
325
+ */
326
+ onMouseDown?: RechartsMouseEventHandler<P, T>
327
+ /**
328
+ * The customized event handler of mouseenter in this chart.
329
+ */
330
+ onMouseEnter?: RechartsMouseEventHandler<P, T>
331
+ /**
332
+ * The customized event handler of mouseleave in this chart.
333
+ */
334
+ onMouseLeave?: RechartsMouseEventHandler<P, T>
335
+ /**
336
+ * The customized event handler of mousemove in this chart.
337
+ */
338
+ onMouseMove?: RechartsMouseEventHandler<P, T>
339
+ /**
340
+ * The customized event handler of mouseout in this chart.
341
+ */
342
+ onMouseOut?: RechartsMouseEventHandler<P, T>
343
+ /**
344
+ * The customized event handler of mouseover in this chart.
345
+ */
346
+ onMouseOver?: RechartsMouseEventHandler<P, T>
347
+ /**
348
+ * The customized event handler of mouseup in this chart.
349
+ */
350
+ onMouseUp?: RechartsMouseEventHandler<P, T>
351
+
352
+ /* Selection Events */
353
+ onSelect?: GenericEventHandler<P>
354
+
355
+ /* Touch Events */
356
+ onTouchCancel?: TouchEventHandler<P, T>
357
+ onTouchEnd?: TouchEventHandler<P, T>
358
+ onTouchMove?: TouchEventHandler<P, T>
359
+ onTouchStart?: TouchEventHandler<P, T>
360
+
361
+ /* Pointer Events */
362
+ onPointerDown?: PointerEventHandler<P, T>
363
+ onPointerMove?: PointerEventHandler<P, T>
364
+ onPointerUp?: PointerEventHandler<P, T>
365
+ onPointerCancel?: PointerEventHandler<P, T>
366
+ onPointerEnter?: PointerEventHandler<P, T>
367
+ onPointerLeave?: PointerEventHandler<P, T>
368
+ onPointerOver?: PointerEventHandler<P, T>
369
+ onPointerOut?: PointerEventHandler<P, T>
370
+ onGotPointerCapture?: PointerEventHandler<P, T>
371
+ onLostPointerCapture?: PointerEventHandler<P, T>
372
+
373
+ /* UI Events */
374
+ onScroll?: UIEventHandler<P>
375
+
376
+ /* Wheel Events */
377
+ onWheel?: WheelEventHandler<P>
378
+
379
+ /* Animation Events */
380
+ onAnimationStart?: AnimationEventHandler<P>
381
+ onAnimationEnd?: AnimationEventHandler<P>
382
+ onAnimationIteration?: AnimationEventHandler<P>
383
+
384
+ /* Transition Events */
385
+ onTransitionEnd?: TransitionEventHandler<P>
386
+ }
387
+
388
+ type AdaptChildEventHandler<P, E extends Event> = {
389
+ bivarianceHack(data: P, index: number, event: E): void
390
+ }["bivarianceHack"]
391
+
392
+ type AdaptChildGenericEventHandler<P> = AdaptChildEventHandler<P, Event>
393
+ type AdaptChildClipboardEventHandler<P> = AdaptChildEventHandler<P, ClipboardEvent>
394
+ type AdaptChildCompositionEventHandler<P> = AdaptChildEventHandler<P, CompositionEvent>
395
+ type AdaptChildDragEventHandler<P> = AdaptChildEventHandler<P, DragEvent>
396
+ type AdaptChildFocusEventHandler<P> = AdaptChildEventHandler<P, FocusEvent>
397
+ type AdaptChildInputEventHandler<P> = AdaptChildEventHandler<P, InputEvent>
398
+ type AdaptChildKeyboardEventHandler<P> = AdaptChildEventHandler<P, KeyboardEvent>
399
+ type AdaptChildMouseEventHandler<P, T = Element> = AdaptChildEventHandler<P, MouseEvent & { currentTarget: T }>
400
+ type AdaptChildTouchEventHandler<P, T = Element> = AdaptChildEventHandler<P, TouchEvent & { currentTarget: T }>
401
+ type AdaptChildPointerEventHandler<P, T = Element> = AdaptChildEventHandler<P, PointerEvent & { currentTarget: T }>
402
+ type AdaptChildUIEventHandler<P> = AdaptChildEventHandler<P, UIEvent>
403
+ type AdaptChildWheelEventHandler<P> = AdaptChildEventHandler<P, WheelEvent>
404
+ type AdaptChildAnimationEventHandler<P> = AdaptChildEventHandler<P, AnimationEvent>
405
+ type AdaptChildTransitionEventHandler<P> = AdaptChildEventHandler<P, TransitionEvent>
406
+
407
+ export type DOMAttributesAdaptChildEvent<P, T extends Element> = {
408
+ children?: JSX.Element
409
+ innerHTML?: string
410
+
411
+ /* Clipboard Events */
412
+ onCopy?: AdaptChildClipboardEventHandler<P>
413
+ onCut?: AdaptChildClipboardEventHandler<P>
414
+ onPaste?: AdaptChildClipboardEventHandler<P>
415
+
416
+ /* Composition Events */
417
+ onCompositionEnd?: AdaptChildCompositionEventHandler<P>
418
+ onCompositionStart?: AdaptChildCompositionEventHandler<P>
419
+ onCompositionUpdate?: AdaptChildCompositionEventHandler<P>
420
+
421
+ /* Focus Events */
422
+ onFocus?: AdaptChildFocusEventHandler<P>
423
+ onBlur?: AdaptChildFocusEventHandler<P>
424
+
425
+ /* Form Events */
426
+ onChange?: AdaptChildGenericEventHandler<P>
427
+ onBeforeInput?: AdaptChildInputEventHandler<P>
428
+ onInput?: AdaptChildInputEventHandler<P>
429
+ onReset?: AdaptChildGenericEventHandler<P>
430
+ onSubmit?: AdaptChildGenericEventHandler<P>
431
+ onInvalid?: AdaptChildGenericEventHandler<P>
432
+
433
+ /* Image Events */
434
+ onLoad?: AdaptChildGenericEventHandler<P>
435
+ onError?: AdaptChildGenericEventHandler<P>
436
+
437
+ /* Keyboard Events */
438
+ onKeyDown?: AdaptChildKeyboardEventHandler<P>
439
+ onKeyPress?: AdaptChildKeyboardEventHandler<P>
440
+ onKeyUp?: AdaptChildKeyboardEventHandler<P>
441
+
442
+ /* Media Events */
443
+ onAbort?: AdaptChildGenericEventHandler<P>
444
+ onCanPlay?: AdaptChildGenericEventHandler<P>
445
+ onCanPlayThrough?: AdaptChildGenericEventHandler<P>
446
+ onDurationChange?: AdaptChildGenericEventHandler<P>
447
+ onEmptied?: AdaptChildGenericEventHandler<P>
448
+ onEncrypted?: AdaptChildGenericEventHandler<P>
449
+ onEnded?: AdaptChildGenericEventHandler<P>
450
+ onLoadedData?: AdaptChildGenericEventHandler<P>
451
+ onLoadedMetadata?: AdaptChildGenericEventHandler<P>
452
+ onLoadStart?: AdaptChildGenericEventHandler<P>
453
+ onPause?: AdaptChildGenericEventHandler<P>
454
+ onPlay?: AdaptChildGenericEventHandler<P>
455
+ onPlaying?: AdaptChildGenericEventHandler<P>
456
+ onProgress?: AdaptChildGenericEventHandler<P>
457
+ onRateChange?: AdaptChildGenericEventHandler<P>
458
+ onSeeked?: AdaptChildGenericEventHandler<P>
459
+ onSeeking?: AdaptChildGenericEventHandler<P>
460
+ onStalled?: AdaptChildGenericEventHandler<P>
461
+ onSuspend?: AdaptChildGenericEventHandler<P>
462
+ onTimeUpdate?: AdaptChildGenericEventHandler<P>
463
+ onVolumeChange?: AdaptChildGenericEventHandler<P>
464
+ onWaiting?: AdaptChildGenericEventHandler<P>
465
+
466
+ /* Mouse Events */
467
+ onAuxClick?: AdaptChildMouseEventHandler<P, T>
468
+ onClick?: AdaptChildMouseEventHandler<P, T>
469
+ onContextMenu?: AdaptChildMouseEventHandler<P, T>
470
+ onDoubleClick?: AdaptChildMouseEventHandler<P, T>
471
+ onDrag?: AdaptChildDragEventHandler<P>
472
+ onDragEnd?: AdaptChildDragEventHandler<P>
473
+ onDragEnter?: AdaptChildDragEventHandler<P>
474
+ onDragExit?: AdaptChildDragEventHandler<P>
475
+ onDragLeave?: AdaptChildDragEventHandler<P>
476
+ onDragOver?: AdaptChildDragEventHandler<P>
477
+ onDragStart?: AdaptChildDragEventHandler<P>
478
+ onDrop?: AdaptChildDragEventHandler<P>
479
+ onMouseDown?: AdaptChildMouseEventHandler<P, T>
480
+ onMouseEnter?: AdaptChildMouseEventHandler<P, T>
481
+ onMouseLeave?: AdaptChildMouseEventHandler<P, T>
482
+ onMouseMove?: AdaptChildMouseEventHandler<P, T>
483
+ onMouseOut?: AdaptChildMouseEventHandler<P, T>
484
+ onMouseOver?: AdaptChildMouseEventHandler<P, T>
485
+ onMouseUp?: AdaptChildMouseEventHandler<P, T>
486
+
487
+ /* Selection Events */
488
+ onSelect?: AdaptChildGenericEventHandler<P>
489
+
490
+ /* Touch Events */
491
+ onTouchCancel?: AdaptChildTouchEventHandler<P, T>
492
+ onTouchEnd?: AdaptChildTouchEventHandler<P, T>
493
+ onTouchMove?: AdaptChildTouchEventHandler<P, T>
494
+ onTouchStart?: AdaptChildTouchEventHandler<P, T>
495
+
496
+ /* Pointer Events */
497
+ onPointerDown?: AdaptChildPointerEventHandler<P, T>
498
+ onPointerMove?: AdaptChildPointerEventHandler<P, T>
499
+ onPointerUp?: AdaptChildPointerEventHandler<P, T>
500
+ onPointerCancel?: AdaptChildPointerEventHandler<P, T>
501
+ onPointerEnter?: AdaptChildPointerEventHandler<P, T>
502
+ onPointerLeave?: AdaptChildPointerEventHandler<P, T>
503
+ onPointerOver?: AdaptChildPointerEventHandler<P, T>
504
+ onPointerOut?: AdaptChildPointerEventHandler<P, T>
505
+ onGotPointerCapture?: AdaptChildPointerEventHandler<P, T>
506
+ onLostPointerCapture?: AdaptChildPointerEventHandler<P, T>
507
+
508
+ /* UI Events */
509
+ onScroll?: AdaptChildUIEventHandler<P>
510
+
511
+ /* Wheel Events */
512
+ onWheel?: AdaptChildWheelEventHandler<P>
513
+
514
+ /* Animation Events */
515
+ onAnimationStart?: AdaptChildAnimationEventHandler<P>
516
+ onAnimationEnd?: AdaptChildAnimationEventHandler<P>
517
+ onAnimationIteration?: AdaptChildAnimationEventHandler<P>
518
+
519
+ /* Transition Events */
520
+ onTransitionEnd?: AdaptChildTransitionEventHandler<P>
521
+ }
522
+
523
+ /**
524
+ * The type of easing function to use for animations
525
+ *
526
+ * @inline
527
+ */
528
+ export type AnimationTiming = "ease" | "ease-in" | "ease-out" | "ease-in-out" | "linear"
529
+ /** Specifies the duration of animation, the unit of this option is ms. */
530
+ export type AnimationDuration = number
531
+
532
+ export type OffsetVertical = {
533
+ top: number
534
+ bottom: number
535
+ }
536
+
537
+ export type OffsetHorizontal = {
538
+ left: number
539
+ right: number
540
+ }
541
+
542
+ /**
543
+ * 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.
544
+ * We use it internally but let's not expose it to the outside world.
545
+ * If you are looking for this information, instead import `ChartOffset` or `PlotArea` from `recharts`.
546
+ */
547
+ export type ChartOffsetInternal = {
548
+ top: number
549
+ bottom: number
550
+ left: number
551
+ right: number
552
+ width: number
553
+ height: number
554
+ brushBottom: number
555
+ }
556
+
557
+ export interface Padding {
558
+ top: number
559
+ bottom: number
560
+ left: number
561
+ right: number
562
+ }
563
+
564
+ export interface GeometrySector {
565
+ cx: number
566
+ cy: number
567
+ innerRadius: number
568
+ outerRadius: number
569
+ startAngle: number
570
+ endAngle: number
571
+ }
572
+
573
+ export type GeometrySectorWithCornerRadius = GeometrySector & {
574
+ cornerRadius: number
575
+ forceCornerRadius: boolean
576
+ cornerIsExternal: boolean
577
+ }
578
+
579
+ export type AxisDomainItem =
580
+ | string
581
+ | number
582
+ | ((d: number) => string | number)
583
+ | "auto"
584
+ | "dataMin"
585
+ | "dataMax"
586
+
587
+ /**
588
+ * The domain of axis.
589
+ * This is the definition
590
+ *
591
+ * Numeric domain is always defined by an array of exactly two values, for the min and the max of the axis.
592
+ * Categorical domain is defined as array of all possible values.
593
+ *
594
+ * Can be specified in many ways:
595
+ * - array of numbers
596
+ * - with special strings like 'dataMin' and 'dataMax'
597
+ * - with special string math like 'dataMin - 100'
598
+ * - with keyword 'auto'
599
+ * - or a function
600
+ * - array of functions
601
+ * - or a combination of the above
602
+ */
603
+ export type AxisDomain =
604
+ | ReadonlyArray<string>
605
+ | ReadonlyArray<number>
606
+ | Readonly<[AxisDomainItem, AxisDomainItem]>
607
+ | (([dataMin, dataMax]: NumberDomain, allowDataOverflow: boolean) => NumberDomain)
608
+
609
+ /**
610
+ * NumberDomain is an evaluated {@link AxisDomain}.
611
+ * Unlike {@link AxisDomain}, it has no variety - it's a tuple of two number.
612
+ * This is after all the keywords and functions were evaluated and what is left is [min, max].
613
+ *
614
+ * Know that the min, max values are not guaranteed to be nice numbers - values like -Infinity or NaN are possible.
615
+ *
616
+ * There are also `category` axes that have different things than numbers in their domain.
617
+ */
618
+ export type NumberDomain = readonly [min: number, max: number]
619
+
620
+ export type CategoricalDomainItem = number | string | Date
621
+
622
+ export type CategoricalDomain = ReadonlyArray<CategoricalDomainItem>
623
+
624
+ export type BaseTickContentProps = {
625
+ angle: number
626
+ className?: string
627
+ fill: string | undefined
628
+ height?: number | string
629
+ index: number
630
+ name?: string
631
+ stroke: string
632
+ payload: CartesianTickItem
633
+ textAnchor: TextAnchor
634
+ tickFormatter: TickFormatter | undefined
635
+ verticalAnchor: TextVerticalAnchor
636
+ visibleTicksCount: number
637
+ width?: number | string
638
+ x: number | string
639
+ y: number | string
640
+ }
641
+
642
+ export type XAxisTickContentProps = BaseTickContentProps & {
643
+ orientation: XAxisOrientation
644
+ padding: XAxisPadding | undefined
645
+ }
646
+
647
+ export type YAxisTickContentProps = BaseTickContentProps & {
648
+ orientation: YAxisOrientation
649
+ padding: YAxisPadding | undefined
650
+ }
651
+
652
+ export type TickProp<T> = TextProps | JSX.Element | ((props: T) => JSX.Element) | boolean
653
+
654
+ export interface BaseAxisProps<DataPointType, DataValueType> extends DataConsumer<
655
+ DataPointType,
656
+ DataValueType
657
+ > {
658
+ /**
659
+ * The type of axis.
660
+ *
661
+ * `category`: Treats data as distinct values.
662
+ * Each value is in the same distance from its neighbors, regardless of their actual numeric difference.
663
+ *
664
+ * `number`: Treats data as continuous range.
665
+ * Values that are numerically closer are placed closer together on the axis.
666
+ *
667
+ * `auto`: the type is inferred based on the chart layout.
668
+ */
669
+ type?: AxisDomainTypeInput
670
+ /**
671
+ * The name of data.
672
+ * This option will be used in tooltip.
673
+ * If no value was set to this option, the value of dataKey will be used alternatively.
674
+ */
675
+ name?: string
676
+ /**
677
+ * The unit of data. This option will be used in tooltip.
678
+ */
679
+ unit?: string
680
+ /**
681
+ * The data that you provide via the `data` prop is an array of objects.
682
+ * Each object can have multiple properties, each representing a different data dimension.
683
+ * Use the `dataKey` prop to specify which property (or dimension) to use for this component.
684
+ *
685
+ * Typically, you will want to have one dataKey on the X axis, and different dataKey on the Y axis,
686
+ * where they extract different values from the same data objects.
687
+ *
688
+ * Decides how to extract the value of this Axis from the data:
689
+ * - `string`: the name of the field in the data object;
690
+ * - `number`: the index of the field in the data;
691
+ * - `function`: a function that receives the data object and returns the value of this Axis.
692
+ *
693
+ * If undefined, it will reuse the dataKey of graphical items.
694
+ */
695
+ dataKey?: DataKey<DataPointType, DataValueType>
696
+ /**
697
+ * Specify the domain of axis when the axis is a number axis.
698
+ *
699
+ * If undefined, then the domain is calculated based on the data and dataKeys.
700
+ *
701
+ * The length of domain should be 2, and we will validate the values in domain.
702
+ *
703
+ * Each element in the array can be a number, 'auto', 'dataMin', 'dataMax', a string like 'dataMin - 20', 'dataMax + 100',
704
+ * or a function that accepts a single argument and returns a number.
705
+ *
706
+ * 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.
707
+ * If a function, receives '[dataMin, dataMax]', and must return a computed domain as '[min, max]'.
708
+ *
709
+ * @example <XAxis type="number" domain={['dataMin', 'dataMax']} />
710
+ * @example <XAxis type="number" domain={[0, 'dataMax']} />
711
+ * @example <XAxis type="number" domain={['auto', 'auto']} />
712
+ * @example <XAxis type="number" domain={[0, 'dataMax + 1000']} />
713
+ * @example <XAxis type="number" domain={['dataMin - 100', 'dataMax + 100']} />
714
+ * @example <XAxis type="number" domain={[dataMin => (0 - Math.abs(dataMin)), dataMax => (dataMax * 2)]} />
715
+ * @example <XAxis type="number" domain={([dataMin, dataMax]) => { const absMax = Math.max(Math.abs(dataMin), Math.abs(dataMax)); return [-absMax, absMax]; }} />
716
+ * @example <XAxis type="number" domain={[0, 100]} allowDataOverflow />
717
+ */
718
+ domain?: AxisDomain
719
+ /**
720
+ * Scale function determines how data values are mapped to visual values.
721
+ * In other words, decided the mapping between data domain and coordinate range.
722
+ *
723
+ * If undefined, or 'auto', the scale function is created internally according to the type of axis and data.
724
+ *
725
+ * You can define a custom scale, either as a string shortcut to a d3 scale, or as a complete scale definition object.
726
+ *
727
+ * @defaultValue auto
728
+ * @example <XAxis scale="log" />
729
+ * @example
730
+ * import { scaleLog } from 'd3-scale';
731
+ * const scale = scaleLog().base(Math.E);
732
+ * <YAxis scale={scale} />
733
+ */
734
+ scale?:
735
+ | ScaleType
736
+ | CustomScaleDefinition
737
+ | CustomScaleDefinition<string>
738
+ | CustomScaleDefinition<number>
739
+ | CustomScaleDefinition<Date>
740
+ }
741
+
742
+ /**
743
+ * Props shared in all renderable axes - meaning the ones that are drawn on the chart,
744
+ * can have ticks, axis line, etc.
745
+ */
746
+ export interface RenderableAxisProps<DataPointType, DataValueType> extends BaseAxisProps<
747
+ DataPointType,
748
+ DataValueType
749
+ > {
750
+ /**
751
+ * Tick text rotation angle in degrees.
752
+ * Positive values rotate clockwise, negative values rotate counterclockwise.
753
+ *
754
+ * @defaultValue 0
755
+ */
756
+ angle?: number
757
+ /**
758
+ * If set true, the axis do not display in the chart.
759
+ *
760
+ * @defaultValue false
761
+ */
762
+ hide?: boolean
763
+ /**
764
+ * Defines how the individual label text is rendered.
765
+ * This controls the settings for individual ticks; on a typical axis, there are multiple ticks, depending on your data.
766
+ *
767
+ * If you want to customize the overall axis label, use the `label` prop instead.
768
+ *
769
+ * Options:
770
+ * - `false`: Do not render any tick labels.
771
+ * - `true`: Render tick labels with default settings.
772
+ * - `object`: An object of props to be merged into the internally calculated tick props.
773
+ * - `JSX.Element`: A custom element to be used as the tick label.
774
+ * - `function`: A function that returns an element for custom rendering of tick labels.
775
+ *
776
+ * @defaultValue true
777
+ */
778
+ tick?: TickProp<unknown>
779
+
780
+ /**
781
+ * The count of axis ticks. Not used if 'type' is 'category'.
782
+ * @defaultValue 5
783
+ */
784
+ tickCount?: number
785
+ /**
786
+ * Controls how Recharts calculates "nice" tick values for this axis.
787
+ * Options: `'none'`, `'auto'`, `'adaptive'`, `'snap125'`.
788
+ * See {@link NiceTicksAlgorithm} for a full description of each option.
789
+ *
790
+ * @defaultValue 'auto'
791
+ * @since 3.8
792
+ */
793
+ niceTicks?: NiceTicksAlgorithm
794
+ /**
795
+ * Determines how the axis line is drawn. Options:
796
+ * - `true`: the axis line is drawn with default props;
797
+ * - `false`: the axis line is not visible;
798
+ * - `object`: passed as props to SVG `<line>` element representing the axis line.
799
+ *
800
+ * @defaultValue true
801
+ */
802
+ axisLine?: boolean | JSX.LineSVGAttributes<SVGLineElement>
803
+
804
+ /**
805
+ * If false set, tick lines will not be drawn.
806
+ * If true set, tick lines will be drawn which have the props calculated internally.
807
+ * If object set, tick lines will be drawn which have the props merged
808
+ * by the internal calculated props and the option.
809
+ * @defaultValue true
810
+ */
811
+ tickLine?: boolean | JSX.LineSVGAttributes<SVGLineElement>
812
+ /**
813
+ * The length of tick line.
814
+ * @defaultValue 6
815
+ */
816
+ tickSize?: number
817
+ /**
818
+ * The formatter function of tick.
819
+ */
820
+ /* eslint-disable-next-line typescript-eslint/no-explicit-any -- tick value is heterogeneous across number/category/time axes; consumers narrow at use site */
821
+ tickFormatter?: (value: any, index: number) => string
822
+ /**
823
+ * When domain of the axis is specified and the type of the axis is 'number',
824
+ * if allowDataOverflow is set to be false,
825
+ * the domain will be adjusted when the minimum value of data is smaller than domain[0] or
826
+ * the maximum value of data is greater than domain[1] so that the axis displays all data values.
827
+ * If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain.
828
+ *
829
+ * @defaultValue false
830
+ */
831
+ allowDataOverflow?: boolean
832
+ /**
833
+ * Allow the axis has duplicated categories or not when the type of axis is "category".
834
+ * @defaultValue true
835
+ */
836
+ allowDuplicatedCategory?: boolean
837
+ /**
838
+ * Allow the ticks of axis to be decimals or not.
839
+ *
840
+ * @defaultValue true
841
+ */
842
+ allowDecimals?: boolean
843
+ /**
844
+ * Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden
845
+ * @defaultValue false
846
+ */
847
+ includeHidden?: boolean
848
+ /**
849
+ * @deprecated Recharts computes the range automatically based on chart width or height
850
+ *
851
+ * Recharts ignores this prop since 3.0
852
+ */
853
+ range?: AxisRange
854
+ /**
855
+ * Defines a single label for the whole axis.
856
+ * This prop renders one label in the center of the axis line.
857
+ * Useful for labeling the axis as a whole, like "Time (in seconds)" or "Distance (in meters)".
858
+ *
859
+ * This is not controlling tick labels.
860
+ * If you want to customize tick labels, please see `tickFormatter` or `tick` props.
861
+ *
862
+ * - `false`: no label is rendered
863
+ * - `string` | `number`: the content of the label
864
+ * - `object`: the props of LabelList component
865
+ * - `JSX.Element`: a custom label element
866
+ * - `function`: a render function of custom label
867
+ *
868
+ * @defaultValue false
869
+ */
870
+ label?: ImplicitLabelType
871
+ /** The HTML element's class name */
872
+ className?: string
873
+ /**
874
+ * If set to true, the ticks of this axis are reversed.
875
+ * @defaultValue false
876
+ */
877
+ reversed?: boolean
878
+ }
879
+
880
+ /** Defines how ticks are placed and whether / how tick collisions are handled.
881
+ * 'preserveStart' keeps the left tick on collision and ensures that the first tick is always shown.
882
+ * 'preserveEnd' keeps the right tick on collision and ensures that the last tick is always shown.
883
+ * 'preserveStartEnd' keeps the left tick on collision and ensures that the first and last ticks always show.
884
+ * 'equidistantPreserveStart' selects a number N such that every nTh tick will be shown without collision.
885
+ * 'equidistantPreserveEnd' selects a number N such that every nTh tick will be shown, ensuring the last tick is always visible.
886
+ */
887
+ export type AxisInterval =
888
+ | number
889
+ | "preserveStart"
890
+ | "preserveEnd"
891
+ | "preserveStartEnd"
892
+ | "equidistantPreserveStart"
893
+ | "equidistantPreserveEnd"
894
+
895
+ /**
896
+ * Ticks can be any type when the axis is the type of category.
897
+ *
898
+ * Ticks must be numbers when the axis is the type of number.
899
+ */
900
+ export type AxisTick = number | string
901
+
902
+ export interface TickItem {
903
+ /* eslint-disable-next-line typescript-eslint/no-explicit-any -- tick value runtime type matches axis type (number/string/Date); narrowing here forces casts at every consumer */
904
+ value: any
905
+ coordinate: number
906
+ index: number
907
+ /**
908
+ * How far this tick is offset from the start of a category band.
909
+ * On axes that do not have bands, this will always be zero.
910
+ *
911
+ * We never read offset internally in Recharts,
912
+ * but it has been part of the external API so let's keep it here for people who do use it.
913
+ */
914
+ offset?: number
915
+ }
916
+
917
+ export interface CartesianTickItem extends TickItem {
918
+ tickCoord?: number
919
+ tickSize?: number
920
+ isShow?: boolean
921
+ }
922
+
923
+ export interface Margin {
924
+ top: number
925
+ right: number
926
+ bottom: number
927
+ left: number
928
+ }
929
+
930
+ /**
931
+ * @inline
932
+ */
933
+ export interface CartesianViewBox {
934
+ x?: number
935
+ y?: number
936
+ width?: number
937
+ height?: number
938
+ }
939
+
940
+ export type CartesianViewBoxRequired = Required<CartesianViewBox>
941
+
942
+ interface PolarViewBox {
943
+ cx?: number
944
+ cy?: number
945
+ innerRadius?: number
946
+ outerRadius?: number
947
+ startAngle?: number
948
+ endAngle?: number
949
+ clockWise?: boolean
950
+ }
951
+
952
+ export type PolarViewBoxRequired = Required<PolarViewBox>
953
+
954
+ export type TrapezoidViewBox = {
955
+ /**
956
+ * The x-coordinate of the upper left corner of the trapezoid.
957
+ * If the upper side is shorter than the lower side, this will be the x-coordinate of the upper left corner,
958
+ * meaning that the X does take into account the varying width of the trapezoid.
959
+ */
960
+ x: number
961
+ /**
962
+ * The y-coordinate of the upper side of the trapezoid.
963
+ * Nothing exciting happening here.
964
+ */
965
+ y: number
966
+ /**
967
+ * The width of the upper side of the trapezoid.
968
+ */
969
+ upperWidth: number
970
+ /**
971
+ * The width of the lower side of the trapezoid.
972
+ */
973
+ lowerWidth: number
974
+ /**
975
+ * The overall width of the trapezoid: `Math.max(upperWidth, lowerWidth)`.
976
+ */
977
+ width: number
978
+ /**
979
+ * The height of the trapezoid.
980
+ */
981
+ height: number
982
+ }
983
+
984
+ /**
985
+ * @inline
986
+ */
987
+ export type ViewBox = CartesianViewBoxRequired | PolarViewBoxRequired
988
+
989
+ type RecordString<T> = Record<string, T>
990
+
991
+ type AdaptEventHandlersReturn =
992
+ | RecordString<(e?: Event) => unknown>
993
+ | RecordString<(e: Event) => void>
994
+ | null
995
+
996
+ export const adaptEventHandlers = (
997
+ props: object | boolean,
998
+ newHandler?: (e?: Event) => unknown,
999
+ ): AdaptEventHandlersReturn => {
1000
+ if (typeof props === "function" || typeof props === "boolean") {
1001
+ return null
1002
+ }
1003
+
1004
+ if (typeof props !== "object" || props === null) {
1005
+ return null
1006
+ }
1007
+
1008
+ const inputProps = props as RecordString<unknown>
1009
+
1010
+ let out: RecordString<(e: Event) => void> | null = null
1011
+ let camelProps: RecordString<unknown> | null = null
1012
+
1013
+ for (const key of ownStringKeys(inputProps)) {
1014
+ if (isEventKey(key) && typeof inputProps[key] === "function") {
1015
+ out ??= {}
1016
+ if (newHandler) {
1017
+ out[key] = newHandler
1018
+ } else {
1019
+ /* User handler gets camelCase payload (className, fillOpacity, strokeWidth)
1020
+ * to match upstream React parity. Capture values now while the runtime owner
1021
+ * is set — at click time the owner is gone, so getters that resolve via
1022
+ * `useContext` (e.g. `useChartLayout`) would return undefined. */
1023
+ const payload = (camelProps ??= camelizeSvgPropsForHandler(inputProps) as RecordString<unknown>)
1024
+ out[key] = (e: Event) =>
1025
+ (inputProps[key] as (props: RecordString<unknown>, e: Event) => void)(payload, e)
1026
+ }
1027
+ }
1028
+ }
1029
+
1030
+ return out ?? NO_EVENT_HANDLERS
1031
+ }
1032
+
1033
+ /* Shared empty result for the common no-handler case; frozen so a caller can never leak writes. */
1034
+ const NO_EVENT_HANDLERS: RecordString<(e: Event) => void> = Object.freeze({})
1035
+
1036
+ const getEventHandlerOfChild =
1037
+ (originalHandler: (data: unknown, index: number, e: Event) => void, data: unknown, index: number) =>
1038
+ (e: Event): null => {
1039
+ originalHandler(data, index, e)
1040
+
1041
+ return null
1042
+ }
1043
+
1044
+ export const adaptEventsOfChild = (
1045
+ props: RecordString<unknown>,
1046
+ data: unknown,
1047
+ index: number,
1048
+ ): RecordString<(e?: Event) => unknown> | null => {
1049
+ if (props === null || (typeof props !== "object" && typeof props !== "function")) {
1050
+ return null
1051
+ }
1052
+
1053
+ let out: RecordString<(e: Event) => void> | null = null
1054
+
1055
+ Object.keys(props).forEach((key: string) => {
1056
+ const item = (props as RecordString<unknown>)[key]
1057
+
1058
+ if (isEventKey(key) && typeof item === "function") {
1059
+ if (out === null) out = {}
1060
+
1061
+ out[key] = getEventHandlerOfChild(item as (data: unknown, index: number, e: Event) => void, data, index)
1062
+ }
1063
+ })
1064
+
1065
+ return out
1066
+ }
1067
+
1068
+ /**
1069
+ * 'axis' means that all graphical items belonging to this axis tick will be highlighted,
1070
+ * and all will be present in the tooltip.
1071
+ * Tooltip with 'axis' will display when hovering on the chart background.
1072
+ *
1073
+ * 'item' means only the one graphical item being hovered will show in the tooltip.
1074
+ * Tooltip with 'item' will display when hovering over individual graphical items.
1075
+ *
1076
+ * This is calculated internally;
1077
+ * charts have a `defaultTooltipEventType` and `validateTooltipEventTypes` options.
1078
+ *
1079
+ * Users then use <Tooltip shared={true} /> or <Tooltip shared={false} /> to control their preference,
1080
+ * and charts will then see what is allowed and what is not.
1081
+ */
1082
+ export type TooltipEventType = "axis" | "item"
1083
+
1084
+ export interface SankeyNode {
1085
+ dx: number
1086
+ dy: number
1087
+ name: string
1088
+ value: number
1089
+ x: number
1090
+ y: number
1091
+ depth: number
1092
+ targetNodes: number[]
1093
+ targetLinks: number[]
1094
+ sourceNodes: number[]
1095
+ sourceLinks: number[]
1096
+ }
1097
+
1098
+ export interface SankeyLink {
1099
+ target: number
1100
+ source: number
1101
+ value: number
1102
+ sy: number
1103
+ dy: number
1104
+ ty: number
1105
+ }
1106
+
1107
+ export type Size = { width: number; height: number }
1108
+
1109
+ /**
1110
+ * These are the props we are going to pass to an `activeDot` or `dot` if it is a function or a custom Component
1111
+ */
1112
+ export type ActiveDotProps = DotProps & {
1113
+ payload: unknown
1114
+ index: number
1115
+ dataKey: DataKey<unknown> | undefined
1116
+ cx: number | undefined
1117
+ cy: number | undefined
1118
+ r: number | string | undefined
1119
+ fill: string
1120
+ strokeWidth: number
1121
+ stroke: string
1122
+ value: unknown
1123
+ }
1124
+
1125
+ /**
1126
+ * This is the type of `activeDot` prop on:
1127
+ * - Area
1128
+ * - Line
1129
+ * - Radar
1130
+ *
1131
+ * @inline
1132
+ */
1133
+ export type ActiveDotType =
1134
+ /**
1135
+ * true | false will turn the default activeDot on and off, respectively
1136
+ */
1137
+ | boolean
1138
+ /**
1139
+ * activeDot can be a custom Solid Component.
1140
+ * It should return an SVG element because we are in SVG context - HTML won't work here.
1141
+ */
1142
+ | ((props: ActiveDotProps) => JSX.Element)
1143
+ /**
1144
+ * activeDot can be an object; props from here will be appended to the default active dot
1145
+ */
1146
+ | Partial<ActiveDotProps>
1147
+ /**
1148
+ * activeDot can be a JSX element.
1149
+ */
1150
+ | JSX.Element
1151
+
1152
+ /**
1153
+ * Inside the dot event handlers we provide extra information about the dot point
1154
+ * that the Dot component itself does not need but users might find useful.
1155
+ */
1156
+ export type DotItemDotProps = SVGPropsNoEvents<Omit<DotProps, "points" | "ref">> & {
1157
+ points: ReadonlyArray<DotPoint>
1158
+ index: number
1159
+ payload: unknown
1160
+ dataKey: DataKey<unknown> | undefined
1161
+ value: unknown
1162
+ }
1163
+
1164
+ /**
1165
+ * This is the type of `dot` prop on:
1166
+ * - Area
1167
+ * - Line
1168
+ * - Radar
1169
+ *
1170
+ * @inline
1171
+ */
1172
+ export type DotType =
1173
+ /**
1174
+ * true | false will turn the default dot on and off, respectively
1175
+ */
1176
+ | boolean
1177
+ /**
1178
+ * dot can be a custom Solid Component.
1179
+ * It should return an SVG element because we are in SVG context - HTML won't work here.
1180
+ *
1181
+ * When a function or component is used, the props received are {@link DotItemDotProps}
1182
+ * which contain some extra information compared to {@link DotProps}.
1183
+ */
1184
+ | ((props: DotItemDotProps) => JSX.Element)
1185
+ /**
1186
+ * dot can be an object; props from here will be appended to the default dot
1187
+ */
1188
+ | Partial<DotProps>
1189
+ /**
1190
+ * dot can be a JSX element.
1191
+ */
1192
+ | JSX.Element
1193
+
1194
+ export type ActiveShape<PropsType = Record<string, unknown>, ElementType extends Element = SVGElement> =
1195
+ | JSX.Element
1196
+ | ((props: PropsType) => JSX.Element | null | undefined)
1197
+ | JSX.SvgSVGAttributes<ElementType>
1198
+ | boolean
1199
+
1200
+ /**
1201
+ * Animation progress props passed to custom `shape` renderers.
1202
+ * `animationElapsedTime` is 0 at the start and 1 at the end (easing already applied).
1203
+ */
1204
+ export interface ShapeAnimationProps {
1205
+ animationElapsedTime?: number
1206
+ isAnimating?: boolean
1207
+ isEntrance?: boolean
1208
+ }
1209
+
1210
+ export type RangeObj = PolarViewBoxRequired & {
1211
+ angle: number
1212
+ radius: number
1213
+ }
1214
+
1215
+ type HTMLElementTarget = Pick<HTMLElement, "getBoundingClientRect" | "offsetWidth" | "offsetHeight">
1216
+ type SVGElementTarget = Pick<SVGGraphicsElement, "getBoundingClientRect" | "getBBox">
1217
+
1218
+ /**
1219
+ * Simplified version of the MouseEvent so that we don't have to mock the whole thing in tests.
1220
+ *
1221
+ * This represents the native MouseEvent:
1222
+ * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
1223
+ */
1224
+ export interface HTMLMousePointer {
1225
+ clientX: number
1226
+ clientY: number
1227
+ currentTarget: HTMLElementTarget
1228
+ }
1229
+
1230
+ export interface HTMLTouchPointer {
1231
+ touches: ArrayLike<Pick<Touch, "clientX" | "clientY">>
1232
+ currentTarget: HTMLElementTarget
1233
+ }
1234
+
1235
+ /**
1236
+ * Simplified version of the MouseEvent for SVG elements.
1237
+ *
1238
+ * Similar to MousePointer but uses SVGGraphicsElement properties instead of HTMLElement properties.
1239
+ * SVG elements use getBBox() to get the intrinsic size instead of offsetWidth/offsetHeight.
1240
+ */
1241
+ export interface SVGMousePointer {
1242
+ clientX: number
1243
+ clientY: number
1244
+ currentTarget: SVGElementTarget
1245
+ }
1246
+
1247
+ export interface SVGTouchPointer {
1248
+ touches: ArrayLike<Pick<Touch, "clientX" | "clientY">>
1249
+ currentTarget: SVGElementTarget
1250
+ }
1251
+
1252
+ /**
1253
+ * Recharts accepts mouse events from both HTML and SVG elements.
1254
+ */
1255
+ export type MousePointer = HTMLMousePointer | SVGMousePointer
1256
+ export type TouchPointer = HTMLTouchPointer | SVGTouchPointer
1257
+
1258
+ /**
1259
+ * Coordinates relative to the top-left corner of the active element.
1260
+ * Also include scale which means that element that's scaled will return the same coordinates as element that's not scaled.
1261
+ */
1262
+ export interface RelativePointer {
1263
+ relativeX: number
1264
+ relativeY: number
1265
+ }
1266
+
1267
+ /**
1268
+ * Data provider means that this component accepts a `data` prop which is where you can input your data into the chart state.
1269
+ * The data is an array of objects, where each object represents a data point.
1270
+ *
1271
+ * DataPointType is the type of each data point object in the data array.
1272
+ *
1273
+ * The data is reused in multiple charts and components. Meaning if you provide data on the chart level,
1274
+ * then all child components, graphical items, legend, tooltip, axes ... will be able to access the data.
1275
+ *
1276
+ * Same goes for the graphical item. If you provide data on the graphical item level,
1277
+ * then that data is visible for the main chart, and all axes, tooltip, legend ... in the whole chart.
1278
+ * This is not scoped to the graphical item only.
1279
+ */
1280
+ export interface DataProvider<DataPointType> {
1281
+ /**
1282
+ * The source data. Each element should be an object.
1283
+ * The properties of each object represent the values of different data dimensions.
1284
+ *
1285
+ * Use the `dataKey` prop to specify which properties to use.
1286
+ *
1287
+ * @example data={[{ name: 'a', value: 12 }]}
1288
+ * @example data={[{ label: 'foo', measurements: [5, 12] }]}
1289
+ */
1290
+ data?: ChartData<DataPointType>
1291
+ }
1292
+
1293
+ /**
1294
+ * Data consumer means that this component accepts a `dataKey` prop which is how you specify
1295
+ * which dimension of the data to use for this component.
1296
+ *
1297
+ * DataPointType is the type of each data point object in the data array.
1298
+ * DataValueType is the type of the value that this dataKey extracts from each data point.
1299
+ */
1300
+ export interface DataConsumer<DataPointType, DataValueType> {
1301
+ /**
1302
+ * The data that you provide via the `data` prop is an array of objects.
1303
+ * Each object can have multiple properties, each representing a different data dimension.
1304
+ * Use the `dataKey` prop to specify which property (or dimension) to use for this component.
1305
+ *
1306
+ * Typically, you will want to have one dataKey on the X axis, and different dataKey on the Y axis,
1307
+ * where they extract different values from the same data objects.
1308
+ *
1309
+ * Decides how to extract the value from the data:
1310
+ * - `string`: the name of the field in the data object;
1311
+ * - `number`: the index of the field in the data;
1312
+ * - `function`: a function that receives the data object and returns the value.
1313
+ */
1314
+ dataKey?: DataKey<DataPointType, DataValueType>
1315
+ }
1316
+
1317
+ /**
1318
+ * Props shared with all Cartesian and Polar charts.
1319
+ * There are three charts that do not use these base props, and define their own:
1320
+ * - Treemap
1321
+ * - Sunburst
1322
+ * - Sankey
1323
+ */
1324
+ interface BaseChartProps<DataPointType> extends DataProvider<DataPointType>, ExternalMouseEvents {
1325
+ /**
1326
+ * The width of chart container.
1327
+ * Can be a number or a percent string like "100%".
1328
+ *
1329
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1330
+ */
1331
+ width?: number | Percent
1332
+ /**
1333
+ * The height of chart container.
1334
+ * Can be a number or a percent string like "100%".
1335
+ *
1336
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1337
+ */
1338
+ height?: number | Percent
1339
+ id?: string
1340
+ children?: JSX.Element
1341
+ className?: string
1342
+ /**
1343
+ * Turn on accessibility support for keyboard-only and screen reader users.
1344
+ *
1345
+ * @defaultValue true
1346
+ */
1347
+ accessibilityLayer?: boolean
1348
+ desc?: string
1349
+ /**
1350
+ * Empty space around the container.
1351
+ *
1352
+ * @defaultValue {"top":5,"right":5,"bottom":5,"left":5}
1353
+ */
1354
+ margin?: Partial<Margin>
1355
+ style?: JSX.CSSProperties
1356
+ /**
1357
+ * The CSS cursor style applied to the chart container.
1358
+ * Useful for setting the mouse cursor when hovering over the chart (e.g. `"pointer"`, `"crosshair"`).
1359
+ */
1360
+ cursor?: JSX.CSSProperties["cursor"]
1361
+ /**
1362
+ * Charts with the same syncId will synchronize Tooltip and Brush events.
1363
+ *
1364
+ * @see {@link https://recharts.github.io/en-US/examples/SynchronizedAreaChart/ Synchronized Charts Example}
1365
+ */
1366
+ syncId?: number | string
1367
+ /**
1368
+ * Customize how the charts will synchronize tooltips and brushes.
1369
+ * `index`: synchronize using the data index in the data array. Index expects that all data has the same length.
1370
+ * `value`: synchronize using the data value on categorical axis (categorical: XAxis in horizontal layout, YAxis in vertical layout).
1371
+ * function: a custom sync method which receives tick and data as argument and returns an index.
1372
+ *
1373
+ * @defaultValue index
1374
+ */
1375
+ syncMethod?: SyncMethod
1376
+ /**
1377
+ * If and where the chart should appear in the tab order
1378
+ */
1379
+ tabIndex?: number
1380
+ /**
1381
+ * If true, then it will listen to container size changes and adapt the SVG chart accordingly.
1382
+ * If false, then it renders the chart at the specified width and height and will stay that way
1383
+ * even if the container size changes.
1384
+ *
1385
+ * This is similar to ResponsiveContainer but without the need for an extra wrapper component.
1386
+ * The `responsive` prop also uses standard CSS sizing rules, instead of custom resolution logic (like ResponsiveContainer does).
1387
+ * @default false
1388
+ *
1389
+ * @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
1390
+ */
1391
+ responsive?: boolean
1392
+ }
1393
+
1394
+ export interface EventThrottlingProps {
1395
+ /**
1396
+ * Decides the time interval to throttle events.
1397
+ * Only events defined in `throttledEvents` prop are throttled.
1398
+ * All other events are executed immediately/synchronously.
1399
+ *
1400
+ * Options:
1401
+ * - `number`: the time interval in milliseconds
1402
+ * - `'raf'`: use requestAnimationFrame to schedule updates.
1403
+ *
1404
+ * @defaultValue 'raf'
1405
+ */
1406
+ throttleDelay?: number | "raf"
1407
+ /**
1408
+ * Defines which events should be throttled.
1409
+ * Events not in this list will not be throttled.
1410
+ *
1411
+ * Use the special value `'all'` to throttle all events. Empty array means no events are throttled.
1412
+ *
1413
+ * Use the prop `throttleDelay` to define the throttling interval.
1414
+ *
1415
+ * If an event is on this list, then you lose the opportunity to access the event synchronously.
1416
+ * Which means that if you want to call `e.preventDefault()` or `e.stopPropagation()` inside the event handler,
1417
+ * then that event handler must not be in this list.
1418
+ *
1419
+ * @defaultValue ["mousemove","touchmove","pointermove","scroll","wheel"]
1420
+ */
1421
+ throttledEvents?: ReadonlyArray<keyof GlobalEventHandlersEventMap> | "all"
1422
+ }
1423
+
1424
+ export interface CartesianChartProps<DataPointType = unknown>
1425
+ extends BaseChartProps<DataPointType>, EventThrottlingProps {
1426
+ /**
1427
+ * The gap between two bar categories, which can be a percent value or a fixed value.
1428
+ *
1429
+ * @defaultValue 10%
1430
+ *
1431
+ * @see {@link https://recharts.github.io/en-US/guide/barAlignment/ Bar Alignment Guide}
1432
+ */
1433
+ barCategoryGap?: number | string
1434
+ /**
1435
+ * The gap between two bars in the same category.
1436
+ *
1437
+ * @defaultValue 4
1438
+ *
1439
+ * @see {@link https://recharts.github.io/en-US/guide/barAlignment/ Bar Alignment Guide}
1440
+ */
1441
+ barGap?: number | string
1442
+ /**
1443
+ * The width or height of each bar. If the barSize is not specified, the size of the
1444
+ * bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
1445
+ */
1446
+ barSize?: number | string
1447
+ /**
1448
+ * The base value of area.
1449
+ */
1450
+ baseValue?: BaseValue
1451
+ compact?: boolean
1452
+ dataKey?: DataKey<unknown>
1453
+ /**
1454
+ * The layout of chart defines the orientation of axes, graphical items, and tooltip.
1455
+ *
1456
+ * @defaultValue horizontal
1457
+ */
1458
+ layout?: CartesianLayout
1459
+ /**
1460
+ * The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart.
1461
+ */
1462
+ maxBarSize?: number
1463
+ /**
1464
+ * If `false`, stacked items will be rendered left to right.
1465
+ * If `true`, stacked items will be rendered right to left.
1466
+ *
1467
+ * Render direction affects SVG layering, not x position.
1468
+ *
1469
+ * @defaultValue false
1470
+ */
1471
+ reverseStackOrder?: boolean
1472
+ /**
1473
+ * The ARIA role for the chart, which provides semantic information for screen reader users.
1474
+ */
1475
+ role?: string
1476
+ /**
1477
+ * The type of offset function used to generate the lower and upper values in the series array.
1478
+ * The types are built-in offsets in d3-shape.
1479
+ * Only applicable for stacked Area or Bar charts.
1480
+ * Has no effect when the stackId prop is not set on Area or Bar components.
1481
+ *
1482
+ * @link https://d3js.org/d3-shape/stack#stack_offset
1483
+ * @see {@link https://recharts.github.io/en-US/examples/BarChartStackedBySign/ Chart with stackOffset=sign example}
1484
+ *
1485
+ * @defaultValue none
1486
+ */
1487
+ stackOffset?: StackOffsetType
1488
+ title?: string
1489
+ }
1490
+
1491
+ export interface PolarChartProps<DataPointType = unknown>
1492
+ extends BaseChartProps<DataPointType>, EventThrottlingProps {
1493
+ /**
1494
+ * The gap between two bar categories, which can be a percent value or a fixed value.
1495
+ *
1496
+ * @defaultValue 10%
1497
+ */
1498
+ barCategoryGap?: number | string
1499
+ /**
1500
+ * The gap between two bars in the same category.
1501
+ *
1502
+ * @defaultValue 4
1503
+ */
1504
+ barGap?: number | string
1505
+ /**
1506
+ * The width or height of each bar. If the barSize is not specified, the size of the
1507
+ * bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
1508
+ */
1509
+ barSize?: number | string
1510
+ /**
1511
+ * The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width.
1512
+ * @defaultValue 50%
1513
+ */
1514
+ cx?: number | string
1515
+ /**
1516
+ * The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height.
1517
+ * @defaultValue 50%
1518
+ */
1519
+ cy?: number | string
1520
+ dataKey?: DataKey<unknown>
1521
+ /**
1522
+ * Angle, in degrees, at which the chart should end.
1523
+ */
1524
+ endAngle?: number
1525
+ /**
1526
+ * The inner radius of the chart.
1527
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
1528
+ * @defaultValue 0
1529
+ */
1530
+ innerRadius?: number | string
1531
+ /**
1532
+ * The layout of chart defines the orientation of axes, graphical items, and tooltip.
1533
+ */
1534
+ layout?: PolarLayout
1535
+ maxBarSize?: number
1536
+ /**
1537
+ * The outer radius of the chart.
1538
+ * If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy.
1539
+ * @defaultValue 80%
1540
+ */
1541
+ outerRadius?: number | string
1542
+ reverseStackOrder?: boolean
1543
+ role?: string
1544
+ stackOffset?: StackOffsetType
1545
+ /**
1546
+ * Angle in degrees from which the chart should start.
1547
+ */
1548
+ startAngle?: number
1549
+ title?: string
1550
+ }
1551
+
1552
+ export type Percent = `${number}%`
1553
+
1554
+ export type NonEmptyArray<T> = readonly [T, ...T[]]
1555
+
1556
+ export const isNonEmptyArray = <T>(
1557
+ arr: ReadonlyArray<T> | null | undefined,
1558
+ ): arr is NonEmptyArray<T> => {
1559
+ return Array.isArray(arr) && arr.length > 0
1560
+ }