@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,578 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { ChartState } from "../store"
3
- import { selectChartDataSliceWithIndexes } from "./dataSelectors"
4
- import { readChartState } from "../chartState"
5
- import {
6
- type AxisRange,
7
- combineAllAppliedValues,
8
- combineAreasDomain,
9
- combineAxisDomain,
10
- combineAxisDomainWithNiceTicks,
11
- combineCategoricalDomain,
12
- combineDisplayedData,
13
- combineDomainOfAllAppliedNumericalValuesIncludingErrorValues,
14
- combineDomainOfStackGroups,
15
- combineDotsDomain,
16
- combineDuplicateDomain,
17
- combineGraphicalItemsData,
18
- combineLinesDomain,
19
- combineNiceTicks,
20
- combineNumericalDomain,
21
- combineStackGroups,
22
- filterGraphicalNotStackedItems,
23
- filterReferenceElements,
24
- getDomainDefinition,
25
- itemAxisPredicate,
26
- mergeDomains,
27
- type RenderableAxisSettings,
28
- selectAllErrorBarSettings,
29
- selectAxisRange,
30
- selectHasBar,
31
- selectReferenceAreas,
32
- selectReferenceDots,
33
- selectReferenceLines,
34
- selectTooltipAxis,
35
- selectTooltipAxisDataKey,
36
- selectUnfilteredCartesianItems,
37
- } from "./axisSelectors"
38
- import { selectUnfilteredPolarItems } from "./polarSelectors"
39
- import { selectChartLayout } from "../../context/chartLayoutContext"
40
- import { isCategoricalAxis, type StackId } from "../../util/ChartUtils"
41
- import type {
42
- AxisDomain,
43
- CategoricalDomain,
44
- CategoricalDomainItem,
45
- Coordinate,
46
- D3ScaleType,
47
- DataKey,
48
- LayoutType,
49
- NumberDomain,
50
- TickItem,
51
- TooltipEventType,
52
- } from "../../util/types"
53
- import type { AppliedChartData, ChartData } from "../chartDataSlice"
54
- import { selectChartDataWithIndexes } from "./dataSelectors"
55
- import type {
56
- CartesianGraphicalItemSettings,
57
- GraphicalItemSettings,
58
- PolarGraphicalItemSettings,
59
- } from "../graphicalItemsSlice"
60
- import type {
61
- ReferenceAreaSettings,
62
- ReferenceDotSettings,
63
- ReferenceLineSettings,
64
- } from "../referenceElementsSlice"
65
- import {
66
- selectChartName,
67
- selectReverseStackOrder,
68
- selectStackOffsetType,
69
- } from "./rootPropsSelectors"
70
- import { isNotNil, mathSign } from "../../util/DataUtils"
71
- import { combineAxisRangeWithReverse } from "./combiners/combineAxisRangeWithReverse"
72
- import type {
73
- TooltipIndex,
74
- TooltipInteractionState,
75
- TooltipPayload,
76
- TooltipSettingsState,
77
- } from "../tooltipSlice"
78
-
79
- import {
80
- combineTooltipEventType,
81
- selectDefaultTooltipEventType,
82
- selectValidateTooltipEventTypes,
83
- } from "./selectTooltipEventType"
84
-
85
- import { combineActiveLabel } from "./combiners/combineActiveLabel"
86
-
87
- import { selectTooltipSettings } from "./selectTooltipSettings"
88
-
89
- import { combineTooltipInteractionState } from "./combiners/combineTooltipInteractionState"
90
- import { combineActiveTooltipIndex } from "./combiners/combineActiveTooltipIndex"
91
- import { combineCoordinateForDefaultIndex } from "./combiners/combineCoordinateForDefaultIndex"
92
- import { selectChartHeight, selectChartWidth } from "./containerSelectors"
93
- import { selectChartOffsetInternal } from "./selectChartOffsetInternal"
94
- import { combineTooltipPayloadConfigurations } from "./combiners/combineTooltipPayloadConfigurations"
95
- import { selectTooltipPayloadSearcher } from "./selectTooltipPayloadSearcher"
96
- import { selectTooltipState } from "./selectTooltipState"
97
-
98
- import { combineTooltipPayload } from "./combiners/combineTooltipPayload"
99
- import type { StackGroup } from "../../util/stacks/stackTypes"
100
- import { selectTooltipAxisId } from "./selectTooltipAxisId"
101
- import { type RenderableAxisType, selectTooltipAxisType } from "./selectTooltipAxisType"
102
- import {
103
- combineDisplayedStackedData,
104
- type DisplayedStackedData,
105
- } from "./combiners/combineDisplayedStackedData"
106
- import { type DefinitelyStackedGraphicalItem, isStacked } from "../types/StackedGraphicalItem"
107
- import { numericalDomainSpecifiedWithoutRequiringData } from "../../util/isDomainSpecifiedByUser"
108
- import type { ActiveLabel } from "../../synchronisation/types"
109
- import { type RechartsScale, rechartsScaleFactory } from "../../util/scale/RechartsScale"
110
- import { isWellBehavedNumber } from "../../util/isWellBehavedNumber"
111
- import { combineRealScaleType } from "./combiners/combineRealScaleType"
112
- import { combineConfiguredScale } from "./combiners/combineConfiguredScale"
113
- import { chartSelector } from "./chartSelector"
114
- import type { CustomScaleDefinition } from "../../util/scale/CustomScaleDefinition"
115
-
116
- export const selectTooltipAxisRealScaleType = chartSelector(function selectTooltipAxisRealScaleType(state: ChartState): D3ScaleType | undefined {
117
- return combineRealScaleType(selectTooltipAxis(state), selectHasBar(state), selectChartName(state))
118
- })
119
-
120
- export const selectAllUnfilteredGraphicalItems = chartSelector(function selectAllUnfilteredGraphicalItems(state: ChartState): ReadonlyArray<CartesianGraphicalItemSettings | PolarGraphicalItemSettings> {
121
- return [
122
- ...selectUnfilteredCartesianItems(state),
123
- ...selectUnfilteredPolarItems(state),
124
- ]
125
- })
126
-
127
- const selectTooltipAxisPredicate = chartSelector(function selectTooltipAxisPredicate(state: ChartState) {
128
- return itemAxisPredicate(selectTooltipAxisType(state), selectTooltipAxisId(state))
129
- })
130
-
131
- export const selectAllGraphicalItemsSettings = chartSelector(function selectAllGraphicalItemsSettings(state: ChartState): ReadonlyArray<GraphicalItemSettings> {
132
- // One pass over the item map; same order and result as
133
- // combineGraphicalItemsSettings(selectAllUnfilteredGraphicalItems(state), axis, predicate).
134
- const graphicalItems = readChartState(state).graphicalItems
135
- const includeHidden = selectTooltipAxis(state)?.includeHidden === true
136
- const axisPredicate = selectTooltipAxisPredicate(state)
137
- const cartesian: GraphicalItemSettings[] = []
138
- const polar: GraphicalItemSettings[] = []
139
- for (const id in graphicalItems) {
140
- const item = graphicalItems[id]
141
- if (item == null || typeof item !== "object") {
142
- continue
143
- }
144
- const type = item.type
145
- const settings = item.settings
146
- const isCartesian = type === "line" || type === "area" || type === "bar" || type === "scatter"
147
- const isPolar =
148
- (type === "pie" || type === "radar" || type === "radialBar") &&
149
- settings !== null &&
150
- typeof settings === "object"
151
- if ((isCartesian || isPolar) && axisPredicate(settings) && (includeHidden || !settings.hide)) {
152
- ;(isCartesian ? cartesian : polar).push(settings)
153
- }
154
- }
155
- if (polar.length === 0) {
156
- return cartesian
157
- }
158
- return cartesian.length === 0 ? polar : [...cartesian, ...polar]
159
- })
160
-
161
- const selectAllStackedGraphicalItemsSettings = chartSelector(function selectAllStackedGraphicalItemsSettings(state: ChartState): ReadonlyArray<DefinitelyStackedGraphicalItem> {
162
- return selectAllGraphicalItemsSettings(state).filter(isStacked)
163
- })
164
-
165
- export const selectTooltipGraphicalItemsData = chartSelector(function selectTooltipGraphicalItemsData(state: ChartState): ChartData {
166
- return combineGraphicalItemsData(selectAllGraphicalItemsSettings(state))
167
- })
168
-
169
- /**
170
- * Data for tooltip always use the data with indexes set by a Brush,
171
- * and never accept the isPanorama flag:
172
- * because Tooltip never displays inside the panorama anyway
173
- * so we don't need to worry what would happen there.
174
- */
175
- export const selectTooltipDisplayedData = chartSelector(function selectTooltipDisplayedData(state: ChartState): ChartData {
176
- return combineDisplayedData(
177
- selectTooltipGraphicalItemsData(state),
178
- selectChartDataWithIndexes(state),
179
- )
180
- })
181
-
182
- const selectTooltipStackedData = chartSelector(function selectTooltipStackedData(state: ChartState): DisplayedStackedData {
183
- return combineDisplayedStackedData(
184
- selectAllStackedGraphicalItemsSettings(state),
185
- selectChartDataWithIndexes(state),
186
- selectTooltipAxis(state),
187
- )
188
- })
189
-
190
- const selectAnyTooltipItemUsesChartData = chartSelector(function selectAnyTooltipItemUsesChartData(state: ChartState): boolean {
191
- return selectAllGraphicalItemsSettings(state).some((item) => !(item as { data?: unknown }).data)
192
- })
193
-
194
- const selectAllTooltipAppliedValues = chartSelector(function selectAllTooltipAppliedValues(state: ChartState): AppliedChartData {
195
- return combineAllAppliedValues(
196
- selectTooltipDisplayedData(state),
197
- selectTooltipAxis(state),
198
- selectAllGraphicalItemsSettings(state),
199
- selectChartDataWithIndexes(state),
200
- selectAnyTooltipItemUsesChartData(state),
201
- selectTooltipGraphicalItemsData(state),
202
- )
203
- })
204
-
205
- const selectTooltipAxisDomainDefinition = chartSelector(function selectTooltipAxisDomainDefinition(state: ChartState): AxisDomain | undefined {
206
- return getDomainDefinition(selectTooltipAxis(state))
207
- })
208
-
209
- function selectTooltipDataOverflow(state: ChartState): boolean {
210
- return selectTooltipAxis(state).allowDataOverflow
211
- }
212
-
213
- const selectTooltipDomainFromUserPreferences = chartSelector(function selectTooltipDomainFromUserPreferences(state: ChartState): NumberDomain | undefined {
214
- return numericalDomainSpecifiedWithoutRequiringData(
215
- selectTooltipAxisDomainDefinition(state),
216
- selectTooltipDataOverflow(state),
217
- )
218
- })
219
-
220
- const selectAllStackedGraphicalItems = chartSelector(function selectAllStackedGraphicalItems(state: ChartState): ReadonlyArray<DefinitelyStackedGraphicalItem> {
221
- return selectAllGraphicalItemsSettings(state).filter(isStacked)
222
- })
223
-
224
- const selectTooltipStackGroups = chartSelector(function selectTooltipStackGroups(state: ChartState): Record<StackId, StackGroup> {
225
- return combineStackGroups(
226
- selectTooltipStackedData(state),
227
- selectAllStackedGraphicalItems(state),
228
- selectStackOffsetType(state),
229
- selectReverseStackOrder(state),
230
- )
231
- })
232
-
233
- const selectTooltipDomainOfStackGroups = chartSelector(function selectTooltipDomainOfStackGroups(state: ChartState): NumberDomain | undefined {
234
- return combineDomainOfStackGroups(
235
- selectTooltipStackGroups(state),
236
- selectChartDataWithIndexes(state),
237
- selectTooltipAxisType(state),
238
- selectTooltipDomainFromUserPreferences(state),
239
- )
240
- })
241
-
242
- const selectTooltipItemsSettingsExceptStacked = chartSelector(function selectTooltipItemsSettingsExceptStacked(state: ChartState): ReadonlyArray<GraphicalItemSettings> {
243
- return filterGraphicalNotStackedItems(selectAllGraphicalItemsSettings(state))
244
- })
245
-
246
- const selectTooltipDomainOfAllAppliedNumericalValuesIncludingErrorValues = chartSelector(function selectTooltipDomainOfAllAppliedNumericalValuesIncludingErrorValues(state: ChartState): NumberDomain | undefined {
247
- return combineDomainOfAllAppliedNumericalValuesIncludingErrorValues(
248
- selectTooltipDisplayedData(state),
249
- selectTooltipAxis(state),
250
- selectTooltipItemsSettingsExceptStacked(state),
251
- selectAllErrorBarSettings(state),
252
- selectTooltipAxisType(state),
253
- selectChartDataSliceWithIndexes(state),
254
- )
255
- })
256
-
257
- const selectReferenceDotsByTooltipAxis = chartSelector(function selectReferenceDotsByTooltipAxis(state: ChartState): ReadonlyArray<ReferenceDotSettings> | undefined {
258
- return filterReferenceElements(
259
- selectReferenceDots(state),
260
- selectTooltipAxisType(state),
261
- selectTooltipAxisId(state),
262
- )
263
- })
264
-
265
- const selectTooltipReferenceDotsDomain = chartSelector(function selectTooltipReferenceDotsDomain(state: ChartState): NumberDomain | undefined {
266
- return combineDotsDomain(selectReferenceDotsByTooltipAxis(state), selectTooltipAxisType(state))
267
- })
268
-
269
- const selectReferenceAreasByTooltipAxis = chartSelector(function selectReferenceAreasByTooltipAxis(state: ChartState): ReadonlyArray<ReferenceAreaSettings> | undefined {
270
- return filterReferenceElements(
271
- selectReferenceAreas(state),
272
- selectTooltipAxisType(state),
273
- selectTooltipAxisId(state),
274
- )
275
- })
276
-
277
- const selectTooltipReferenceAreasDomain = chartSelector(function selectTooltipReferenceAreasDomain(state: ChartState): NumberDomain | undefined {
278
- return combineAreasDomain(selectReferenceAreasByTooltipAxis(state), selectTooltipAxisType(state))
279
- })
280
-
281
- const selectReferenceLinesByTooltipAxis = chartSelector(function selectReferenceLinesByTooltipAxis(state: ChartState): ReadonlyArray<ReferenceLineSettings> | undefined {
282
- return filterReferenceElements(
283
- selectReferenceLines(state),
284
- selectTooltipAxisType(state),
285
- selectTooltipAxisId(state),
286
- )
287
- })
288
-
289
- const selectTooltipReferenceLinesDomain = chartSelector(function selectTooltipReferenceLinesDomain(state: ChartState): NumberDomain | undefined {
290
- return combineLinesDomain(selectReferenceLinesByTooltipAxis(state), selectTooltipAxisType(state))
291
- })
292
-
293
- const selectTooltipReferenceElementsDomain = chartSelector(function selectTooltipReferenceElementsDomain(state: ChartState): NumberDomain | undefined {
294
- return mergeDomains(
295
- selectTooltipReferenceDotsDomain(state),
296
- selectTooltipReferenceLinesDomain(state),
297
- selectTooltipReferenceAreasDomain(state),
298
- )
299
- })
300
-
301
- const selectTooltipNumericalDomain = chartSelector(function selectTooltipNumericalDomain(state: ChartState): NumberDomain | undefined {
302
- return combineNumericalDomain(
303
- selectTooltipAxis(state),
304
- selectTooltipAxisDomainDefinition(state),
305
- selectTooltipDomainFromUserPreferences(state),
306
- selectTooltipDomainOfStackGroups(state),
307
- selectTooltipDomainOfAllAppliedNumericalValuesIncludingErrorValues(state),
308
- selectTooltipReferenceElementsDomain(state),
309
- selectChartLayout(state),
310
- selectTooltipAxisType(state),
311
- )
312
- })
313
-
314
- export const selectTooltipAxisDomain = chartSelector(function selectTooltipAxisDomain(state: ChartState): NumberDomain | CategoricalDomain | undefined {
315
- return combineAxisDomain(
316
- selectTooltipAxis(state),
317
- selectChartLayout(state),
318
- selectTooltipDisplayedData(state),
319
- selectAllTooltipAppliedValues(state),
320
- selectStackOffsetType(state),
321
- selectTooltipAxisType(state),
322
- selectTooltipNumericalDomain(state),
323
- )
324
- })
325
-
326
- const selectTooltipNiceTicks = chartSelector(function selectTooltipNiceTicks(state: ChartState): ReadonlyArray<number> | undefined {
327
- return combineNiceTicks(
328
- selectTooltipAxisDomain(state),
329
- selectTooltipAxis(state),
330
- selectTooltipAxisRealScaleType(state),
331
- )
332
- })
333
-
334
- export const selectTooltipAxisDomainIncludingNiceTicks = chartSelector(function selectTooltipAxisDomainIncludingNiceTicks(state: ChartState): NumberDomain | CategoricalDomain | undefined {
335
- return combineAxisDomainWithNiceTicks(
336
- selectTooltipAxis(state),
337
- selectTooltipAxisDomain(state),
338
- selectTooltipNiceTicks(state),
339
- selectTooltipAxisType(state),
340
- )
341
- })
342
-
343
- const selectTooltipAxisRange = chartSelector((state: ChartState): AxisRange | undefined => {
344
- const axisType = selectTooltipAxisType(state)
345
- const axisId = selectTooltipAxisId(state)
346
- const isPanorama = false
347
- return selectAxisRange(state, axisType, axisId, isPanorama)
348
- })
349
-
350
- export const selectTooltipAxisRangeWithReverse = chartSelector(function selectTooltipAxisRangeWithReverse(state: ChartState): AxisRange | undefined {
351
- return combineAxisRangeWithReverse(selectTooltipAxis(state), selectTooltipAxisRange(state))
352
- })
353
-
354
- const selectTooltipConfiguredScale = chartSelector(function selectTooltipConfiguredScale(state: ChartState): CustomScaleDefinition | undefined {
355
- return combineConfiguredScale(
356
- selectTooltipAxis(state),
357
- selectTooltipAxisRealScaleType(state),
358
- selectTooltipAxisDomainIncludingNiceTicks(state),
359
- selectTooltipAxisRangeWithReverse(state),
360
- )
361
- })
362
-
363
- export const selectTooltipAxisScale = chartSelector(function selectTooltipAxisScale(state: ChartState): RechartsScale | undefined {
364
- return rechartsScaleFactory(selectTooltipConfiguredScale(state))
365
- })
366
-
367
- const selectTooltipDuplicateDomain = chartSelector(function selectTooltipDuplicateDomain(state: ChartState): ReadonlyArray<unknown> | undefined {
368
- return combineDuplicateDomain(
369
- selectChartLayout(state),
370
- selectAllTooltipAppliedValues(state),
371
- selectTooltipAxis(state),
372
- selectTooltipAxisType(state),
373
- )
374
- })
375
-
376
- export const selectTooltipCategoricalDomain = chartSelector(function selectTooltipCategoricalDomain(state: ChartState): ReadonlyArray<unknown> | undefined {
377
- return combineCategoricalDomain(
378
- selectChartLayout(state),
379
- selectAllTooltipAppliedValues(state),
380
- selectTooltipAxis(state),
381
- selectTooltipAxisType(state),
382
- )
383
- })
384
-
385
- const combineTicksOfTooltipAxis = (
386
- layout: LayoutType,
387
- axis: RenderableAxisSettings,
388
- realScaleType: string | undefined,
389
- scale: RechartsScale | undefined,
390
- axisRange: AxisRange | undefined,
391
- duplicateDomain: ReadonlyArray<unknown> | undefined,
392
- categoricalDomain: ReadonlyArray<unknown> | undefined,
393
- axisType: RenderableAxisType,
394
- ): ReadonlyArray<TickItem> | undefined => {
395
- if (!axis) {
396
- return undefined
397
- }
398
- const { type } = axis
399
-
400
- const isCategorical = isCategoricalAxis(layout, axisType)
401
-
402
- if (!scale) {
403
- return undefined
404
- }
405
-
406
- const offsetForBand = realScaleType === "scaleBand" && scale.bandwidth ? scale.bandwidth() / 2 : 2
407
- let offset = type === "category" && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0
408
-
409
- offset =
410
- axisType === "angleAxis" && axisRange != null && axisRange?.length >= 2
411
- ? mathSign(axisRange[0] - axisRange[1]) * 2 * offset
412
- : offset
413
-
414
- if (isCategorical && categoricalDomain) {
415
- return categoricalDomain
416
- .map((entry: unknown, index: number): TickItem | null => {
417
- const scaled = scale.map(entry)
418
- if (!isWellBehavedNumber(scaled)) {
419
- return null
420
- }
421
- return {
422
- coordinate: scaled + offset,
423
- index,
424
- offset,
425
- value: entry,
426
- }
427
- })
428
- .filter(isNotNil)
429
- }
430
-
431
- return scale
432
- .domain()
433
- .map((entry: CategoricalDomainItem, index: number): TickItem | null => {
434
- const scaled = scale.map(entry)
435
- if (!isWellBehavedNumber(scaled)) {
436
- return null
437
- }
438
- return {
439
- coordinate: scaled + offset,
440
- index,
441
- offset,
442
- value: duplicateDomain ? duplicateDomain[entry as unknown as number] : entry,
443
- }
444
- })
445
- .filter(isNotNil)
446
- }
447
-
448
- /**
449
- * Of on four almost identical implementations of tick generation.
450
- * The four horsemen of tick generation are:
451
- * - {@link selectTooltipAxisTicks}
452
- * - {@link combineAxisTicks}
453
- * - {@link getTicksOfAxis}.
454
- * - {@link combineGraphicalItemTicks}
455
- */
456
- export const selectTooltipAxisTicks = chartSelector(function selectTooltipAxisTicks(state: ChartState): ReadonlyArray<TickItem> | undefined {
457
- return combineTicksOfTooltipAxis(
458
- selectChartLayout(state),
459
- selectTooltipAxis(state),
460
- selectTooltipAxisRealScaleType(state),
461
- selectTooltipAxisScale(state),
462
- selectTooltipAxisRange(state),
463
- selectTooltipDuplicateDomain(state),
464
- selectTooltipCategoricalDomain(state),
465
- selectTooltipAxisType(state),
466
- )
467
- })
468
-
469
- const selectTooltipEventType = chartSelector(function selectTooltipEventType(state: ChartState): TooltipEventType | undefined {
470
- const defaultTooltipEventType = selectDefaultTooltipEventType(state)
471
- const validateTooltipEventType = selectValidateTooltipEventTypes(state)
472
- const settings: TooltipSettingsState = selectTooltipSettings(state)
473
- return combineTooltipEventType(settings.shared, defaultTooltipEventType, validateTooltipEventType)
474
- })
475
-
476
- const selectTooltipTrigger = (state: ChartState) => {
477
- return readChartState(state).tooltip.settings.trigger
478
- }
479
-
480
- const selectDefaultIndex = chartSelector((state: ChartState): TooltipIndex | undefined => {
481
- const raw = readChartState(state).tooltip.settings.defaultIndex
482
- if (typeof raw === "number") return String(raw)
483
- return raw
484
- })
485
-
486
- const selectTooltipInteractionState = chartSelector(function selectTooltipInteractionState(state: ChartState): TooltipInteractionState | undefined {
487
- return combineTooltipInteractionState(
488
- selectTooltipState(state),
489
- selectTooltipEventType(state),
490
- selectTooltipTrigger(state),
491
- selectDefaultIndex(state),
492
- )
493
- })
494
-
495
- export const selectActiveTooltipIndex = chartSelector(function selectActiveTooltipIndex(state: ChartState): TooltipIndex | null {
496
- return combineActiveTooltipIndex(
497
- selectTooltipInteractionState(state),
498
- selectTooltipDisplayedData(state),
499
- selectTooltipAxisDataKey(state),
500
- selectTooltipAxisDomain(state),
501
- )
502
- })
503
-
504
- export const selectActiveLabel = chartSelector(function selectActiveLabel(state: ChartState): ActiveLabel {
505
- return combineActiveLabel(selectTooltipAxisTicks(state), selectActiveTooltipIndex(state))
506
- })
507
-
508
- export const selectActiveTooltipDataKey = chartSelector(function selectActiveTooltipDataKey(state: ChartState): DataKey<unknown> | undefined {
509
- const tooltipInteraction = selectTooltipInteractionState(state)
510
- if (!tooltipInteraction) {
511
- return undefined
512
- }
513
- return tooltipInteraction.dataKey
514
- })
515
-
516
- export const selectActiveTooltipGraphicalItemId = chartSelector(function selectActiveTooltipGraphicalItemId(state: ChartState): string | undefined {
517
- const tooltipInteraction = selectTooltipInteractionState(state)
518
- if (!tooltipInteraction) {
519
- return undefined
520
- }
521
- return tooltipInteraction.graphicalItemId
522
- })
523
-
524
- const selectTooltipPayloadConfigurations = chartSelector(function selectTooltipPayloadConfigurations(state: ChartState) {
525
- return combineTooltipPayloadConfigurations(
526
- selectTooltipState(state),
527
- selectTooltipEventType(state),
528
- selectTooltipTrigger(state),
529
- selectDefaultIndex(state),
530
- )
531
- })
532
-
533
- const selectTooltipCoordinateForDefaultIndex = chartSelector(function selectTooltipCoordinateForDefaultIndex(state: ChartState): Coordinate | undefined {
534
- return combineCoordinateForDefaultIndex(
535
- selectChartWidth(state),
536
- selectChartHeight(state),
537
- selectChartLayout(state),
538
- selectChartOffsetInternal(state),
539
- selectTooltipAxisTicks(state),
540
- selectDefaultIndex(state),
541
- selectTooltipPayloadConfigurations(state),
542
- )
543
- })
544
-
545
- export const selectActiveTooltipCoordinate = chartSelector(function selectActiveTooltipCoordinate(state: ChartState): Coordinate | undefined {
546
- const tooltipInteractionState = selectTooltipInteractionState(state)
547
- const defaultIndexCoordinate = selectTooltipCoordinateForDefaultIndex(state)
548
- if (tooltipInteractionState?.coordinate) {
549
- return tooltipInteractionState.coordinate
550
- }
551
- return defaultIndexCoordinate
552
- })
553
-
554
- export const selectIsTooltipActive = chartSelector(function selectIsTooltipActive(state: ChartState): boolean {
555
- const tooltipInteractionState = selectTooltipInteractionState(state)
556
- return tooltipInteractionState?.active ?? false
557
- })
558
-
559
- export const selectActiveTooltipPayload = chartSelector(function selectActiveTooltipPayload(state: ChartState): TooltipPayload | undefined {
560
- return combineTooltipPayload(
561
- selectTooltipPayloadConfigurations(state),
562
- selectActiveTooltipIndex(state),
563
- selectChartDataWithIndexes(state),
564
- selectTooltipAxisDataKey(state),
565
- selectActiveLabel(state),
566
- selectTooltipPayloadSearcher(state),
567
- selectTooltipEventType(state),
568
- )
569
- })
570
-
571
- export const selectActiveTooltipDataPoints = chartSelector(function selectActiveTooltipDataPoints(state: ChartState) {
572
- const payload = selectActiveTooltipPayload(state)
573
- if (payload == null) {
574
- return undefined
575
- }
576
- const dataPoints = payload.map((p) => p.payload).filter((p) => p != null)
577
- return Array.from(new Set(dataPoints))
578
- })
@@ -1,31 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { ChartState } from "../store"
3
- import type { TooltipIndex, TooltipPayloadConfiguration } from "../tooltipSlice"
4
- import type { Coordinate } from "../../util/types"
5
- import { selectTooltipState } from "./selectTooltipState"
6
- import { chartSelector } from "./chartSelector"
7
- import type { GraphicalItemId } from "../graphicalItemsSlice"
8
-
9
- const selectAllTooltipPayloadConfiguration = chartSelector(function selectAllTooltipPayloadConfiguration(state: ChartState): ReadonlyArray<TooltipPayloadConfiguration> {
10
- const tooltipState = selectTooltipState(state)
11
- return tooltipState.tooltipItemPayloads
12
- })
13
-
14
- export const selectTooltipCoordinate = chartSelector(function selectTooltipCoordinate(state: ChartState, tooltipIndex: TooltipIndex, graphicalItemId: GraphicalItemId): Coordinate | undefined {
15
- const allTooltipConfigurations = selectAllTooltipPayloadConfiguration(state)
16
-
17
- if (tooltipIndex == null) {
18
- return undefined
19
- }
20
- const mostRelevantTooltipConfiguration = allTooltipConfigurations.find((tooltipConfiguration) => {
21
- return tooltipConfiguration.settings.graphicalItemId === graphicalItemId
22
- })
23
- if (mostRelevantTooltipConfiguration == null) {
24
- return undefined
25
- }
26
- const { getPosition } = mostRelevantTooltipConfiguration
27
- if (getPosition == null) {
28
- return undefined
29
- }
30
- return getPosition(tooltipIndex)
31
- })
@@ -1,29 +0,0 @@
1
- /* eslint-disable import/no-cycle */
2
- import type { ChartState } from "./chartState"
3
- import { createInitialChartState } from "./chartState"
4
-
5
- import { createStore } from '../util/solid-1-compat';
6
- export type { ChartState }
7
- export { createInitialChartState }
8
-
9
- /** Alias so existing tests can keep calling createInitialState. */
10
- export function createInitialState(preloadedState?: Partial<ChartState>): ChartState {
11
- return createInitialChartState(preloadedState)
12
- }
13
-
14
- type StoreTuple<T> = [T, (...args: unknown[]) => void]
15
- type ReduxShim<T> = {
16
- getState: () => T
17
- dispatch: (action: (setStore: unknown, store: T) => void) => void
18
- }
19
- export type RechartsStoreHandle = StoreTuple<ChartState> & ReduxShim<ChartState>
20
-
21
- export function createRechartsStore(preloadedState?: Partial<ChartState>): RechartsStoreHandle {
22
- const [store, setStore] = createStore<ChartState>(createInitialChartState(preloadedState))
23
- const result = [store, setStore] as unknown as RechartsStoreHandle
24
- result.getState = () => store
25
- result.dispatch = (action) => {
26
- action(setStore, store)
27
- }
28
- return result
29
- }
@@ -1,9 +0,0 @@
1
- import { snapshot } from "solid-js"
2
-
3
- /**
4
- * Inside a store draft, entries are store proxies, never `===` the raw object that was
5
- * written. Compare through `snapshot`, which resolves a proxy to its backing object.
6
- */
7
- export function isSameStoreEntry(a: unknown, b: unknown): boolean {
8
- return a === b || snapshot(a) === snapshot(b)
9
- }
@@ -1,10 +0,0 @@
1
- import { runWithOwner } from "solid-js"
2
-
3
- /**
4
- * Runs chart-state writes from a cleanup. Disposal can happen inside a computation
5
- * (for example a `Show` switching branches), where Solid 2 rejects owned writes;
6
- * teardown bookkeeping has no owner of its own.
7
- */
8
- export function teardownWrite(write: () => void): void {
9
- runWithOwner(null, write)
10
- }
@@ -1,23 +0,0 @@
1
- import type { ChartState } from "./chartState"
2
- import type { TooltipInteractionState } from "./tooltipSlice"
3
-
4
- type DraftSetter = (write: (draft: ChartState) => void) => void
5
-
6
- /**
7
- * A chart's own pointer interaction, mirroring upstream's setMouseOverAxisIndex /
8
- * setMouseClickAxisIndex / setActiveMouseOverItemIndex / setActiveClickItemIndex reducers:
9
- * it ends any incoming synchronisation and keyboard interaction before recording itself.
10
- */
11
- export function setTooltipInteraction(
12
- setState: DraftSetter,
13
- interaction: "axisInteraction" | "itemInteraction",
14
- trigger: "hover" | "click",
15
- payload: TooltipInteractionState,
16
- ): void {
17
- setState((draft) => {
18
- draft.tooltip.syncInteraction.active = false
19
- draft.tooltip.syncInteraction.sourceViewBox = undefined
20
- draft.tooltip.keyboardInteraction.active = false
21
- draft.tooltip[interaction][trigger] = payload
22
- })
23
- }