solid-recharts 0.1.0 → 0.2.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 (279) hide show
  1. package/LICENSE +24 -0
  2. package/package.json +10 -7
  3. package/src/cartesian/Area.tsx +40 -55
  4. package/src/cartesian/Bar.tsx +66 -58
  5. package/src/cartesian/BarStack.tsx +5 -2
  6. package/src/cartesian/Brush.tsx +1 -1
  7. package/src/cartesian/Funnel.tsx +15 -19
  8. package/src/cartesian/Line.tsx +34 -51
  9. package/src/cartesian/LineDrawShape.tsx +8 -6
  10. package/src/cartesian/ReferenceArea.tsx +25 -35
  11. package/src/cartesian/ReferenceDot.tsx +24 -34
  12. package/src/cartesian/ReferenceLine.tsx +25 -34
  13. package/src/cartesian/Scatter.tsx +25 -37
  14. package/src/cartesian/XAxis.tsx +54 -67
  15. package/src/cartesian/YAxis.tsx +53 -66
  16. package/src/cartesian/ZAxis.tsx +27 -40
  17. package/src/chart/SunburstChart.tsx +1 -1
  18. package/src/component/ActivePoints.tsx +0 -9
  19. package/src/component/Customized.tsx +1 -1
  20. package/src/component/Dots.tsx +7 -3
  21. package/src/context/ErrorBarContext.tsx +15 -24
  22. package/src/polar/Pie.tsx +36 -48
  23. package/src/polar/PolarAngleAxis.tsx +41 -50
  24. package/src/polar/PolarRadiusAxis.tsx +40 -48
  25. package/src/polar/Radar.tsx +22 -34
  26. package/src/polar/RadialBar.tsx +21 -39
  27. package/src/shape/Curve.tsx +1 -1
  28. package/src/shape/Symbols.tsx +1 -1
  29. package/src/state/RechartsReduxContext.tsx +1 -1
  30. package/src/state/SetLegendPayload.ts +19 -27
  31. package/src/state/SetTooltipEntrySettings.tsx +9 -26
  32. package/src/state/cartesianAxisSlice.ts +40 -60
  33. package/src/state/createCollectionActions.ts +51 -0
  34. package/src/state/createSelector.ts +97 -0
  35. package/src/state/externalEventsMiddleware.ts +2 -11
  36. package/src/state/graphicalItemsSlice.ts +27 -40
  37. package/src/state/isEventThrottled.ts +12 -0
  38. package/src/state/keyboardEventsMiddleware.ts +2 -8
  39. package/src/state/layoutSlice.ts +8 -4
  40. package/src/state/legendSlice.ts +24 -26
  41. package/src/state/mouseEventsMiddleware.ts +2 -13
  42. package/src/state/patched.ts +19 -0
  43. package/src/state/referenceElementsSlice.ts +40 -31
  44. package/src/state/registerInStore.ts +68 -0
  45. package/src/state/selectors/areaSelectors.ts +13 -36
  46. package/src/state/selectors/arrayEqualityCheck.ts +32 -7
  47. package/src/state/selectors/axisSelectors.ts +215 -169
  48. package/src/state/selectors/barSelectors.ts +8 -36
  49. package/src/state/selectors/combiners/combineConfiguredScale.ts +1 -1
  50. package/src/state/selectors/combiners/combineRealScaleType.ts +1 -1
  51. package/src/state/selectors/dataSelectors.ts +35 -16
  52. package/src/state/selectors/numberDomainEqualityCheck.ts +16 -8
  53. package/src/state/selectors/selectAxisForGraphicalItem.ts +52 -0
  54. package/src/state/store.ts +0 -1
  55. package/src/state/tooltipSlice.ts +93 -64
  56. package/src/util/ActiveShapeUtils.tsx +0 -7
  57. package/src/util/BarUtils.tsx +27 -22
  58. package/src/util/ChartUtils.ts +69 -25
  59. package/src/util/propsAreEqual.ts +3 -33
  60. package/src/util/stacks/stackTypes.ts +1 -1
  61. package/src/util/types.ts +2 -2
  62. package/test/animation/CSSTransitionAnimate.timing.spec.tsx +1 -1
  63. package/test/animation/JavascriptAnimate.spec.tsx +1 -1
  64. package/test/animation/legacyAnimationLengthChange.spec.tsx +1 -1
  65. package/test/cartesian/Area.animation.spec.tsx +1 -1
  66. package/test/cartesian/Area.range.spec.tsx +1 -1
  67. package/test/cartesian/Area.spec.tsx +1 -1
  68. package/test/cartesian/Area.stacked.render.spec.tsx +1 -1
  69. package/test/cartesian/Area.typed.spec.tsx +1 -1
  70. package/test/cartesian/Axis.integration.spec.tsx +1 -1
  71. package/test/cartesian/Bar/Bar.csstransition.spec.tsx +1 -1
  72. package/test/cartesian/Bar/Bar.spec.tsx +1 -1
  73. package/test/cartesian/Bar/Bar.typed.spec.tsx +1 -1
  74. package/test/cartesian/Bar.animation.spec.tsx +1 -1
  75. package/test/cartesian/Bar.stackDomain.spec.tsx +1 -1
  76. package/test/cartesian/Bar.stacked.render.spec.tsx +1 -1
  77. package/test/cartesian/Bar.zeroDimensionFiltering.spec.tsx +1 -1
  78. package/test/cartesian/Brush.keyboard.spec.tsx +1 -1
  79. package/test/cartesian/Brush.panorama.spec.tsx +1 -1
  80. package/test/cartesian/Brush.props.spec.tsx +1 -1
  81. package/test/cartesian/Brush.render.spec.tsx +1 -1
  82. package/test/cartesian/Brush.spec.tsx +1 -1
  83. package/test/cartesian/Brush.stacked.spec.tsx +1 -1
  84. package/test/cartesian/CartesianAxis.render.spec.tsx +1 -1
  85. package/test/cartesian/CartesianAxis.spec.tsx +2 -2
  86. package/test/cartesian/CartesianGrid.render.spec.tsx +1 -1
  87. package/test/cartesian/CartesianGrid.spec.tsx +1 -1
  88. package/test/cartesian/ErrorBar.render.spec.tsx +1 -1
  89. package/test/cartesian/ErrorBar.spec.tsx +1 -1
  90. package/test/cartesian/Funnel.animation.spec.tsx +1 -1
  91. package/test/cartesian/Funnel.spec.tsx +1 -1
  92. package/test/cartesian/Funnel.typed.spec.tsx +1 -1
  93. package/test/cartesian/GraphicalItemClipPath.scale-behavior.spec.tsx +2 -2
  94. package/test/cartesian/Line.animation.spec.tsx +1 -1
  95. package/test/cartesian/Line.sparseAnimationPath.spec.tsx +1 -1
  96. package/test/cartesian/Line.spec.tsx +1 -1
  97. package/test/cartesian/Line.typed.spec.tsx +1 -1
  98. package/test/cartesian/ReferenceArea.render.spec.tsx +1 -1
  99. package/test/cartesian/ReferenceArea.spec.tsx +1 -1
  100. package/test/cartesian/ReferenceArea.typed.spec.tsx +1 -1
  101. package/test/cartesian/ReferenceDot.render.spec.tsx +1 -1
  102. package/test/cartesian/ReferenceDot.spec.tsx +1 -1
  103. package/test/cartesian/ReferenceDot.typed.spec.tsx +1 -1
  104. package/test/cartesian/ReferenceLine/ReferenceLine.panorama.spec.tsx +1 -1
  105. package/test/cartesian/ReferenceLine/ReferenceLine.spec.tsx +1 -1
  106. package/test/cartesian/ReferenceLine/ReferenceLine.typed.spec.tsx +1 -1
  107. package/test/cartesian/ReferenceLine/getEndPoints.spec.ts +1 -1
  108. package/test/cartesian/ReferenceLine.render.spec.tsx +1 -1
  109. package/test/cartesian/Scatter.animation.spec.tsx +1 -1
  110. package/test/cartesian/Scatter.render.spec.tsx +1 -1
  111. package/test/cartesian/Scatter.spec.tsx +1 -1
  112. package/test/cartesian/Scatter.typed.spec.tsx +1 -1
  113. package/test/cartesian/XAxis/XAxis.barSize.spec.tsx +1 -1
  114. package/test/cartesian/XAxis/XAxis.brush.spec.tsx +1 -1
  115. package/test/cartesian/XAxis/XAxis.categorydomain.spec.tsx +1 -1
  116. package/test/cartesian/XAxis/XAxis.datatypes.spec.tsx +1 -1
  117. package/test/cartesian/XAxis/XAxis.hide.spec.tsx +1 -1
  118. package/test/cartesian/XAxis/XAxis.multiaxis.spec.tsx +1 -1
  119. package/test/cartesian/XAxis/XAxis.numberdomain.spec.tsx +1 -1
  120. package/test/cartesian/XAxis/XAxis.padding.spec.tsx +1 -1
  121. package/test/cartesian/XAxis/XAxis.padding_clip.spec.tsx +1 -1
  122. package/test/cartesian/XAxis/XAxis.state.spec.tsx +1 -1
  123. package/test/cartesian/XAxis/XAxis.tick.spec.tsx +1 -1
  124. package/test/cartesian/XAxis/XAxis.timescale.spec.tsx +2 -2
  125. package/test/cartesian/XAxis/XAxis.typed.spec.tsx +1 -1
  126. package/test/cartesian/XAxis/XAxis.vertical.spec.tsx +1 -1
  127. package/test/cartesian/XAxis.tickFormatter.spec.tsx +1 -1
  128. package/test/cartesian/YAxis/YAxis.7362.derivedDomain.spec.tsx +1 -1
  129. package/test/cartesian/YAxis/YAxis.interval-zero.spec.tsx +1 -1
  130. package/test/cartesian/YAxis/YAxis.label.spec.tsx +1 -1
  131. package/test/cartesian/YAxis/YAxis.spec.tsx +1 -1
  132. package/test/cartesian/YAxis/YAxis.tick.spec.tsx +1 -1
  133. package/test/cartesian/YAxis/YAxis.tickFormatter.spec.tsx +1 -1
  134. package/test/cartesian/YAxis/YAxis.typed.spec.tsx +1 -1
  135. package/test/cartesian/ZAxis.spec.tsx +1 -1
  136. package/test/cartesian/ZAxis.typed.spec.tsx +1 -1
  137. package/test/cartesian/axisLineAndStroke.spec.tsx +1 -1
  138. package/test/cartesian/miscFeatureGaps.spec.tsx +1 -1
  139. package/test/chart/AccessibilityLayer.spec.tsx +1 -1
  140. package/test/chart/AccessibilityScans.spec.tsx +2 -2
  141. package/test/chart/AreaChart.spec.tsx +1 -1
  142. package/test/chart/AreaChart.typed.spec.tsx +1 -1
  143. package/test/chart/BarChart.spec.tsx +1 -1
  144. package/test/chart/BarChart.typed.spec.tsx +1 -1
  145. package/test/chart/CategoricalChart.spec.tsx +1 -1
  146. package/test/chart/ComposedChart.spec.tsx +1 -1
  147. package/test/chart/ComposedChart.typed.spec.tsx +1 -1
  148. package/test/chart/FunnelChart.spec.tsx +1 -1
  149. package/test/chart/FunnelChart.typed.spec.tsx +1 -1
  150. package/test/chart/LineChart.smoke.spec.tsx +1 -1
  151. package/test/chart/LineChart.spec.tsx +1 -1
  152. package/test/chart/LineChart.typed.spec.tsx +1 -1
  153. package/test/chart/NicheChartTooltip.spec.tsx +1 -1
  154. package/test/chart/PieChart.spec.tsx +1 -1
  155. package/test/chart/PieChart.typed.spec.tsx +1 -1
  156. package/test/chart/RadarChart.spec.tsx +1 -1
  157. package/test/chart/RadarChart.typed.spec.tsx +1 -1
  158. package/test/chart/RadialBarChart.spec.tsx +1 -1
  159. package/test/chart/RadialBarChart.typed.spec.tsx +1 -1
  160. package/test/chart/RechartsWrapper.spec.tsx +1 -1
  161. package/test/chart/Sankey.content.spec.tsx +1 -1
  162. package/test/chart/Sankey.spec.tsx +1 -1
  163. package/test/chart/ScatterChart.spec.tsx +1 -1
  164. package/test/chart/ScatterChart.typed.spec.tsx +1 -1
  165. package/test/chart/SunburstChart.spec.tsx +1 -1
  166. package/test/chart/Treemap.animation.spec.tsx +1 -1
  167. package/test/chart/Treemap.spec.tsx +1 -1
  168. package/test/chart/chartEvents.spec.tsx +1 -1
  169. package/test/chart/responsive.spec.tsx +1 -1
  170. package/test/component/Cell.render.spec.tsx +1 -1
  171. package/test/component/Cell.spec.tsx +1 -1
  172. package/test/component/Cursor.spec.tsx +1 -1
  173. package/test/component/DefaultTooltipContent.spec.tsx +1 -1
  174. package/test/component/Label.render.spec.tsx +1 -1
  175. package/test/component/Label.spec.tsx +1 -1
  176. package/test/component/LabelList.spec.tsx +1 -1
  177. package/test/component/Legend.itemSorter.spec.tsx +1 -1
  178. package/test/component/Legend.render.spec.tsx +1 -1
  179. package/test/component/Legend.spec.tsx +1 -1
  180. package/test/component/ResponsiveContainer.spec.tsx +1 -1
  181. package/test/component/ResponsiveContainerDataTest.spec.tsx +1 -1
  182. package/test/component/Text.spec.tsx +1 -1
  183. package/test/component/Tooltip/ActiveDot.spec.tsx +1 -1
  184. package/test/component/Tooltip/tooltipEventType.spec.tsx +1 -1
  185. package/test/component/Tooltip/tooltipTestHelpers.tsx +1 -1
  186. package/test/component/Tooltip.defaultIndex.spec.tsx +1 -1
  187. package/test/component/Tooltip.hover.spec.tsx +1 -1
  188. package/test/component/Tooltip.item.spec.tsx +1 -1
  189. package/test/component/Tooltip.keyboard.spec.tsx +1 -1
  190. package/test/component/Tooltip.payload.spec.tsx +1 -1
  191. package/test/component/Tooltip.touch.spec.tsx +1 -1
  192. package/test/component/Tooltip.visibility.spec.tsx +1 -1
  193. package/test/component/TooltipBoundingBox.spec.tsx +2 -2
  194. package/test/container/ClipPath.spec.tsx +1 -1
  195. package/test/context/chartLayoutContext.spec.tsx +1 -1
  196. package/test/helper/createSelectorTestCase.tsx +1 -1
  197. package/test/helper/mockAxes.ts +1 -1
  198. package/test/helper/selectorTestHelpers.tsx +1 -1
  199. package/test/hooks/useActiveTooltipDataPoints.spec.tsx +1 -1
  200. package/test/hooks/useOffset.spec.tsx +1 -1
  201. package/test/hooks/useTooltipStateHooks.spec.tsx +1 -1
  202. package/test/polar/Pie/Pie-TwoLevelPieChart.spec.tsx +1 -1
  203. package/test/polar/Pie/Pie.spec.tsx +1 -1
  204. package/test/polar/Pie/Pie.typed.spec.tsx +1 -1
  205. package/test/polar/Pie.animation.spec.tsx +1 -1
  206. package/test/polar/PieWithLegend.animation.spec.tsx +1 -1
  207. package/test/polar/PolarAngleAxis/PolarAngleAxis.events.spec.tsx +1 -1
  208. package/test/polar/PolarAngleAxis/PolarAngleAxis.spec.tsx +1 -1
  209. package/test/polar/PolarAngleAxis/PolarAngleAxis.typed.spec.tsx +1 -1
  210. package/test/polar/PolarAngleAxis.render.spec.tsx +1 -1
  211. package/test/polar/PolarGrid.render.spec.tsx +1 -1
  212. package/test/polar/PolarGrid.spec.tsx +1 -1
  213. package/test/polar/PolarLegendPerRow.render.spec.tsx +1 -1
  214. package/test/polar/PolarRadiusAxis.events.spec.tsx +1 -1
  215. package/test/polar/PolarRadiusAxis.render.spec.tsx +1 -1
  216. package/test/polar/PolarRadiusAxis.spec.tsx +1 -1
  217. package/test/polar/PolarRadiusAxis.typed.spec.tsx +1 -1
  218. package/test/polar/PolarTooltipLegend.render.spec.tsx +1 -1
  219. package/test/polar/Radar.animation.spec.tsx +1 -1
  220. package/test/polar/Radar.render.spec.tsx +1 -1
  221. package/test/polar/Radar.spec.tsx +1 -1
  222. package/test/polar/Radar.typed.spec.tsx +1 -1
  223. package/test/polar/RadialBar/RadialBar.spec.tsx +1 -1
  224. package/test/polar/RadialBar/RadialBar.typed.spec.tsx +1 -1
  225. package/test/polar/RadialBar.animation.spec.tsx +1 -1
  226. package/test/polar/RadialBar.render.spec.tsx +1 -1
  227. package/test/polar/RadialBar.stacked.spec.tsx +1 -1
  228. package/test/setup.ts +1 -1
  229. package/test/shape/ActiveShape.spec.tsx +1 -1
  230. package/test/shape/Cross.spec.tsx +1 -1
  231. package/test/shape/Curve.spec.tsx +2 -2
  232. package/test/shape/Curve.typed.spec.tsx +1 -1
  233. package/test/shape/Dot.spec.tsx +1 -1
  234. package/test/shape/Polygon.spec.tsx +1 -1
  235. package/test/shape/Rectangle.animation.spec.tsx +1 -1
  236. package/test/shape/Rectangle.spec.tsx +1 -1
  237. package/test/shape/Sector.spec.tsx +1 -1
  238. package/test/shape/Symbols.spec.tsx +1 -1
  239. package/test/shape/Trapezoid.spec.tsx +1 -1
  240. package/test/state/createCollectionActions.spec.ts +87 -0
  241. package/test/state/createSelector.spec.ts +158 -0
  242. package/test/state/hooks.spec.tsx +1 -1
  243. package/test/state/registerInStore.spec.tsx +101 -0
  244. package/test/state/selectors/axisSelectors.spec.tsx +1 -1
  245. package/test/state/selectors/combiners/combineConfiguredScale.spec.ts +1 -1
  246. package/test/state/selectors/combiners/combineRealScaleType.spec.ts +1 -1
  247. package/test/state/selectors/dataSelectors.spec.tsx +1 -1
  248. package/test/state/selectors/legendSelectors.spec.tsx +1 -1
  249. package/test/state/selectors/radarSelectors.spec.tsx +1 -1
  250. package/test/state/selectors/selectActiveTooltipIndex.spec.tsx +1 -1
  251. package/test/state/selectors/selectDisplayedData.spec.tsx +1 -1
  252. package/test/state/selectors/selectStackGroups.spec.tsx +1 -1
  253. package/test/state/selectors/selectorMemoization.spec.tsx +136 -0
  254. package/test/state/selectors/selectors.spec.tsx +1 -1
  255. package/test/util/CartesianUtils/CartesianUtils.spec.ts +1 -1
  256. package/test/util/ChartUtils/ChartUtils.spec.ts +1 -1
  257. package/test/util/ChartUtils/getCateCoordinateOfLine.spec.ts +14 -0
  258. package/test/util/ChartUtils/getStackedData.spec.ts +1 -1
  259. package/test/util/ChartUtils/truncateByDomain.spec.ts +1 -1
  260. package/test/util/DomUtils.spec.tsx +1 -1
  261. package/test/util/FunnelUtils.spec.tsx +1 -1
  262. package/test/util/scale/createCategoricalInverse.spec.ts +1 -1
  263. package/test/util/useElementOffset.spec.tsx +1 -1
  264. package/test/util/usePrefersReducedMotion.spec.ts +1 -1
  265. package/test/util/useUniqueId.spec.ts +1 -1
  266. package/test/zIndex/AllZIndexPortals.spec.tsx +1 -1
  267. package/test/zIndex/DynamicZIndex.spec.tsx +1 -1
  268. package/test/zIndex/ZIndexLayer.portalOwner.spec.tsx +1 -1
  269. package/test/zIndex/componentZIndex.spec.tsx +1 -1
  270. package/test/zIndex/multiChartZIndexIsolation.spec.tsx +1 -1
  271. package/test-results/.last-run.json +4 -0
  272. package/NEXT_SESSION_PROMPT.md +0 -114
  273. package/src/state/reduxDevtoolsJsonStringifyReplacer.ts +0 -15
  274. package/src/util/axisPropsAreEqual.ts +0 -42
  275. package/src/util/resolveDefaultProps.tsx +0 -8
  276. package/src/util/typedDataKey.ts +0 -8
  277. package/test/helper/render.ts +0 -7
  278. package/test/state/reduxDevtoolsJsonStringifyReplacer.spec.ts +0 -25
  279. package/test/util/axisPropsAreEqual.spec.ts +0 -93
@@ -16,7 +16,7 @@
16
16
  // - PERMANENT-N/A (by design, NOT deferred): the custom-element `shape` branch
17
17
  // (React.cloneElement — use the render-function form). <Label>
18
18
  // CHILDREN are not rendered (the `label` prop is).
19
- import { createEffect, createMemo, merge, Show } from "solid-js";
19
+ import { createMemo, merge, Show } from "solid-js";
20
20
  import type { JSX } from "@solidjs/web";
21
21
  import { Layer } from "../container/Layer";
22
22
  import {
@@ -41,7 +41,7 @@ import { CartesianScaleHelperImpl } from "../util/scale/CartesianScaleHelper";
41
41
  import type { AxisId } from "../state/cartesianAxisSlice";
42
42
  import { DefaultZIndexes } from "../zIndex/DefaultZIndexes";
43
43
  import { ZIndexLayer } from "../zIndex/ZIndexLayer";
44
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
44
+ import { registerInStore } from "../state/registerInStore";
45
45
 
46
46
  type ReferenceCoordinateValue = number | string;
47
47
 
@@ -124,39 +124,29 @@ const renderRect = (option: ReferenceAreaProps["shape"], props: RectangleProps):
124
124
 
125
125
  function ReportReferenceArea(props: ReferenceAreaSettings): JSX.Element {
126
126
  const store = useAppStore();
127
- let prev: ReferenceAreaSettings | null = null;
128
-
129
- createEffect(
130
- (): ReferenceAreaSettings => ({
131
- id: props.id,
132
- xAxisId: props.xAxisId,
133
- yAxisId: props.yAxisId,
134
- ifOverflow: props.ifOverflow,
135
- x1: props.x1,
136
- x2: props.x2,
137
- y1: props.y1,
138
- y2: props.y2,
139
- }),
140
- (settings) => {
141
- if (store == null) {
142
- return;
143
- }
144
- if (prev === null) {
145
- store.actions.referenceElements.addArea(settings);
146
- } else if (prev !== settings) {
147
- store.actions.referenceElements.removeArea(prev);
148
- store.actions.referenceElements.addArea(settings);
149
- }
150
- prev = settings;
151
- },
152
- );
153
-
154
- unregisterOnCleanup(() => {
155
- if (prev && store != null) {
156
- store.actions.referenceElements.removeArea(prev);
157
- prev = null;
158
- }
159
- });
127
+ if (store != null) {
128
+ registerInStore<ReferenceAreaSettings>(
129
+ () => ({
130
+ id: props.id,
131
+ xAxisId: props.xAxisId,
132
+ yAxisId: props.yAxisId,
133
+ ifOverflow: props.ifOverflow,
134
+ x1: props.x1,
135
+ x2: props.x2,
136
+ y1: props.y1,
137
+ y2: props.y2,
138
+ }),
139
+ {
140
+ add: (next) => store.actions.referenceElements.addArea(next),
141
+ // No replace action on the slice; a change is remove-then-add (recharts idiom).
142
+ replace: (prev, next) => {
143
+ store.actions.referenceElements.removeArea(prev);
144
+ store.actions.referenceElements.addArea(next);
145
+ },
146
+ remove: (prev) => store.actions.referenceElements.removeArea(prev),
147
+ },
148
+ );
149
+ }
160
150
 
161
151
  return null;
162
152
  }
@@ -12,7 +12,7 @@
12
12
  // - PERMANENT-N/A (by design, NOT deferred): the custom-element `shape` branch
13
13
  // (React.cloneElement — use the render-function form);
14
14
  // `children` is not rendered (CartesianLabelContext).
15
- import { createEffect, createMemo, merge, Show } from "solid-js";
15
+ import { createMemo, merge, Show } from "solid-js";
16
16
  import type { JSX } from "@solidjs/web";
17
17
  import { Layer } from "../container/Layer";
18
18
  import { Dot, type DotProps } from "../shape/Dot";
@@ -36,7 +36,7 @@ import { DefaultZIndexes } from "../zIndex/DefaultZIndexes";
36
36
  import { ZIndexLayer } from "../zIndex/ZIndexLayer";
37
37
  import { Coordinate } from "../util/types";
38
38
  import { CartesianScaleHelperImpl } from "../util/scale/CartesianScaleHelper";
39
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
39
+ import { registerInStore } from "../state/registerInStore";
40
40
 
41
41
  type ReferenceCoordinateValue = number | string;
42
42
 
@@ -130,38 +130,28 @@ export type Props<
130
130
 
131
131
  function ReportReferenceDot(props: ReferenceDotSettings): JSX.Element {
132
132
  const store = useAppStore();
133
- let prev: ReferenceDotSettings | null = null;
134
-
135
- createEffect(
136
- (): ReferenceDotSettings => ({
137
- id: props.id,
138
- xAxisId: props.xAxisId,
139
- yAxisId: props.yAxisId,
140
- ifOverflow: props.ifOverflow,
141
- x: props.x,
142
- y: props.y,
143
- r: props.r,
144
- }),
145
- (settings) => {
146
- if (store == null) {
147
- return;
148
- }
149
- if (prev === null) {
150
- store.actions.referenceElements.addDot(settings);
151
- } else if (prev !== settings) {
152
- store.actions.referenceElements.removeDot(prev);
153
- store.actions.referenceElements.addDot(settings);
154
- }
155
- prev = settings;
156
- },
157
- );
158
-
159
- unregisterOnCleanup(() => {
160
- if (prev && store != null) {
161
- store.actions.referenceElements.removeDot(prev);
162
- prev = null;
163
- }
164
- });
133
+ if (store != null) {
134
+ registerInStore<ReferenceDotSettings>(
135
+ () => ({
136
+ id: props.id,
137
+ xAxisId: props.xAxisId,
138
+ yAxisId: props.yAxisId,
139
+ ifOverflow: props.ifOverflow,
140
+ x: props.x,
141
+ y: props.y,
142
+ r: props.r,
143
+ }),
144
+ {
145
+ add: (next) => store.actions.referenceElements.addDot(next),
146
+ // No replace action on the slice; a change is remove-then-add (recharts idiom).
147
+ replace: (prev, next) => {
148
+ store.actions.referenceElements.removeDot(prev);
149
+ store.actions.referenceElements.addDot(next);
150
+ },
151
+ remove: (prev) => store.actions.referenceElements.removeDot(prev),
152
+ },
153
+ );
154
+ }
165
155
 
166
156
  return null;
167
157
  }
@@ -16,7 +16,7 @@
16
16
  // render-function form; the default-`<line>` branch is kept). <Label> CHILDREN
17
17
  // are not rendered (the `label` prop is).
18
18
  import { type CamelSvgProps } from "../util/svgPropertiesNoEvents";
19
- import { createEffect, createMemo, merge, Show } from "solid-js";
19
+ import { createMemo, merge, Show } from "solid-js";
20
20
  import type { JSX } from "@solidjs/web";
21
21
  import { Layer } from "../container/Layer";
22
22
  import {
@@ -46,7 +46,7 @@ import { CartesianScaleHelper, CartesianScaleHelperImpl } from "../util/scale/Ca
46
46
  import type { AxisId } from "../state/cartesianAxisSlice";
47
47
  import { DefaultZIndexes } from "../zIndex/DefaultZIndexes";
48
48
  import { ZIndexLayer } from "../zIndex/ZIndexLayer";
49
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
49
+ import { registerInStore } from "../state/registerInStore";
50
50
 
51
51
  /**
52
52
  * Single point that defines one end of a segment, in data space.
@@ -242,38 +242,29 @@ const renderLine = (
242
242
 
243
243
  function ReportReferenceLine(props: ReferenceLineSettings): JSX.Element {
244
244
  const store = useAppStore();
245
- let prev: ReferenceLineSettings | null = null;
246
-
247
- createEffect(
248
- (): ReferenceLineSettings => ({
249
- id: props.id,
250
- xAxisId: props.xAxisId,
251
- yAxisId: props.yAxisId,
252
- ifOverflow: props.ifOverflow,
253
- x: props.x,
254
- y: props.y,
255
- segment: props.segment,
256
- }),
257
- (settings) => {
258
- if (store == null) {
259
- return;
260
- }
261
- if (prev === null) {
262
- store.actions.referenceElements.addLine(settings);
263
- } else if (prev !== settings) {
264
- store.actions.referenceElements.removeLine(prev);
265
- store.actions.referenceElements.addLine(settings);
266
- }
267
- prev = settings;
268
- },
269
- );
270
-
271
- unregisterOnCleanup(() => {
272
- if (prev && store != null) {
273
- store.actions.referenceElements.removeLine(prev);
274
- prev = null;
275
- }
276
- });
245
+ if (store != null) {
246
+ registerInStore<ReferenceLineSettings>(
247
+ () => ({
248
+ id: props.id,
249
+ xAxisId: props.xAxisId,
250
+ yAxisId: props.yAxisId,
251
+ ifOverflow: props.ifOverflow,
252
+ x: props.x,
253
+ y: props.y,
254
+ segment: props.segment,
255
+ }),
256
+ {
257
+ add: (next) => store.actions.referenceElements.addLine(next),
258
+ // The referenceElements slice has no replace action; the change is a
259
+ // remove of the old settings followed by an add of the new (recharts idiom).
260
+ replace: (prev, next) => {
261
+ store.actions.referenceElements.removeLine(prev);
262
+ store.actions.referenceElements.addLine(next);
263
+ },
264
+ remove: (prev) => store.actions.referenceElements.removeLine(prev),
265
+ },
266
+ );
267
+ }
277
268
 
278
269
  return null;
279
270
  }
@@ -10,7 +10,7 @@
10
10
  // joint/fitting line) are wired.) Solid deviations:
11
11
  // resolveDefaultProps→merge; effect-dispatch registration → createEffect/onCleanup;
12
12
  // the `@ts-expect-error`-laden value plumbing is replaced with typed coercion.
13
- import { createEffect, createMemo, For, merge, Show } from "solid-js";
13
+ import { createMemo, For, merge, Show } from "solid-js";
14
14
  import type { JSX } from "@solidjs/web";
15
15
  import { useAppSelector, useAppStore } from "../state/hooks";
16
16
  import { useIsPanorama } from "../context/PanoramaContext";
@@ -79,7 +79,7 @@ import { getCateCoordinateOfLine, getTooltipNameProp, getValueByDataKey } from "
79
79
  import { getLinearRegression, interpolate, isNullish, isNumOrStr } from "../util/DataUtils";
80
80
  import { BaseAxisWithScale, implicitZAxis, ZAxisWithScale } from "../state/selectors/axisSelectors";
81
81
  import type { Formatter, ValueType } from "../component/DefaultTooltipContent";
82
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
82
+ import { registerInStore } from "../state/registerInStore";
83
83
 
84
84
  export interface ScatterPointNode {
85
85
  x?: number | string;
@@ -402,41 +402,29 @@ export const Scatter = (props: ScatterProps): JSX.Element => {
402
402
  // The default shape a (possibly partial-object) activeShape falls back to.
403
403
  const defaultSymbolShape = (p: ScatterShapeProps): JSX.Element => <Symbols {...p} />;
404
404
 
405
- let prev: ScatterSettings | null = null;
406
-
407
- createEffect(
408
- (): ScatterSettings => ({
409
- id,
410
- type: "scatter",
411
- isPanorama,
412
- data: merged.data,
413
- dataKey: merged.dataKey,
414
- xAxisId: merged.xAxisId,
415
- yAxisId: merged.yAxisId,
416
- zAxisId: merged.zAxisId,
417
- hide: merged.hide,
418
- tooltipType: merged.tooltipType,
419
- name: merged.name,
420
- }),
421
- (settings) => {
422
- if (store == null) {
423
- return;
424
- }
425
- if (prev === null) {
426
- store.actions.graphicalItems.addCartesianGraphicalItem(settings);
427
- } else if (prev !== settings) {
428
- store.actions.graphicalItems.replaceCartesianGraphicalItem({ prev, next: settings });
429
- }
430
- prev = settings;
431
- },
432
- );
433
-
434
- unregisterOnCleanup(() => {
435
- if (prev && store != null) {
436
- store.actions.graphicalItems.removeCartesianGraphicalItem(prev);
437
- prev = null;
438
- }
439
- });
405
+ if (store != null) {
406
+ registerInStore<ScatterSettings>(
407
+ () => ({
408
+ id,
409
+ type: "scatter",
410
+ isPanorama,
411
+ data: merged.data,
412
+ dataKey: merged.dataKey,
413
+ xAxisId: merged.xAxisId,
414
+ yAxisId: merged.yAxisId,
415
+ zAxisId: merged.zAxisId,
416
+ hide: merged.hide,
417
+ tooltipType: merged.tooltipType,
418
+ name: merged.name,
419
+ }),
420
+ {
421
+ add: (next) => store.actions.graphicalItems.addCartesianGraphicalItem(next),
422
+ replace: (prev, next) =>
423
+ store.actions.graphicalItems.replaceCartesianGraphicalItem({ prev, next }),
424
+ remove: (prev) => store.actions.graphicalItems.removeCartesianGraphicalItem(prev),
425
+ },
426
+ );
427
+ }
440
428
 
441
429
  // Per-point <Cell> overrides (collected from children, in data order).
442
430
  const cells = collectCells(() => props.children);
@@ -10,7 +10,7 @@
10
10
  // plus `onCleanup` for removal. Defaults are resolved field-by-field to match
11
11
  // recharts' `resolveDefaultProps`: explicit `undefined` falls back to defaults.
12
12
  import { type CamelSvgProps } from "../util/svgPropertiesNoEvents";
13
- import { createEffect, createMemo, Show } from "solid-js";
13
+ import { createMemo, Show } from "solid-js";
14
14
  import type { JSX } from "@solidjs/web";
15
15
  import { useAppSelector, useAppStore } from "../state/hooks";
16
16
  import {
@@ -43,7 +43,7 @@ import {
43
43
  TickProp,
44
44
  } from "../util/types";
45
45
  import { CustomScaleDefinition } from "../util/scale/CustomScaleDefinition";
46
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
46
+ import { registerInStore } from "../state/registerInStore";
47
47
 
48
48
  export interface XAxisProps<DataPointType = unknown, DataValueType = unknown> {
49
49
  xAxisId?: string | number;
@@ -155,71 +155,58 @@ export function XAxis<DataPointType = unknown, DataValueType = unknown>(
155
155
  const unit = createMemo(() => props.unit);
156
156
  const mirror = createMemo(() => withDefault(props.mirror, xAxisDefaultProps.mirror));
157
157
 
158
- let prev: XAxisSettings | null = null;
159
-
160
- createEffect(
161
- (): XAxisSettings | undefined => {
162
- const evaluatedType = getAxisTypeBasedOnLayout(
163
- layout(),
164
- "xAxis",
165
- withDefault(props.type, xAxisDefaultProps.type),
166
- );
167
- if (evaluatedType == null) {
168
- return undefined;
169
- }
170
- return {
171
- id: xAxisId(),
172
- scale: withDefault(props.scale, xAxisDefaultProps.scale),
173
- type: evaluatedType,
174
- dataKey: props.dataKey,
175
- unit: unit(),
176
- name: props.name,
177
- allowDuplicatedCategory: withDefault(
178
- props.allowDuplicatedCategory,
179
- xAxisDefaultProps.allowDuplicatedCategory,
180
- ),
181
- allowDataOverflow: withDefault(
182
- props.allowDataOverflow,
183
- xAxisDefaultProps.allowDataOverflow,
184
- ),
185
- reversed: withDefault(props.reversed, xAxisDefaultProps.reversed),
186
- includeHidden: withDefault(props.includeHidden, xAxisDefaultProps.includeHidden),
187
- domain: props.domain,
188
- allowDecimals: withDefault(props.allowDecimals, xAxisDefaultProps.allowDecimals),
189
- tickCount: withDefault(props.tickCount, xAxisDefaultProps.tickCount),
190
- ticks: props.ticks,
191
- tick: tick(),
192
- niceTicks: withDefault(props.niceTicks, xAxisDefaultProps.niceTicks),
193
- interval: withDefault(props.interval, xAxisDefaultProps.interval),
194
- mirror: mirror(),
195
- minTickGap: withDefault(props.minTickGap, xAxisDefaultProps.minTickGap),
196
- angle: withDefault(props.angle, xAxisDefaultProps.angle),
197
- hide: hide(),
198
- tickFormatter: tickFormatter(),
199
- padding: withDefault(props.padding, xAxisDefaultProps.padding),
200
- height: withDefault(props.height, xAxisDefaultProps.height),
201
- orientation: orientation(),
202
- };
203
- },
204
- (settings) => {
205
- if (settings == null || store == null) {
206
- return;
207
- }
208
- if (prev === null) {
209
- store.actions.cartesianAxis.addXAxis(settings);
210
- } else if (prev !== settings) {
211
- store.actions.cartesianAxis.replaceXAxis({ prev, next: settings });
212
- }
213
- prev = settings;
214
- },
215
- );
216
-
217
- unregisterOnCleanup(() => {
218
- if (prev && store != null) {
219
- store.actions.cartesianAxis.removeXAxis(prev);
220
- prev = null;
221
- }
222
- });
158
+ if (store != null) {
159
+ registerInStore<XAxisSettings>(
160
+ (): XAxisSettings | undefined => {
161
+ const evaluatedType = getAxisTypeBasedOnLayout(
162
+ layout(),
163
+ "xAxis",
164
+ withDefault(props.type, xAxisDefaultProps.type),
165
+ );
166
+ if (evaluatedType == null) {
167
+ return undefined;
168
+ }
169
+ return {
170
+ id: xAxisId(),
171
+ scale: withDefault(props.scale, xAxisDefaultProps.scale),
172
+ type: evaluatedType,
173
+ dataKey: props.dataKey,
174
+ unit: unit(),
175
+ name: props.name,
176
+ allowDuplicatedCategory: withDefault(
177
+ props.allowDuplicatedCategory,
178
+ xAxisDefaultProps.allowDuplicatedCategory,
179
+ ),
180
+ allowDataOverflow: withDefault(
181
+ props.allowDataOverflow,
182
+ xAxisDefaultProps.allowDataOverflow,
183
+ ),
184
+ reversed: withDefault(props.reversed, xAxisDefaultProps.reversed),
185
+ includeHidden: withDefault(props.includeHidden, xAxisDefaultProps.includeHidden),
186
+ domain: props.domain,
187
+ allowDecimals: withDefault(props.allowDecimals, xAxisDefaultProps.allowDecimals),
188
+ tickCount: withDefault(props.tickCount, xAxisDefaultProps.tickCount),
189
+ ticks: props.ticks,
190
+ tick: tick(),
191
+ niceTicks: withDefault(props.niceTicks, xAxisDefaultProps.niceTicks),
192
+ interval: withDefault(props.interval, xAxisDefaultProps.interval),
193
+ mirror: mirror(),
194
+ minTickGap: withDefault(props.minTickGap, xAxisDefaultProps.minTickGap),
195
+ angle: withDefault(props.angle, xAxisDefaultProps.angle),
196
+ hide: hide(),
197
+ tickFormatter: tickFormatter(),
198
+ padding: withDefault(props.padding, xAxisDefaultProps.padding),
199
+ height: withDefault(props.height, xAxisDefaultProps.height),
200
+ orientation: orientation(),
201
+ };
202
+ },
203
+ {
204
+ add: (next) => store.actions.cartesianAxis.addXAxis(next),
205
+ replace: (prev, next) => store.actions.cartesianAxis.replaceXAxis({ prev, next }),
206
+ remove: (prev) => store.actions.cartesianAxis.removeXAxis(prev),
207
+ },
208
+ );
209
+ }
223
210
 
224
211
  // Visual: render the <CartesianAxis> (ticks + labels + axis line). Never inside
225
212
  // a Brush panorama.
@@ -40,7 +40,7 @@ import {
40
40
  TickProp,
41
41
  } from "../util/types";
42
42
  import { CustomScaleDefinition } from "../util/scale/CustomScaleDefinition";
43
- import { unregisterOnCleanup } from "../state/unregisterOnCleanup";
43
+ import { registerInStore } from "../state/registerInStore";
44
44
 
45
45
  export interface YAxisProps<DataPointType = unknown, DataValueType = unknown> {
46
46
  yAxisId?: string | number;
@@ -152,71 +152,58 @@ export function YAxis<DataPointType = unknown, DataValueType = unknown>(
152
152
  const unit = createMemo(() => props.unit);
153
153
  const mirror = createMemo(() => withDefault(props.mirror, yAxisDefaultProps.mirror));
154
154
 
155
- let prev: YAxisSettings | null = null;
156
-
157
- createEffect(
158
- (): YAxisSettings | undefined => {
159
- const evaluatedType = getAxisTypeBasedOnLayout(
160
- layout(),
161
- "yAxis",
162
- withDefault(props.type, yAxisDefaultProps.type),
163
- );
164
- if (evaluatedType == null) {
165
- return undefined;
166
- }
167
- return {
168
- id: yAxisId(),
169
- scale: withDefault(props.scale, yAxisDefaultProps.scale),
170
- type: evaluatedType,
171
- dataKey: props.dataKey,
172
- unit: unit(),
173
- name: props.name,
174
- allowDuplicatedCategory: withDefault(
175
- props.allowDuplicatedCategory,
176
- yAxisDefaultProps.allowDuplicatedCategory,
177
- ),
178
- allowDataOverflow: withDefault(
179
- props.allowDataOverflow,
180
- yAxisDefaultProps.allowDataOverflow,
181
- ),
182
- reversed: withDefault(props.reversed, yAxisDefaultProps.reversed),
183
- includeHidden: withDefault(props.includeHidden, yAxisDefaultProps.includeHidden),
184
- domain: props.domain,
185
- allowDecimals: withDefault(props.allowDecimals, yAxisDefaultProps.allowDecimals),
186
- tickCount: withDefault(props.tickCount, yAxisDefaultProps.tickCount),
187
- ticks: props.ticks,
188
- tick: tick(),
189
- niceTicks: withDefault(props.niceTicks, yAxisDefaultProps.niceTicks),
190
- interval: withDefault(props.interval, yAxisDefaultProps.interval),
191
- mirror: mirror(),
192
- minTickGap: withDefault(props.minTickGap, yAxisDefaultProps.minTickGap),
193
- angle: withDefault(props.angle, yAxisDefaultProps.angle),
194
- hide: hide(),
195
- tickFormatter: tickFormatter(),
196
- padding: withDefault(props.padding, yAxisDefaultProps.padding),
197
- width: withDefault(props.width, yAxisDefaultProps.width),
198
- orientation: orientation(),
199
- };
200
- },
201
- (settings) => {
202
- if (settings == null || store == null) {
203
- return;
204
- }
205
- if (prev === null) {
206
- store.actions.cartesianAxis.addYAxis(settings);
207
- } else if (prev !== settings) {
208
- store.actions.cartesianAxis.replaceYAxis({ prev, next: settings });
209
- }
210
- prev = settings;
211
- },
212
- );
213
-
214
- unregisterOnCleanup(() => {
215
- if (prev && store != null) {
216
- store.actions.cartesianAxis.removeYAxis(prev);
217
- prev = null;
218
- }
219
- });
155
+ if (store != null) {
156
+ registerInStore<YAxisSettings>(
157
+ (): YAxisSettings | undefined => {
158
+ const evaluatedType = getAxisTypeBasedOnLayout(
159
+ layout(),
160
+ "yAxis",
161
+ withDefault(props.type, yAxisDefaultProps.type),
162
+ );
163
+ if (evaluatedType == null) {
164
+ return undefined;
165
+ }
166
+ return {
167
+ id: yAxisId(),
168
+ scale: withDefault(props.scale, yAxisDefaultProps.scale),
169
+ type: evaluatedType,
170
+ dataKey: props.dataKey,
171
+ unit: unit(),
172
+ name: props.name,
173
+ allowDuplicatedCategory: withDefault(
174
+ props.allowDuplicatedCategory,
175
+ yAxisDefaultProps.allowDuplicatedCategory,
176
+ ),
177
+ allowDataOverflow: withDefault(
178
+ props.allowDataOverflow,
179
+ yAxisDefaultProps.allowDataOverflow,
180
+ ),
181
+ reversed: withDefault(props.reversed, yAxisDefaultProps.reversed),
182
+ includeHidden: withDefault(props.includeHidden, yAxisDefaultProps.includeHidden),
183
+ domain: props.domain,
184
+ allowDecimals: withDefault(props.allowDecimals, yAxisDefaultProps.allowDecimals),
185
+ tickCount: withDefault(props.tickCount, yAxisDefaultProps.tickCount),
186
+ ticks: props.ticks,
187
+ tick: tick(),
188
+ niceTicks: withDefault(props.niceTicks, yAxisDefaultProps.niceTicks),
189
+ interval: withDefault(props.interval, yAxisDefaultProps.interval),
190
+ mirror: mirror(),
191
+ minTickGap: withDefault(props.minTickGap, yAxisDefaultProps.minTickGap),
192
+ angle: withDefault(props.angle, yAxisDefaultProps.angle),
193
+ hide: hide(),
194
+ tickFormatter: tickFormatter(),
195
+ padding: withDefault(props.padding, yAxisDefaultProps.padding),
196
+ width: withDefault(props.width, yAxisDefaultProps.width),
197
+ orientation: orientation(),
198
+ };
199
+ },
200
+ {
201
+ add: (next) => store.actions.cartesianAxis.addYAxis(next),
202
+ replace: (prev, next) => store.actions.cartesianAxis.replaceYAxis({ prev, next }),
203
+ remove: (prev) => store.actions.cartesianAxis.removeYAxis(prev),
204
+ },
205
+ );
206
+ }
220
207
 
221
208
  // Visual: render the <CartesianAxis>. Never inside a Brush panorama.
222
209
  const isPanorama = useIsPanorama();