@solidports/recharts 0.1.0 → 0.1.1

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 (304) hide show
  1. package/dist/index.d.ts +40 -2
  2. package/dist/index.js +14238 -7174
  3. package/dist/{dev.js → index.jsx} +18367 -15900
  4. package/dist/server.js +48178 -0
  5. package/package.json +36 -19
  6. package/src/animation/AnimatedItems.tsx +0 -183
  7. package/src/animation/AnimationController.ts +0 -33
  8. package/src/animation/AnimationControllerImpl.ts +0 -36
  9. package/src/animation/AnimationHandle.ts +0 -307
  10. package/src/animation/CSSTransitionAnimate.tsx +0 -170
  11. package/src/animation/JavascriptAnimate.tsx +0 -119
  12. package/src/animation/easing.ts +0 -221
  13. package/src/animation/matchBy.ts +0 -164
  14. package/src/animation/timeoutController.ts +0 -70
  15. package/src/animation/useAnimationController.tsx +0 -34
  16. package/src/animation/useAnimationStartSnapshot.ts +0 -118
  17. package/src/animation/util.ts +0 -41
  18. package/src/cartesian/Area.tsx +0 -915
  19. package/src/cartesian/AreaRevealShape.tsx +0 -190
  20. package/src/cartesian/Bar.tsx +0 -1369
  21. package/src/cartesian/BarStack.tsx +0 -152
  22. package/src/cartesian/Brush.tsx +0 -951
  23. package/src/cartesian/CartesianAxis.tsx +0 -722
  24. package/src/cartesian/CartesianGrid.tsx +0 -711
  25. package/src/cartesian/ErrorBar.tsx +0 -361
  26. package/src/cartesian/Funnel.tsx +0 -803
  27. package/src/cartesian/GraphicalItemClipPath.tsx +0 -67
  28. package/src/cartesian/Line.tsx +0 -863
  29. package/src/cartesian/LineDrawShape.tsx +0 -89
  30. package/src/cartesian/ReferenceArea.tsx +0 -331
  31. package/src/cartesian/ReferenceDot.tsx +0 -304
  32. package/src/cartesian/ReferenceLine.tsx +0 -474
  33. package/src/cartesian/Scatter.tsx +0 -888
  34. package/src/cartesian/XAxis.tsx +0 -433
  35. package/src/cartesian/YAxis.tsx +0 -443
  36. package/src/cartesian/ZAxis.tsx +0 -155
  37. package/src/cartesian/cartesianPositionToCSSTranslate.tsx +0 -29
  38. package/src/cartesian/cartesianViewBoxToTrapezoid.tsx +0 -21
  39. package/src/cartesian/getCartesianPosition.tsx +0 -267
  40. package/src/cartesian/getEquidistantTicks.ts +0 -144
  41. package/src/cartesian/getTicks.ts +0 -225
  42. package/src/cartesian/isOutsidePosition.ts +0 -15
  43. package/src/cartesian/useAnimatedLineLength.ts +0 -54
  44. package/src/chart/AreaChart.tsx +0 -29
  45. package/src/chart/BarChart.tsx +0 -29
  46. package/src/chart/CartesianChart.tsx +0 -131
  47. package/src/chart/CategoricalChart.tsx +0 -94
  48. package/src/chart/ComposedChart.tsx +0 -29
  49. package/src/chart/FunnelChart.tsx +0 -29
  50. package/src/chart/LineChart.tsx +0 -29
  51. package/src/chart/PieChart.tsx +0 -50
  52. package/src/chart/PolarChart.tsx +0 -164
  53. package/src/chart/RadarChart.tsx +0 -70
  54. package/src/chart/RadialBarChart.tsx +0 -46
  55. package/src/chart/RechartsWrapper.tsx +0 -551
  56. package/src/chart/Sankey.tsx +0 -1534
  57. package/src/chart/ScatterChart.tsx +0 -29
  58. package/src/chart/SunburstChart.tsx +0 -504
  59. package/src/chart/Treemap.tsx +0 -1223
  60. package/src/chart/createInitialRootProps.ts +0 -24
  61. package/src/chart/types.ts +0 -53
  62. package/src/component/ActivePoints.tsx +0 -144
  63. package/src/component/Cell.tsx +0 -37
  64. package/src/component/Cursor.tsx +0 -185
  65. package/src/component/Customized.tsx +0 -50
  66. package/src/component/DefaultLegendContent.tsx +0 -348
  67. package/src/component/DefaultTooltipContent.tsx +0 -224
  68. package/src/component/Dots.tsx +0 -157
  69. package/src/component/Label.tsx +0 -636
  70. package/src/component/LabelList.tsx +0 -375
  71. package/src/component/Legend.tsx +0 -512
  72. package/src/component/ResponsiveContainer.tsx +0 -348
  73. package/src/component/Text.tsx +0 -541
  74. package/src/component/Tooltip.tsx +0 -470
  75. package/src/component/TooltipBoundingBox.tsx +0 -146
  76. package/src/component/responsiveContainerUtils.ts +0 -134
  77. package/src/container/ClipPathProvider.tsx +0 -51
  78. package/src/container/Layer.tsx +0 -38
  79. package/src/container/RootSurface.tsx +0 -120
  80. package/src/container/Surface.tsx +0 -61
  81. package/src/context/CellsContext.tsx +0 -54
  82. package/src/context/ErrorBarContext.tsx +0 -146
  83. package/src/context/GraphicalItemChildrenScope.tsx +0 -18
  84. package/src/context/PanoramaContext.tsx +0 -9
  85. package/src/context/RegisterGraphicalItemId.tsx +0 -30
  86. package/src/context/accessibilityContext.tsx +0 -6
  87. package/src/context/brushUpdateContext.tsx +0 -9
  88. package/src/context/chartDataContext.tsx +0 -97
  89. package/src/context/chartLayoutContext.tsx +0 -201
  90. package/src/context/legendPayloadContext.tsx +0 -20
  91. package/src/context/legendPortalContext.tsx +0 -12
  92. package/src/context/tooltipContext.tsx +0 -89
  93. package/src/context/tooltipPortalContext.tsx +0 -12
  94. package/src/context/useTooltipAxis.ts +0 -22
  95. package/src/hooks.ts +0 -476
  96. package/src/index.ts +0 -280
  97. package/src/polar/Pie.tsx +0 -1360
  98. package/src/polar/PolarAngleAxis.tsx +0 -616
  99. package/src/polar/PolarGrid.tsx +0 -312
  100. package/src/polar/PolarRadiusAxis.tsx +0 -547
  101. package/src/polar/Radar.tsx +0 -734
  102. package/src/polar/RadialBar.tsx +0 -917
  103. package/src/polar/defaultPolarAngleAxisProps.tsx +0 -27
  104. package/src/polar/defaultPolarRadiusAxisProps.tsx +0 -25
  105. package/src/shape/Cross.tsx +0 -89
  106. package/src/shape/Curve.tsx +0 -343
  107. package/src/shape/Dot.tsx +0 -70
  108. package/src/shape/Polygon.tsx +0 -195
  109. package/src/shape/Rectangle.tsx +0 -470
  110. package/src/shape/Sector.tsx +0 -347
  111. package/src/shape/Symbols.tsx +0 -139
  112. package/src/shape/Trapezoid.tsx +0 -280
  113. package/src/state/RechartsStateContext.tsx +0 -12
  114. package/src/state/RechartsStateProvider.tsx +0 -87
  115. package/src/state/RechartsStoreContext.tsx +0 -25
  116. package/src/state/RechartsStoreProvider.tsx +0 -35
  117. package/src/state/ReportChartProps.tsx +0 -40
  118. package/src/state/ReportEventSettings.tsx +0 -30
  119. package/src/state/ReportMainChartProps.tsx +0 -61
  120. package/src/state/ReportPolarOptions.tsx +0 -35
  121. package/src/state/SetGraphicalItem.ts +0 -79
  122. package/src/state/SetLegendPayload.ts +0 -134
  123. package/src/state/SetTooltipEntrySettings.tsx +0 -72
  124. package/src/state/actions.ts +0 -464
  125. package/src/state/brushSlice.ts +0 -13
  126. package/src/state/cartesianAxisSlice.ts +0 -141
  127. package/src/state/chartDataSlice.ts +0 -50
  128. package/src/state/chartState.ts +0 -297
  129. package/src/state/errorBarSlice.ts +0 -29
  130. package/src/state/eventSettingsSlice.ts +0 -8
  131. package/src/state/events.ts +0 -76
  132. package/src/state/externalEventsMiddleware.ts +0 -255
  133. package/src/state/graphicalItemsSlice.ts +0 -74
  134. package/src/state/hooks/useChartSelectors.tsx +0 -45
  135. package/src/state/keyboardEventsMiddleware.ts +0 -228
  136. package/src/state/layoutSlice.ts +0 -21
  137. package/src/state/legendSlice.ts +0 -57
  138. package/src/state/mouseEventsMiddleware.ts +0 -185
  139. package/src/state/optionsSlice.ts +0 -47
  140. package/src/state/polarAxisSlice.ts +0 -10
  141. package/src/state/polarOptionsSlice.ts +0 -12
  142. package/src/state/rawData.ts +0 -26
  143. package/src/state/referenceElementsSlice.ts +0 -40
  144. package/src/state/renderedTicksSlice.ts +0 -15
  145. package/src/state/rootPropsSlice.ts +0 -47
  146. package/src/state/selectors/areaSelectors.ts +0 -240
  147. package/src/state/selectors/arrayEqualityCheck.ts +0 -29
  148. package/src/state/selectors/axisSelectors.ts +0 -2157
  149. package/src/state/selectors/barSelectors.ts +0 -310
  150. package/src/state/selectors/barStackSelectors.ts +0 -77
  151. package/src/state/selectors/brushSelectors.ts +0 -33
  152. package/src/state/selectors/chartSelector.ts +0 -185
  153. package/src/state/selectors/combiners/combineActiveLabel.ts +0 -16
  154. package/src/state/selectors/combiners/combineActiveTooltipIndex.ts +0 -95
  155. package/src/state/selectors/combiners/combineAllBarPositions.ts +0 -122
  156. package/src/state/selectors/combiners/combineAxisRangeWithReverse.ts +0 -16
  157. package/src/state/selectors/combiners/combineBarPosition.ts +0 -23
  158. package/src/state/selectors/combiners/combineBarSizeList.ts +0 -80
  159. package/src/state/selectors/combiners/combineCheckedDomain.ts +0 -48
  160. package/src/state/selectors/combiners/combineConfiguredScale.ts +0 -111
  161. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.ts +0 -45
  162. package/src/state/selectors/combiners/combineDisplayedStackedData.ts +0 -50
  163. package/src/state/selectors/combiners/combineInverseScaleFunction.ts +0 -16
  164. package/src/state/selectors/combiners/combineRealScaleType.ts +0 -44
  165. package/src/state/selectors/combiners/combineStackedData.ts +0 -27
  166. package/src/state/selectors/combiners/combineTooltipInteractionState.ts +0 -86
  167. package/src/state/selectors/combiners/combineTooltipPayload.ts +0 -205
  168. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.ts +0 -58
  169. package/src/state/selectors/containerSelectors.ts +0 -12
  170. package/src/state/selectors/dataSelectors.ts +0 -88
  171. package/src/state/selectors/funnelSelectors.ts +0 -75
  172. package/src/state/selectors/graphicalItemSelectors.ts +0 -30
  173. package/src/state/selectors/legendSelectors.ts +0 -29
  174. package/src/state/selectors/lineSelectors.ts +0 -134
  175. package/src/state/selectors/numberDomainEqualityCheck.ts +0 -14
  176. package/src/state/selectors/pickAxisId.ts +0 -5
  177. package/src/state/selectors/pickAxisType.ts +0 -3
  178. package/src/state/selectors/pieSelectors.ts +0 -97
  179. package/src/state/selectors/polarAxisSelectors.ts +0 -201
  180. package/src/state/selectors/polarGridSelectors.ts +0 -28
  181. package/src/state/selectors/polarScaleSelectors.ts +0 -133
  182. package/src/state/selectors/polarSelectors.ts +0 -219
  183. package/src/state/selectors/radarSelectors.ts +0 -191
  184. package/src/state/selectors/radialBarSelectors.ts +0 -435
  185. package/src/state/selectors/rootPropsSelectors.ts +0 -25
  186. package/src/state/selectors/scatterSelectors.ts +0 -96
  187. package/src/state/selectors/selectActivePropsFromChartPointer.ts +0 -26
  188. package/src/state/selectors/selectAllAxes.ts +0 -17
  189. package/src/state/selectors/selectChartOffset.ts +0 -16
  190. package/src/state/selectors/selectChartOffsetInternal.ts +0 -136
  191. package/src/state/selectors/selectLegendArea.ts +0 -20
  192. package/src/state/selectors/selectPlotArea.ts +0 -22
  193. package/src/state/selectors/selectTooltipAxisId.ts +0 -7
  194. package/src/state/selectors/selectTooltipAxisType.ts +0 -32
  195. package/src/state/selectors/selectTooltipEventType.ts +0 -48
  196. package/src/state/selectors/selectTooltipPayloadSearcher.ts +0 -6
  197. package/src/state/selectors/selectTooltipSettings.ts +0 -39
  198. package/src/state/selectors/selectTooltipState.ts +0 -8
  199. package/src/state/selectors/selectors.ts +0 -271
  200. package/src/state/selectors/tooltipSelectors.ts +0 -578
  201. package/src/state/selectors/touchSelectors.ts +0 -31
  202. package/src/state/store.ts +0 -29
  203. package/src/state/storeIdentity.ts +0 -9
  204. package/src/state/teardownWrite.ts +0 -10
  205. package/src/state/tooltipInteraction.ts +0 -23
  206. package/src/state/tooltipSlice.ts +0 -334
  207. package/src/state/touchEventsMiddleware.ts +0 -214
  208. package/src/state/types/AnimationSettings.ts +0 -20
  209. package/src/state/types/AreaSettings.ts +0 -14
  210. package/src/state/types/BarSettings.ts +0 -15
  211. package/src/state/types/LineSettings.ts +0 -9
  212. package/src/state/types/PieSettings.ts +0 -34
  213. package/src/state/types/RadarSettings.ts +0 -5
  214. package/src/state/types/RadialBarSettings.ts +0 -10
  215. package/src/state/types/ScatterSettings.ts +0 -12
  216. package/src/state/types/StackedGraphicalItem.ts +0 -34
  217. package/src/state/useChartState.ts +0 -17
  218. package/src/state/zIndexSlice.ts +0 -39
  219. package/src/synchronisation/syncSelectors.ts +0 -7
  220. package/src/synchronisation/types.ts +0 -44
  221. package/src/synchronisation/useChartSynchronisation.tsx +0 -404
  222. package/src/theme/RechartsTheme.ts +0 -16
  223. package/src/theme/RechartsThemeContext.ts +0 -19
  224. package/src/theme/darkTheme.ts +0 -13
  225. package/src/theme/graphicalItemIdentity.ts +0 -70
  226. package/src/theme/legacyTheme.ts +0 -17
  227. package/src/theme/lightTheme.ts +0 -13
  228. package/src/types.ts +0 -54
  229. package/src/util/ActiveShapeUtils.tsx +0 -162
  230. package/src/util/BarUtils.tsx +0 -62
  231. package/src/util/BarePortal.tsx +0 -50
  232. package/src/util/CamelCaseSVGAttrs.ts +0 -34
  233. package/src/util/CartesianUtils.ts +0 -48
  234. package/src/util/ChartUtils.ts +0 -802
  235. package/src/util/Constants.ts +0 -42
  236. package/src/util/CssPrefixUtils.ts +0 -20
  237. package/src/util/DOMUtils.ts +0 -129
  238. package/src/util/DataUtils.ts +0 -216
  239. package/src/util/Events.ts +0 -16
  240. package/src/util/FunnelUtils.tsx +0 -15
  241. package/src/util/Global.ts +0 -12
  242. package/src/util/IfOverflow.ts +0 -15
  243. package/src/util/LRUCache.ts +0 -41
  244. package/src/util/LogUtils.ts +0 -22
  245. package/src/util/PolarUtils.ts +0 -132
  246. package/src/util/RadialBarUtils.tsx +0 -24
  247. package/src/util/ReactUtils.ts +0 -95
  248. package/src/util/ReduceCSSCalc.ts +0 -187
  249. package/src/util/ScatterUtils.tsx +0 -52
  250. package/src/util/ShapeElementProps.tsx +0 -87
  251. package/src/util/TickUtils.ts +0 -60
  252. package/src/util/XAxisUtils.ts +0 -48
  253. package/src/util/YAxisUtils.ts +0 -48
  254. package/src/util/axisPropsAreEqual.ts +0 -48
  255. package/src/util/createCartesianCharts.tsx +0 -150
  256. package/src/util/createEventProxy.ts +0 -20
  257. package/src/util/createPolarCharts.tsx +0 -112
  258. package/src/util/cursor/getCursorPoints.ts +0 -46
  259. package/src/util/cursor/getCursorRectangle.ts +0 -28
  260. package/src/util/cursor/getRadialCursorPoints.ts +0 -32
  261. package/src/util/excludeEventProps.ts +0 -171
  262. package/src/util/getActiveCoordinate.ts +0 -213
  263. package/src/util/getAxisTypeBasedOnLayout.ts +0 -21
  264. package/src/util/getClassNameFromUnknown.ts +0 -6
  265. package/src/util/getEveryNth.ts +0 -27
  266. package/src/util/getRadiusAndStrokeWidthFromDot.ts +0 -35
  267. package/src/util/getRelativeCoordinate.ts +0 -80
  268. package/src/util/getSliced.ts +0 -13
  269. package/src/util/hoverDedupe.ts +0 -41
  270. package/src/util/isDomainSpecifiedByUser.ts +0 -219
  271. package/src/util/isWellBehavedNumber.ts +0 -7
  272. package/src/util/pathTotalLength.ts +0 -25
  273. package/src/util/payload/getUniqPayload.ts +0 -28
  274. package/src/util/propsAreEqual.ts +0 -121
  275. package/src/util/resolveDefaultProps.ts +0 -161
  276. package/src/util/round.ts +0 -32
  277. package/src/util/scale/CartesianScaleHelper.ts +0 -72
  278. package/src/util/scale/CustomScaleDefinition.ts +0 -81
  279. package/src/util/scale/RechartsScale.ts +0 -130
  280. package/src/util/scale/createCategoricalInverse.ts +0 -72
  281. package/src/util/scale/getNiceTickValues.ts +0 -311
  282. package/src/util/scale/index.ts +0 -2
  283. package/src/util/scale/util/arithmetic.ts +0 -54
  284. package/src/util/solid-1-compat.ts +0 -310
  285. package/src/util/solidJsxCamelAugment.d.ts +0 -84
  286. package/src/util/stacks/getStackSeriesIdentifier.ts +0 -21
  287. package/src/util/stacks/stackTypes.ts +0 -60
  288. package/src/util/structurallyEqual.ts +0 -31
  289. package/src/util/svgPropertiesAndEvents.ts +0 -53
  290. package/src/util/svgPropertiesNoEvents.ts +0 -571
  291. package/src/util/tooltip/translate.ts +0 -171
  292. package/src/util/typedDataKey.ts +0 -48
  293. package/src/util/types.ts +0 -1560
  294. package/src/util/useAnimationId.ts +0 -31
  295. package/src/util/useElementOffset.ts +0 -110
  296. package/src/util/useId.ts +0 -8
  297. package/src/util/usePrefersReducedMotion.ts +0 -48
  298. package/src/util/useReportScale.ts +0 -24
  299. package/src/util/useUniqueId.ts +0 -30
  300. package/src/zIndex/DefaultZIndexes.ts +0 -84
  301. package/src/zIndex/ZIndexLayer.tsx +0 -121
  302. package/src/zIndex/ZIndexPortal.tsx +0 -79
  303. package/src/zIndex/getZIndexFromUnknown.ts +0 -14
  304. package/src/zIndex/zIndexSelectors.ts +0 -48
@@ -1,185 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { ChartState } from "./chartState"
3
- import type { RelativePointer, HTMLMousePointer } from "../util/types"
4
- import { selectActivePropsFromChartPointer } from "./selectors/selectActivePropsFromChartPointer"
5
- import { selectTooltipEventType } from "./selectors/selectTooltipEventType"
6
- import { getRelativeCoordinate } from "../util/getRelativeCoordinate"
7
- import { readChartState } from "./chartState"
8
-
9
- import { type SetStoreFunction } from '../util/solid-1-compat';
10
- import { setTooltipInteraction } from "./tooltipInteraction"
11
- export type MouseEventHandlers = {
12
- handleMouseClick: (mousePointer: HTMLMousePointer) => void
13
- handleMouseMove: (mousePointer: HTMLMousePointer) => void
14
- }
15
-
16
- /**
17
- * Creates mouse event handler functions that read from the Solid store and update it directly.
18
- * Replaces the Redux createListenerMiddleware pattern.
19
- */
20
- export function createMouseEventHandlers(
21
- store: ChartState,
22
- setStore: SetStoreFunction<ChartState>,
23
- ): MouseEventHandlers {
24
- /*
25
- * This single rafId is safe because:
26
- * 1. Each chart has its own store instance with its own handlers
27
- * 2. mouseMove only fires from one DOM element (the chart wrapper)
28
- * 3. Rapid mousemove events from the same element SHOULD debounce - we only care about the latest position
29
- * This is different from externalEventsMiddleware which handles multiple event types
30
- * (click, mouseenter, mouseleave, etc.) that should NOT cancel each other.
31
- */
32
- let rafId: number | null = null
33
- let timeoutId: ReturnType<typeof setTimeout> | null = null
34
- let latestChartPointer: RelativePointer | null = null
35
-
36
- function handleMouseClick(mousePointer: HTMLMousePointer): void {
37
- const activeProps = selectActivePropsFromChartPointer(
38
- store,
39
- getRelativeCoordinate(mousePointer),
40
- )
41
- if (activeProps?.activeIndex != null) {
42
- setTooltipInteraction(setStore, "axisInteraction", "click", {
43
- active: true,
44
- coordinate: activeProps.activeCoordinate,
45
- dataKey: undefined,
46
- graphicalItemId: undefined,
47
- index: activeProps.activeIndex,
48
- })
49
- }
50
- }
51
-
52
- function handleMouseMove(mousePointer: HTMLMousePointer): void {
53
- const { throttleDelay, throttledEvents } = store.eventSettings
54
- const isThrottled = throttledEvents === "all" || throttledEvents?.includes("mousemove")
55
-
56
- /* Cancel any pending execution */
57
- if (rafId !== null) {
58
- cancelAnimationFrame(rafId)
59
- rafId = null
60
- }
61
- if (timeoutId !== null && (typeof throttleDelay !== "number" || !isThrottled)) {
62
- clearTimeout(timeoutId)
63
- timeoutId = null
64
- }
65
-
66
- /*
67
- * Here it is important to resolve the chart pointer _before_ the callback,
68
- * because once we leave the current event loop, the mousePointer event object will lose
69
- * reference to currentTarget which getRelativeCoordinate uses.
70
- */
71
- latestChartPointer = getRelativeCoordinate(mousePointer)
72
- const callback = () => {
73
- /*
74
- * Here we read a fresh state again inside the callback to ensure we have the latest state values
75
- * after any potential actions that may have been dispatched between the original event and this callback.
76
- */
77
- const tooltipEventType = selectTooltipEventType(
78
- store,
79
- readChartState(store).tooltip.settings.shared,
80
- )
81
- if (latestChartPointer == null) {
82
- rafId = null
83
- timeoutId = null
84
- return
85
- }
86
-
87
- /*
88
- * This functionality only applies to charts that have axes.
89
- * Graphical items have its own mouse events handling mechanism where they attach events directly to the items.
90
- */
91
- if (tooltipEventType === "axis") {
92
- const activeProps = selectActivePropsFromChartPointer(store, latestChartPointer)
93
- if (activeProps?.activeIndex != null) {
94
- setTooltipInteraction(setStore, "axisInteraction", "hover", {
95
- active: true,
96
- coordinate: activeProps.activeCoordinate,
97
- dataKey: undefined,
98
- graphicalItemId: undefined,
99
- index: activeProps.activeIndex,
100
- })
101
- } else {
102
- /* Mouse moves inside svg but out of plot area — flip `active` only, mirror
103
- upstream mouseLeaveChart so coordinate/index survive for the active=true
104
- prop and animation tail. */
105
- setStore("tooltip", "axisInteraction", "hover", "active", false)
106
- setStore("tooltip", "itemInteraction", "hover", "active", false)
107
- }
108
- }
109
- rafId = null
110
- timeoutId = null
111
- }
112
-
113
- if (!isThrottled) {
114
- callback()
115
- return
116
- }
117
-
118
- if (throttleDelay === "raf") {
119
- rafId = requestAnimationFrame(callback)
120
- } else if (typeof throttleDelay === "number") {
121
- if (timeoutId === null) {
122
- timeoutId = setTimeout(callback, throttleDelay)
123
- }
124
- }
125
- }
126
-
127
- return { handleMouseClick, handleMouseMove }
128
- }
129
-
130
- /**
131
- * Action thunk wrappers for use with the dispatch pattern.
132
- * These delegate to the same logic as createMouseEventHandlers.
133
- */
134
- export const mouseClickAction =
135
- (mousePointer: HTMLMousePointer) =>
136
- (
137
- setStore: SetStoreFunction<ChartState>,
138
- store: ChartState,
139
- ) => {
140
- const activeProps = selectActivePropsFromChartPointer(
141
- store,
142
- getRelativeCoordinate(mousePointer),
143
- )
144
- if (activeProps?.activeIndex != null) {
145
- const payload = {
146
- active: true,
147
- coordinate: activeProps.activeCoordinate,
148
- dataKey: undefined,
149
- graphicalItemId: undefined,
150
- index: activeProps.activeIndex,
151
- }
152
- setTooltipInteraction(setStore, "axisInteraction", "click", payload)
153
- }
154
- }
155
-
156
- export const mouseMoveAction =
157
- (mousePointer: HTMLMousePointer) =>
158
- (
159
- setStore: SetStoreFunction<ChartState>,
160
- store: ChartState,
161
- ) => {
162
- const chartPointer = getRelativeCoordinate(mousePointer)
163
- const tooltipEventType = selectTooltipEventType(
164
- store,
165
- readChartState(store).tooltip.settings.shared,
166
- )
167
- if (tooltipEventType === "axis") {
168
- const activeProps = selectActivePropsFromChartPointer(store, chartPointer)
169
- if (activeProps?.activeIndex != null) {
170
- const payload = {
171
- active: true,
172
- coordinate: activeProps.activeCoordinate,
173
- dataKey: undefined,
174
- graphicalItemId: undefined,
175
- index: activeProps.activeIndex,
176
- }
177
- setTooltipInteraction(setStore, "axisInteraction", "hover", payload)
178
- } else {
179
- {
180
- setStore("tooltip", "axisInteraction", "hover", "active", false)
181
- setStore("tooltip", "itemInteraction", "hover", "active", false)
182
- }
183
- }
184
- }
185
- }
@@ -1,47 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { TooltipEventType } from "../util/types"
3
- import type { TooltipIndex, TooltipPayloadSearcher } from "./tooltipSlice"
4
- import { isNan } from "../util/DataUtils"
5
-
6
- /**
7
- * These chart options are decided internally, by Recharts,
8
- * and will not change during the lifetime of the chart.
9
- *
10
- * Changing these options can be done by swapping the root element
11
- * which will make a brand-new store.
12
- *
13
- * If you want to store options that can be changed by the user,
14
- * use UpdatableChartOptions in rootPropsSlice.ts.
15
- */
16
- export type ChartOptions = {
17
- chartName: string
18
- defaultTooltipEventType: TooltipEventType
19
- validateTooltipEventTypes?: ReadonlyArray<TooltipEventType>
20
- tooltipPayloadSearcher: TooltipPayloadSearcher
21
- /**
22
- * We use this to identify which chart is sending events when synchronising.
23
- * Without it, we can't tell the difference between an action that arrived from another chart
24
- * and an action that was dispatched by the chart itself.
25
- */
26
- eventEmitter: symbol | undefined
27
- }
28
-
29
- export const arrayTooltipSearcher: TooltipPayloadSearcher = (
30
- data: unknown,
31
- strIndex: TooltipIndex,
32
- ): unknown | undefined => {
33
- if (strIndex === null || strIndex === undefined) return undefined
34
- if (!Array.isArray(data)) return undefined
35
- const numIndex = Number.parseInt(strIndex, 10)
36
- if (isNan(numIndex)) {
37
- return undefined
38
- }
39
- return data[numIndex] as unknown
40
- }
41
-
42
- export const initialOptionsState: ChartOptions = {
43
- chartName: "",
44
- defaultTooltipEventType: "axis",
45
- eventEmitter: undefined,
46
- tooltipPayloadSearcher: () => undefined,
47
- }
@@ -1,10 +0,0 @@
1
- import type { AxisId, BaseCartesianAxis, TicksSettings } from "./cartesianAxisSlice"
2
-
3
- export type RadiusAxisSettings = BaseCartesianAxis & TicksSettings
4
-
5
- export type AngleAxisSettings = BaseCartesianAxis & TicksSettings
6
-
7
- export type PolarAxisState = {
8
- radiusAxis: Record<AxisId, RadiusAxisSettings>
9
- angleAxis: Record<AxisId, AngleAxisSettings>
10
- }
@@ -1,12 +0,0 @@
1
- export type PolarChartOptions = {
2
- cx: number | string
3
- cy: number | string
4
- endAngle: number
5
- innerRadius: number | string
6
- outerRadius: number | string
7
- startAngle: number
8
- }
9
-
10
- export type PolarChartState = PolarChartOptions | null
11
-
12
- export const initialPolarOptionsState: PolarChartState = null
@@ -1,26 +0,0 @@
1
- import { createStore, runWithOwner } from "solid-js"
2
-
3
- /**
4
- * Marks chart data as a raw record so the chart store serves it by reference instead of
5
- * wrapping every row in a proxy.
6
- *
7
- * Upstream treats chart data as immutable: a change replaces the whole array, and selectors
8
- * compare it by reference. A deep store would instead track each row field a selector reads,
9
- * so a derivation over N rows would subscribe to N × fields signals. A shallow store ingests
10
- * its values as raw records (Solid's sticky raw contract), after which no store wraps them; the
11
- * slot that holds the array still tracks replacement.
12
- *
13
- * Values that cannot be marked stay deep-tracked: proxies from a user store (Solid skips them),
14
- * and raw objects that already back a deep store (Solid throws, and exposes no query for it).
15
- */
16
- export function markRawData<T>(value: T): T {
17
- if (value == null || typeof value !== "object") {
18
- return value
19
- }
20
- try {
21
- runWithOwner(null, () => createStore({ value }, { shallow: true }))
22
- } catch {
23
- /* already backs a deep store: keep it deep-tracked */
24
- }
25
- return value
26
- }
@@ -1,40 +0,0 @@
1
- import type { AxisId } from "./cartesianAxisSlice"
2
- import type { IfOverflow } from "../util/IfOverflow"
3
- import type { ReferenceLineSegment } from "../cartesian/ReferenceLine"
4
-
5
- export type ReferenceElementSettings = {
6
- yAxisId: AxisId
7
- xAxisId: AxisId
8
- ifOverflow: IfOverflow
9
- }
10
-
11
- export type ReferenceDotSettings = ReferenceElementSettings & {
12
- x: unknown
13
- y: unknown
14
- r: number
15
- }
16
-
17
- export type ReferenceAreaSettings = ReferenceElementSettings & {
18
- x1: unknown
19
- x2: unknown
20
- y1: unknown
21
- y2: unknown
22
- }
23
-
24
- export type ReferenceLineSettings = ReferenceElementSettings & {
25
- x: unknown
26
- y: unknown
27
- segment: ReferenceLineSegment | undefined
28
- }
29
-
30
- export type ReferenceElementState = {
31
- dots: ReadonlyArray<ReferenceDotSettings>
32
- areas: ReadonlyArray<ReferenceAreaSettings>
33
- lines: ReadonlyArray<ReferenceLineSettings>
34
- }
35
-
36
- export const initialReferenceElementsState: ReferenceElementState = {
37
- areas: [],
38
- dots: [],
39
- lines: [],
40
- }
@@ -1,15 +0,0 @@
1
- import type { TickItem } from "../util/types"
2
- import type { AxisId } from "./cartesianAxisSlice"
3
-
4
- export type RenderedTicksAxisState = {
5
- [axisId: AxisId]: ReadonlyArray<TickItem>
6
- }
7
-
8
- export type RenderedTicksState = {
9
- xAxis: RenderedTicksAxisState
10
- yAxis: RenderedTicksAxisState
11
- }
12
-
13
- export function createInitialRenderedTicksState(): RenderedTicksState {
14
- return { xAxis: {}, yAxis: {} }
15
- }
@@ -1,47 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import { StackOffsetType } from "../util/types"
3
- import { SyncMethod } from "../synchronisation/types"
4
- import { BaseValue } from "../cartesian/Area"
5
-
6
- /**
7
- * These are chart options that users can choose - which means they can also
8
- * choose to change them which should trigger a re-render.
9
- */
10
- export type UpdatableChartOptions = {
11
- accessibilityLayer: boolean
12
- barCategoryGap: number | string
13
- barGap: number | string
14
- barSize: string | number | undefined
15
- baseValue: BaseValue | undefined
16
- /**
17
- * Useful for debugging which chart is which when synchronising.
18
- * The className is also passed to the root element of the chart but that's done in the JSX, not through Redux.
19
- */
20
- className: string | undefined
21
- maxBarSize: number | undefined
22
- /**
23
- * If false, stacked items will be rendered left to right. If true, stacked items will be rendered right to left.
24
- * (Render direction affects SVG layering, not x position.)
25
- */
26
- reverseStackOrder: boolean
27
- stackOffset: StackOffsetType
28
- /**
29
- * Charts that share the same syncId will have their Tooltip and Brush synchronised.
30
- */
31
- syncId: number | string | undefined
32
- syncMethod: SyncMethod
33
- }
34
-
35
- export const initialRootPropsState: UpdatableChartOptions = {
36
- accessibilityLayer: true,
37
- barCategoryGap: "10%",
38
- barGap: 4,
39
- barSize: undefined,
40
- baseValue: undefined,
41
- className: undefined,
42
- maxBarSize: undefined,
43
- reverseStackOrder: false,
44
- stackOffset: "none",
45
- syncId: undefined,
46
- syncMethod: "index",
47
- }
@@ -1,240 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { DataKey, NullableCoordinate } from "../../util/types"
3
- import { computeArea } from "../../cartesian/Area"
4
- import {
5
- selectAxisWithScale,
6
- selectStackGroups,
7
- selectTicksOfGraphicalItem,
8
- selectUnfilteredCartesianItems,
9
- } from "./axisSelectors"
10
- import type { ChartState } from "../store"
11
- import type { AxisId, XAxisSettings, YAxisSettings } from "../cartesianAxisSlice"
12
- import { selectChartLayout } from "../../context/chartLayoutContext"
13
- import { selectChartDataWithIndexesIfNotInPanoramaPosition3 } from "./dataSelectors"
14
- import { getBandSizeOfAxis, isCategoricalAxis, type StackId } from "../../util/ChartUtils"
15
- import { isNotNil } from "../../util/DataUtils"
16
- import type { ChartData } from "../chartDataSlice"
17
- import { getStackSeriesIdentifier } from "../../util/stacks/getStackSeriesIdentifier"
18
- import type {
19
- StackDataPoint,
20
- StackGroup,
21
- StackSeries,
22
- StackSeriesIdentifier,
23
- } from "../../util/stacks/stackTypes"
24
- import type { AreaSettings } from "../types/AreaSettings"
25
- import type { GraphicalItemId } from "../graphicalItemsSlice"
26
- import { selectChartBaseValue } from "./rootPropsSelectors"
27
- import { chartSelector } from "./chartSelector"
28
- import {
29
- selectXAxisIdFromGraphicalItemId,
30
- selectYAxisIdFromGraphicalItemId,
31
- } from "./graphicalItemSelectors"
32
-
33
- /** Optional overrides — bypass the axis-settings lookup on hot animation frames. */
34
- export type AreaAxisOverrides = {
35
- xAxis?: XAxisSettings
36
- yAxis?: YAxisSettings
37
- areaSettings?: AreaSettings
38
- }
39
-
40
- export interface AreaPointItem extends NullableCoordinate {
41
- x: number | null
42
- y: number | null
43
- value?: ReadonlyArray<unknown>
44
- payload?: unknown
45
- }
46
-
47
- export type ComputedArea = {
48
- points: ReadonlyArray<AreaPointItem>
49
- baseLine: number | ReadonlyArray<AreaPointItem>
50
- isRange: boolean
51
- }
52
-
53
- const selectXAxisWithScale = chartSelector((
54
- state: ChartState,
55
- graphicalItemId: GraphicalItemId,
56
- isPanorama: boolean,
57
- override?: XAxisSettings,
58
- ) =>
59
- selectAxisWithScale(
60
- state,
61
- "xAxis",
62
- selectXAxisIdFromGraphicalItemId(state, graphicalItemId),
63
- isPanorama,
64
- override,
65
- ))
66
-
67
- const selectXAxisTicks = chartSelector((
68
- state: ChartState,
69
- graphicalItemId: GraphicalItemId,
70
- isPanorama: boolean,
71
- ) =>
72
- selectTicksOfGraphicalItem(
73
- state,
74
- "xAxis",
75
- selectXAxisIdFromGraphicalItemId(state, graphicalItemId),
76
- isPanorama,
77
- ))
78
-
79
- const selectYAxisWithScale = chartSelector((
80
- state: ChartState,
81
- graphicalItemId: GraphicalItemId,
82
- isPanorama: boolean,
83
- override?: YAxisSettings,
84
- ) =>
85
- selectAxisWithScale(
86
- state,
87
- "yAxis",
88
- selectYAxisIdFromGraphicalItemId(state, graphicalItemId),
89
- isPanorama,
90
- override,
91
- ))
92
-
93
- const selectYAxisTicks = chartSelector((
94
- state: ChartState,
95
- graphicalItemId: GraphicalItemId,
96
- isPanorama: boolean,
97
- ) =>
98
- selectTicksOfGraphicalItem(
99
- state,
100
- "yAxis",
101
- selectYAxisIdFromGraphicalItemId(state, graphicalItemId),
102
- isPanorama,
103
- ))
104
-
105
- const selectBandSize = chartSelector(function selectBandSize(state: ChartState, graphicalItemId: GraphicalItemId, isPanorama: boolean, overrides?: AreaAxisOverrides) {
106
- const layout = selectChartLayout(state)
107
- const xAxis = selectXAxisWithScale(state, graphicalItemId, isPanorama, overrides?.xAxis)
108
- const yAxis = selectYAxisWithScale(state, graphicalItemId, isPanorama, overrides?.yAxis)
109
- const xAxisTicks = selectXAxisTicks(state, graphicalItemId, isPanorama)
110
- const yAxisTicks = selectYAxisTicks(state, graphicalItemId, isPanorama)
111
- if (isCategoricalAxis(layout, "xAxis")) {
112
- return getBandSizeOfAxis(xAxis, xAxisTicks, false)
113
- }
114
- return getBandSizeOfAxis(yAxis, yAxisTicks, false)
115
- })
116
-
117
- const selectSynchronisedAreaSettings = chartSelector(function selectSynchronisedAreaSettings(state: ChartState, id: GraphicalItemId): AreaSettings | undefined {
118
- const graphicalItems = selectUnfilteredCartesianItems(state)
119
- return graphicalItems.filter((item) => item.type === "area").find((item) => item.id === id) as
120
- | AreaSettings
121
- | undefined
122
- })
123
-
124
- const selectNumericalAxisType = chartSelector((state: ChartState): "xAxis" | "yAxis" => {
125
- const layout = selectChartLayout(state)
126
- const isXAxisCategorical = isCategoricalAxis(layout, "xAxis")
127
- return isXAxisCategorical ? "yAxis" : "xAxis"
128
- })
129
-
130
- const selectNumericalAxisIdFromGraphicalItemId = chartSelector((
131
- state: ChartState,
132
- graphicalItemId: GraphicalItemId,
133
- ): AxisId => {
134
- const axisType = selectNumericalAxisType(state)
135
- if (axisType === "yAxis") {
136
- return selectYAxisIdFromGraphicalItemId(state, graphicalItemId)
137
- }
138
- return selectXAxisIdFromGraphicalItemId(state, graphicalItemId)
139
- })
140
-
141
- const selectNumericalAxisStackGroups = chartSelector((
142
- state: ChartState,
143
- graphicalItemId: GraphicalItemId,
144
- isPanorama: boolean,
145
- ): Record<StackId, StackGroup> | undefined =>
146
- selectStackGroups(
147
- state,
148
- selectNumericalAxisType(state),
149
- selectNumericalAxisIdFromGraphicalItemId(state, graphicalItemId),
150
- isPanorama,
151
- ))
152
-
153
- export const selectGraphicalItemStackedData = chartSelector(function selectGraphicalItemStackedData(state: ChartState, id: GraphicalItemId, isPanorama: boolean): ReadonlyArray<StackDataPoint> | undefined {
154
- const areaSettings = selectSynchronisedAreaSettings(state, id)
155
- const stackGroups = selectNumericalAxisStackGroups(state, id, isPanorama)
156
- if (areaSettings == null || stackGroups == null) {
157
- return undefined
158
- }
159
- const { stackId } = areaSettings
160
- const stackSeriesIdentifier: StackSeriesIdentifier | undefined =
161
- getStackSeriesIdentifier(areaSettings)
162
- if (stackId == null || stackSeriesIdentifier == null) {
163
- return undefined
164
- }
165
- const groups: ReadonlyArray<StackSeries> | undefined = stackGroups[stackId]?.stackedData
166
- const found: StackSeries | undefined = groups?.find((v) => v.key === stackSeriesIdentifier)
167
- if (found == null) {
168
- return undefined
169
- }
170
- return found.map((item): StackDataPoint => [item[0], item[1]])
171
- })
172
-
173
- const selectStackDataKeys = chartSelector(function selectStackDataKeys(state: ChartState, id: GraphicalItemId, isPanorama: boolean): ReadonlyArray<DataKey<unknown>> | undefined {
174
- const areaSettings = selectSynchronisedAreaSettings(state, id)
175
- const stackGroups = selectNumericalAxisStackGroups(state, id, isPanorama)
176
- if (areaSettings == null || areaSettings.stackId == null || stackGroups == null) {
177
- return undefined
178
- }
179
- const group: StackGroup | undefined = stackGroups[areaSettings.stackId]
180
- if (group == null) {
181
- return undefined
182
- }
183
- return group.graphicalItems.map((item) => item.dataKey).filter(isNotNil)
184
- })
185
-
186
- export const selectArea = chartSelector(function selectArea(state: ChartState, id: GraphicalItemId, isPanorama: boolean, overrides?: AreaAxisOverrides): ComputedArea | undefined {
187
- const layout = selectChartLayout(state)
188
- const xAxis = selectXAxisWithScale(state, id, isPanorama, overrides?.xAxis)
189
- const yAxis = selectYAxisWithScale(state, id, isPanorama, overrides?.yAxis)
190
- const xAxisTicks = selectXAxisTicks(state, id, isPanorama)
191
- const yAxisTicks = selectYAxisTicks(state, id, isPanorama)
192
- const stackedData = selectGraphicalItemStackedData(state, id, isPanorama)
193
- const { chartData, dataStartIndex, dataEndIndex } =
194
- selectChartDataWithIndexesIfNotInPanoramaPosition3(state, undefined, isPanorama)
195
- const bandSize = selectBandSize(state, id, isPanorama, overrides)
196
- const areaSettings = overrides?.areaSettings ?? selectSynchronisedAreaSettings(state, id)
197
- const chartBaseValue = selectChartBaseValue(state)
198
- const stackDataKeys = selectStackDataKeys(state, id, isPanorama)
199
-
200
- if (
201
- areaSettings == null ||
202
- (layout !== "horizontal" && layout !== "vertical") ||
203
- xAxis == null ||
204
- yAxis == null ||
205
- xAxisTicks == null ||
206
- yAxisTicks == null ||
207
- xAxisTicks.length === 0 ||
208
- yAxisTicks.length === 0 ||
209
- bandSize == null
210
- ) {
211
- return undefined
212
- }
213
- const { data } = areaSettings
214
-
215
- let displayedData: ChartData | undefined
216
- if (data && data.length > 0) {
217
- displayedData = data
218
- } else {
219
- displayedData = chartData?.slice(dataStartIndex, dataEndIndex + 1)
220
- }
221
-
222
- if (displayedData == null) {
223
- return undefined
224
- }
225
-
226
- return computeArea({
227
- areaSettings,
228
- bandSize,
229
- chartBaseValue,
230
- dataStartIndex,
231
- displayedData,
232
- layout,
233
- stackedData,
234
- stackDataKeys,
235
- xAxis,
236
- xAxisTicks,
237
- yAxis,
238
- yAxisTicks,
239
- })
240
- })
@@ -1,29 +0,0 @@
1
- /**
2
- * Checks if two arrays are equal, treating empty arrays as equal regardless of reference.
3
- * If both arrays are non-empty, it checks for reference equality.
4
- * @param a
5
- * @param b
6
- */
7
- export function emptyArraysAreEqualCheck<T>(a: ReadonlyArray<T>, b: ReadonlyArray<T>): boolean {
8
- if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {
9
- return true
10
- }
11
- return a === b
12
- }
13
-
14
- /**
15
- * Checks if two arrays have the same contents in the same order.
16
- * @param a
17
- * @param b
18
- */
19
- export function arrayContentsAreEqualCheck<T>(a: ReadonlyArray<T>, b: ReadonlyArray<T>): boolean {
20
- if (a.length === b.length) {
21
- for (let i = 0; i < a.length; i++) {
22
- if (a[i] !== b[i]) {
23
- return false
24
- }
25
- }
26
- return true
27
- }
28
- return false
29
- }