@octanejs/recharts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +53 -0
  3. package/src/animation/AnimatedItems.tsrx +82 -0
  4. package/src/animation/AnimationControllerImpl.js +33 -0
  5. package/src/animation/AnimationHandle.js +291 -0
  6. package/src/animation/JavascriptAnimate.tsrx +81 -0
  7. package/src/animation/easing.js +193 -0
  8. package/src/animation/matchBy.js +279 -0
  9. package/src/animation/timeoutController.js +49 -0
  10. package/src/animation/useAnimationController.ts +22 -0
  11. package/src/animation/useAnimationStartSnapshot.ts +43 -0
  12. package/src/animation/util.js +11 -0
  13. package/src/cartesian/Bar.ts +4 -0
  14. package/src/cartesian/Bar.tsrx +716 -0
  15. package/src/cartesian/Bar.tsrx.d.ts +4 -0
  16. package/src/cartesian/BarStack.tsrx +97 -0
  17. package/src/cartesian/BarStack.tsrx.d.ts +6 -0
  18. package/src/cartesian/CartesianAxis.tsrx +413 -0
  19. package/src/cartesian/CartesianAxis.tsrx.d.ts +3 -0
  20. package/src/cartesian/GraphicalItemClipPath.tsrx +44 -0
  21. package/src/cartesian/Line.ts +4 -0
  22. package/src/cartesian/Line.tsrx +544 -0
  23. package/src/cartesian/Line.tsrx.d.ts +4 -0
  24. package/src/cartesian/LineDrawShape.tsrx +106 -0
  25. package/src/cartesian/LineDrawShape.tsrx.d.ts +2 -0
  26. package/src/cartesian/XAxis.tsrx +156 -0
  27. package/src/cartesian/XAxis.tsrx.d.ts +3 -0
  28. package/src/cartesian/YAxis.tsrx +183 -0
  29. package/src/cartesian/YAxis.tsrx.d.ts +3 -0
  30. package/src/cartesian/getCartesianPosition.js +277 -0
  31. package/src/cartesian/getEquidistantTicks.js +133 -0
  32. package/src/cartesian/getTicks.js +280 -0
  33. package/src/cartesian/useAnimatedLineLength.ts +33 -0
  34. package/src/chart/BarChart.tsrx +22 -0
  35. package/src/chart/BarChart.tsrx.d.ts +2 -0
  36. package/src/chart/CartesianChart.tsrx +76 -0
  37. package/src/chart/CartesianChart.tsrx.d.ts +10 -0
  38. package/src/chart/CategoricalChart.tsrx +54 -0
  39. package/src/chart/LineChart.tsrx +22 -0
  40. package/src/chart/LineChart.tsrx.d.ts +2 -0
  41. package/src/chart/RechartsWrapper.tsrx +294 -0
  42. package/src/component/ActivePoints.tsrx +76 -0
  43. package/src/component/Cell.ts +37 -0
  44. package/src/component/Dots.tsrx +74 -0
  45. package/src/component/Label.tsrx +309 -0
  46. package/src/component/Label.tsrx.d.ts +12 -0
  47. package/src/component/LabelList.tsrx +83 -0
  48. package/src/component/LabelList.tsrx.d.ts +8 -0
  49. package/src/component/ResponsiveContainer.ts +22 -0
  50. package/src/component/Text.tsrx +281 -0
  51. package/src/component/Text.tsrx.d.ts +9 -0
  52. package/src/component/responsiveContainerUtils.js +111 -0
  53. package/src/container/ClipPathProvider.tsrx +29 -0
  54. package/src/container/Layer.tsrx +9 -0
  55. package/src/container/Layer.tsrx.d.ts +6 -0
  56. package/src/container/RootSurface.tsrx +76 -0
  57. package/src/container/Surface.tsrx +23 -0
  58. package/src/container/Surface.tsrx.d.ts +12 -0
  59. package/src/context/CellsContext.ts +80 -0
  60. package/src/context/ErrorBarContext.tsrx +53 -0
  61. package/src/context/PanoramaContext.ts +10 -0
  62. package/src/context/RegisterGraphicalItemId.tsrx +19 -0
  63. package/src/context/accessibilityContext.js +10 -0
  64. package/src/context/chartDataContext.ts +57 -0
  65. package/src/context/chartLayoutContext.ts +171 -0
  66. package/src/context/legendPortalContext.ts +5 -0
  67. package/src/context/tooltipContext.js +55 -0
  68. package/src/context/tooltipPortalContext.ts +5 -0
  69. package/src/hooks.js +509 -0
  70. package/src/index.ts +64 -0
  71. package/src/internal.ts +37 -0
  72. package/src/polar/defaultPolarAngleAxisProps.js +27 -0
  73. package/src/polar/defaultPolarRadiusAxisProps.js +24 -0
  74. package/src/shape/Cross.tsrx +25 -0
  75. package/src/shape/Cross.tsrx.d.ts +12 -0
  76. package/src/shape/Curve.tsrx +132 -0
  77. package/src/shape/Curve.tsrx.d.ts +42 -0
  78. package/src/shape/Dot.tsrx +21 -0
  79. package/src/shape/Dot.tsrx.d.ts +9 -0
  80. package/src/shape/Polygon.tsrx +95 -0
  81. package/src/shape/Polygon.tsrx.d.ts +13 -0
  82. package/src/shape/Rectangle.tsrx +162 -0
  83. package/src/shape/Rectangle.tsrx.d.ts +31 -0
  84. package/src/shape/Sector.tsrx +219 -0
  85. package/src/shape/Sector.tsrx.d.ts +29 -0
  86. package/src/shape/Symbols.tsrx +95 -0
  87. package/src/shape/Symbols.tsrx.d.ts +15 -0
  88. package/src/shape/Trapezoid.tsrx +56 -0
  89. package/src/shape/Trapezoid.tsrx.d.ts +29 -0
  90. package/src/state/RechartsReduxContext.ts +7 -0
  91. package/src/state/RechartsStoreProvider.tsrx +24 -0
  92. package/src/state/ReportChartProps.ts +13 -0
  93. package/src/state/ReportEventSettings.ts +15 -0
  94. package/src/state/ReportMainChartProps.ts +22 -0
  95. package/src/state/SetGraphicalItem.ts +61 -0
  96. package/src/state/SetLegendPayload.ts +61 -0
  97. package/src/state/SetTooltipEntrySettings.ts +40 -0
  98. package/src/state/brushSlice.js +36 -0
  99. package/src/state/cartesianAxisSlice.js +256 -0
  100. package/src/state/chartDataSlice.js +67 -0
  101. package/src/state/errorBarSlice.js +53 -0
  102. package/src/state/eventSettingsSlice.js +25 -0
  103. package/src/state/externalEventsMiddleware.js +127 -0
  104. package/src/state/graphicalItemsSlice.js +91 -0
  105. package/src/state/hooks.ts +46 -0
  106. package/src/state/keyboardEventsMiddleware.js +226 -0
  107. package/src/state/layoutSlice.js +57 -0
  108. package/src/state/legendSlice.js +83 -0
  109. package/src/state/mouseEventsMiddleware.js +130 -0
  110. package/src/state/optionsSlice.js +45 -0
  111. package/src/state/polarAxisSlice.js +33 -0
  112. package/src/state/polarOptionsSlice.js +26 -0
  113. package/src/state/reduxDevtoolsJsonStringifyReplacer.js +14 -0
  114. package/src/state/referenceElementsSlice.js +51 -0
  115. package/src/state/renderedTicksSlice.js +41 -0
  116. package/src/state/rootPropsSlice.js +48 -0
  117. package/src/state/selectors/arrayEqualityCheck.js +32 -0
  118. package/src/state/selectors/axisSelectors.js +2113 -0
  119. package/src/state/selectors/barSelectors.js +263 -0
  120. package/src/state/selectors/barStackSelectors.js +65 -0
  121. package/src/state/selectors/brushSelectors.js +21 -0
  122. package/src/state/selectors/combiners/combineActiveLabel.js +18 -0
  123. package/src/state/selectors/combiners/combineActiveTooltipIndex.js +75 -0
  124. package/src/state/selectors/combiners/combineAllBarPositions.js +169 -0
  125. package/src/state/selectors/combiners/combineAxisRangeWithReverse.js +11 -0
  126. package/src/state/selectors/combiners/combineBarPosition.js +17 -0
  127. package/src/state/selectors/combiners/combineBarSizeList.js +115 -0
  128. package/src/state/selectors/combiners/combineCheckedDomain.js +44 -0
  129. package/src/state/selectors/combiners/combineConfiguredScale.js +46 -0
  130. package/src/state/selectors/combiners/combineCoordinateForDefaultIndex.js +48 -0
  131. package/src/state/selectors/combiners/combineDisplayedStackedData.js +54 -0
  132. package/src/state/selectors/combiners/combineInverseScaleFunction.js +12 -0
  133. package/src/state/selectors/combiners/combineRealScaleType.js +36 -0
  134. package/src/state/selectors/combiners/combineStackedData.js +22 -0
  135. package/src/state/selectors/combiners/combineTooltipInteractionState.js +121 -0
  136. package/src/state/selectors/combiners/combineTooltipPayload.js +248 -0
  137. package/src/state/selectors/combiners/combineTooltipPayloadConfigurations.js +59 -0
  138. package/src/state/selectors/containerSelectors.js +6 -0
  139. package/src/state/selectors/dataSelectors.js +97 -0
  140. package/src/state/selectors/graphicalItemSelectors.js +25 -0
  141. package/src/state/selectors/legendSelectors.js +18 -0
  142. package/src/state/selectors/lineSelectors.js +106 -0
  143. package/src/state/selectors/numberDomainEqualityCheck.js +11 -0
  144. package/src/state/selectors/pickAxisId.js +3 -0
  145. package/src/state/selectors/pickAxisType.js +3 -0
  146. package/src/state/selectors/polarAxisSelectors.js +237 -0
  147. package/src/state/selectors/rootPropsSelectors.js +13 -0
  148. package/src/state/selectors/selectActivePropsFromChartPointer.js +23 -0
  149. package/src/state/selectors/selectAllAxes.js +15 -0
  150. package/src/state/selectors/selectChartOffset.js +12 -0
  151. package/src/state/selectors/selectChartOffsetInternal.js +174 -0
  152. package/src/state/selectors/selectPlotArea.js +19 -0
  153. package/src/state/selectors/selectTooltipAxisId.js +3 -0
  154. package/src/state/selectors/selectTooltipAxisType.js +25 -0
  155. package/src/state/selectors/selectTooltipEventType.js +27 -0
  156. package/src/state/selectors/selectTooltipPayloadSearcher.js +3 -0
  157. package/src/state/selectors/selectTooltipSettings.js +3 -0
  158. package/src/state/selectors/selectTooltipState.js +3 -0
  159. package/src/state/selectors/selectors.js +222 -0
  160. package/src/state/selectors/tooltipSelectors.js +471 -0
  161. package/src/state/selectors/touchSelectors.js +31 -0
  162. package/src/state/store.js +101 -0
  163. package/src/state/tooltipSlice.js +237 -0
  164. package/src/state/touchEventsMiddleware.js +140 -0
  165. package/src/state/types/StackedGraphicalItem.js +18 -0
  166. package/src/state/zIndexSlice.js +167 -0
  167. package/src/synchronisation/syncSelectors.js +5 -0
  168. package/src/synchronisation/useChartSynchronisation.tsrx +285 -0
  169. package/src/util/ActiveShapeUtils.tsrx +62 -0
  170. package/src/util/BarUtils.tsrx +35 -0
  171. package/src/util/CartesianUtils.js +66 -0
  172. package/src/util/ChartUtils.js +630 -0
  173. package/src/util/Constants.js +42 -0
  174. package/src/util/DOMUtils.js +180 -0
  175. package/src/util/DataUtils.js +199 -0
  176. package/src/util/Events.js +7 -0
  177. package/src/util/Global.js +13 -0
  178. package/src/util/LRUCache.js +58 -0
  179. package/src/util/LogUtils.js +29 -0
  180. package/src/util/PolarUtils.js +190 -0
  181. package/src/util/ReactUtils.ts +94 -0
  182. package/src/util/ReduceCSSCalc.js +260 -0
  183. package/src/util/TickUtils.js +43 -0
  184. package/src/util/YAxisUtils.js +43 -0
  185. package/src/util/axisPropsAreEqual.js +63 -0
  186. package/src/util/createEventProxy.js +18 -0
  187. package/src/util/excludeEventProps.js +172 -0
  188. package/src/util/getActiveCoordinate.js +253 -0
  189. package/src/util/getAxisTypeBasedOnLayout.js +17 -0
  190. package/src/util/getClassNameFromUnknown.js +8 -0
  191. package/src/util/getEveryNth.js +29 -0
  192. package/src/util/getRadiusAndStrokeWidthFromDot.js +28 -0
  193. package/src/util/getRelativeCoordinate.js +96 -0
  194. package/src/util/getSliced.js +11 -0
  195. package/src/util/isDomainSpecifiedByUser.js +255 -0
  196. package/src/util/isWellBehavedNumber.js +8 -0
  197. package/src/util/propsAreEqual.js +96 -0
  198. package/src/util/resolveDefaultProps.js +131 -0
  199. package/src/util/round.js +39 -0
  200. package/src/util/scale/RechartsScale.js +68 -0
  201. package/src/util/scale/createCategoricalInverse.js +77 -0
  202. package/src/util/scale/getNiceTickValues.js +354 -0
  203. package/src/util/scale/index.js +3 -0
  204. package/src/util/scale/util/arithmetic.js +51 -0
  205. package/src/util/stacks/getStackSeriesIdentifier.js +10 -0
  206. package/src/util/svgPropertiesAndEvents.ts +29 -0
  207. package/src/util/svgPropertiesNoEvents.js +383 -0
  208. package/src/util/types.ts +59 -0
  209. package/src/util/useAnimationId.ts +14 -0
  210. package/src/util/useId.ts +13 -0
  211. package/src/util/usePrefersReducedMotion.ts +30 -0
  212. package/src/util/useReportScale.ts +26 -0
  213. package/src/util/useUniqueId.js +34 -0
  214. package/src/zIndex/DefaultZIndexes.js +75 -0
  215. package/src/zIndex/ZIndexLayer.tsrx +80 -0
  216. package/src/zIndex/ZIndexLayer.tsrx.d.ts +2 -0
  217. package/src/zIndex/ZIndexPortal.tsrx +43 -0
  218. package/src/zIndex/getZIndexFromUnknown.js +15 -0
  219. package/src/zIndex/zIndexSelectors.js +45 -0
@@ -0,0 +1,219 @@
1
+ // Port of shape/Sector.tsx — the pie/radial-bar wedge (arc path with optional
2
+ // per-corner rounding). Path strings must be BYTE-IDENTICAL to upstream:
3
+ // recharts builds them with roundTemplateLiteral (every interpolated number
4
+ // rounded to 4dp, template whitespace/newlines preserved verbatim) — the
5
+ // template literals below reproduce upstream's exact strings including their
6
+ // embedded newlines and indentation.
7
+ import { clsx } from 'clsx';
8
+ import { polarToCartesian, RADIAN } from '../util/PolarUtils';
9
+ import { getPercentValue, mathSign } from '../util/DataUtils';
10
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
11
+ import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents.ts';
12
+ import { roundTemplateLiteral } from '../util/round';
13
+
14
+ const getDeltaAngle = (startAngle, endAngle) => {
15
+ const sign = mathSign(endAngle - startAngle);
16
+ const deltaAngle = Math.min(Math.abs(endAngle - startAngle), 359.999);
17
+ return sign * deltaAngle;
18
+ };
19
+
20
+ const getTangentCircle = ({
21
+ cx,
22
+ cy,
23
+ radius,
24
+ angle,
25
+ sign,
26
+ isExternal,
27
+ cornerRadius,
28
+ cornerIsExternal,
29
+ }) => {
30
+ const centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
31
+ const theta = Math.asin(cornerRadius / centerRadius) / RADIAN;
32
+ const centerAngle = cornerIsExternal ? angle : angle + sign * theta;
33
+ const center = polarToCartesian(cx, cy, centerRadius, centerAngle);
34
+ // The coordinate of point which is tangent to the circle
35
+ const circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
36
+ // The coordinate of point which is tangent to the radius line
37
+ const lineTangencyAngle = cornerIsExternal ? angle - sign * theta : angle;
38
+ const lineTangency = polarToCartesian(
39
+ cx,
40
+ cy,
41
+ centerRadius * Math.cos(theta * RADIAN),
42
+ lineTangencyAngle,
43
+ );
44
+ return { center, circleTangency, lineTangency, theta };
45
+ };
46
+
47
+ const getSectorPath = ({ cx, cy, innerRadius, outerRadius, startAngle, endAngle }) => {
48
+ const angle = getDeltaAngle(startAngle, endAngle);
49
+
50
+ // When the angle of sector equals to 360, start point and end point coincide
51
+ const tempEndAngle = startAngle + angle;
52
+ const outerStartPoint = polarToCartesian(cx, cy, outerRadius, startAngle);
53
+ const outerEndPoint = polarToCartesian(cx, cy, outerRadius, tempEndAngle);
54
+ // Hoisted arc flags — inline `${+(…)}` expressions survive byte-identically
55
+ // but prettier splays them across lines; the string chunks stay verbatim.
56
+ const largeArc = +(Math.abs(angle) > 180);
57
+ const outerSweep = +(startAngle > tempEndAngle);
58
+ let path = roundTemplateLiteral`M ${outerStartPoint.x},${outerStartPoint.y}
59
+ A ${outerRadius},${outerRadius},0,
60
+ ${largeArc},${outerSweep},
61
+ ${outerEndPoint.x},${outerEndPoint.y}
62
+ `;
63
+ if (innerRadius > 0) {
64
+ const innerStartPoint = polarToCartesian(cx, cy, innerRadius, startAngle);
65
+ const innerEndPoint = polarToCartesian(cx, cy, innerRadius, tempEndAngle);
66
+ const innerSweep = +(startAngle <= tempEndAngle);
67
+ path +=
68
+ roundTemplateLiteral`L ${innerEndPoint.x},${innerEndPoint.y}
69
+ A ${innerRadius},${innerRadius},0,
70
+ ${largeArc},${innerSweep},
71
+ ${innerStartPoint.x},${innerStartPoint.y} Z`;
72
+ } else {
73
+ path += roundTemplateLiteral`L ${cx},${cy} Z`;
74
+ }
75
+ return path;
76
+ };
77
+
78
+ const getSectorWithCorner = ({
79
+ cx,
80
+ cy,
81
+ innerRadius,
82
+ outerRadius,
83
+ cornerRadius,
84
+ forceCornerRadius,
85
+ cornerIsExternal,
86
+ startAngle,
87
+ endAngle,
88
+ }) => {
89
+ const sign = mathSign(endAngle - startAngle);
90
+ const { circleTangency: soct, lineTangency: solt, theta: sot } = getTangentCircle({
91
+ cx,
92
+ cy,
93
+ radius: outerRadius,
94
+ angle: startAngle,
95
+ sign,
96
+ cornerRadius,
97
+ cornerIsExternal,
98
+ });
99
+ const { circleTangency: eoct, lineTangency: eolt, theta: eot } = getTangentCircle({
100
+ cx,
101
+ cy,
102
+ radius: outerRadius,
103
+ angle: endAngle,
104
+ sign: -sign,
105
+ cornerRadius,
106
+ cornerIsExternal,
107
+ });
108
+ const outerArcAngle =
109
+ cornerIsExternal
110
+ ? Math.abs(startAngle - endAngle)
111
+ : Math.abs(startAngle - endAngle) - sot - eot;
112
+ if (outerArcAngle < 0) {
113
+ if (forceCornerRadius) {
114
+ const cornerDiameter = cornerRadius * 2;
115
+ return roundTemplateLiteral`M ${solt.x},${solt.y}
116
+ a${cornerRadius},${cornerRadius},0,0,1,${cornerDiameter},0
117
+ a${cornerRadius},${cornerRadius},0,0,1,${-cornerDiameter},0
118
+ `;
119
+ }
120
+ return getSectorPath({ cx, cy, innerRadius, outerRadius, startAngle, endAngle });
121
+ }
122
+ const sweep = +(sign < 0);
123
+ const outerLargeArc = +(outerArcAngle > 180);
124
+ let path = roundTemplateLiteral`M ${solt.x},${solt.y}
125
+ A${cornerRadius},${cornerRadius},0,0,${sweep},${soct.x},${soct.y}
126
+ A${outerRadius},${outerRadius},0,${outerLargeArc},${sweep},${eoct.x},${eoct.y}
127
+ A${cornerRadius},${cornerRadius},0,0,${sweep},${eolt.x},${eolt.y}
128
+ `;
129
+ if (innerRadius > 0) {
130
+ const { circleTangency: sict, lineTangency: silt, theta: sit } = getTangentCircle({
131
+ cx,
132
+ cy,
133
+ radius: innerRadius,
134
+ angle: startAngle,
135
+ sign,
136
+ isExternal: true,
137
+ cornerRadius,
138
+ cornerIsExternal,
139
+ });
140
+ const { circleTangency: eict, lineTangency: eilt, theta: eit } = getTangentCircle({
141
+ cx,
142
+ cy,
143
+ radius: innerRadius,
144
+ angle: endAngle,
145
+ sign: -sign,
146
+ isExternal: true,
147
+ cornerRadius,
148
+ cornerIsExternal,
149
+ });
150
+ const innerArcAngle =
151
+ cornerIsExternal
152
+ ? Math.abs(startAngle - endAngle)
153
+ : Math.abs(startAngle - endAngle) - sit - eit;
154
+ if (innerArcAngle < 0 && cornerRadius === 0) {
155
+ return path + 'L' + cx + ',' + cy + 'Z';
156
+ }
157
+ const innerLargeArc = +(innerArcAngle > 180);
158
+ const innerSweep = +(sign > 0);
159
+ path +=
160
+ roundTemplateLiteral`L${eilt.x},${eilt.y}
161
+ A${cornerRadius},${cornerRadius},0,0,${sweep},${eict.x},${eict.y}
162
+ A${innerRadius},${innerRadius},0,${innerLargeArc},${innerSweep},${sict.x},${sict.y}
163
+ A${cornerRadius},${cornerRadius},0,0,${sweep},${silt.x},${silt.y}Z`;
164
+ } else {
165
+ path += roundTemplateLiteral`L${cx},${cy}Z`;
166
+ }
167
+ return path;
168
+ };
169
+
170
+ export const defaultSectorProps = {
171
+ cx: 0,
172
+ cy: 0,
173
+ innerRadius: 0,
174
+ outerRadius: 0,
175
+ startAngle: 0,
176
+ endAngle: 0,
177
+ cornerRadius: 0,
178
+ forceCornerRadius: false,
179
+ cornerIsExternal: false,
180
+ };
181
+
182
+ export function Sector(sectorProps) {
183
+ const props = resolveDefaultProps(sectorProps, defaultSectorProps);
184
+ const {
185
+ cx,
186
+ cy,
187
+ innerRadius,
188
+ outerRadius,
189
+ cornerRadius,
190
+ forceCornerRadius,
191
+ cornerIsExternal,
192
+ startAngle,
193
+ endAngle,
194
+ className,
195
+ } = props;
196
+ if (outerRadius < innerRadius || startAngle === endAngle) {
197
+ return null;
198
+ }
199
+ const layerClass = clsx('recharts-sector', className);
200
+ const deltaRadius = outerRadius - innerRadius;
201
+ const cr = getPercentValue(cornerRadius, deltaRadius, 0, true);
202
+ let path;
203
+ if (cr > 0 && Math.abs(startAngle - endAngle) < 360) {
204
+ path = getSectorWithCorner({
205
+ cx,
206
+ cy,
207
+ innerRadius,
208
+ outerRadius,
209
+ cornerRadius: Math.min(cr, deltaRadius / 2),
210
+ forceCornerRadius,
211
+ cornerIsExternal,
212
+ startAngle,
213
+ endAngle,
214
+ });
215
+ } else {
216
+ path = getSectorPath({ cx, cy, innerRadius, outerRadius, startAngle, endAngle });
217
+ }
218
+ return <path {...svgPropertiesAndEvents(props)} className={layerClass} d={path} />;
219
+ }
@@ -0,0 +1,29 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export interface SectorProps {
3
+ cx?: number;
4
+ cy?: number;
5
+ innerRadius?: number;
6
+ outerRadius?: number;
7
+ startAngle?: number;
8
+ endAngle?: number;
9
+ cornerRadius?: number | string;
10
+ forceCornerRadius?: boolean;
11
+ cornerIsExternal?: boolean;
12
+ className?: unknown;
13
+ [key: string]: unknown;
14
+ }
15
+ export declare const defaultSectorProps: Required<
16
+ Pick<
17
+ SectorProps,
18
+ | 'cx'
19
+ | 'cy'
20
+ | 'innerRadius'
21
+ | 'outerRadius'
22
+ | 'startAngle'
23
+ | 'endAngle'
24
+ | 'cornerRadius'
25
+ | 'forceCornerRadius'
26
+ | 'cornerIsExternal'
27
+ >
28
+ >;
29
+ export declare const Sector: (props: SectorProps) => unknown;
@@ -0,0 +1,95 @@
1
+ // Port of shape/Symbols.tsx — the scatter/legend marker shapes, drawn by
2
+ // victory-vendor's d3-shape symbol generators (byte-identical `d` output).
3
+ import {
4
+ symbol as shapeSymbol,
5
+ symbolCircle,
6
+ symbolCross,
7
+ symbolDiamond,
8
+ symbolSquare,
9
+ symbolStar,
10
+ symbolTriangle,
11
+ symbolWye,
12
+ } from 'victory-vendor/d3-shape';
13
+ import { clsx } from 'clsx';
14
+ import { isNumber, upperFirst } from '../util/DataUtils';
15
+ import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents.ts';
16
+
17
+ const symbolFactories = {
18
+ symbolCircle,
19
+ symbolCross,
20
+ symbolDiamond,
21
+ symbolSquare,
22
+ symbolStar,
23
+ symbolTriangle,
24
+ symbolWye,
25
+ };
26
+ const RADIAN = Math.PI / 180;
27
+
28
+ const getSymbolFactory = (type) => {
29
+ const name = 'symbol' + upperFirst(type);
30
+ return symbolFactories[name] || symbolCircle;
31
+ };
32
+
33
+ const calculateAreaSize = (size, sizeType, type) => {
34
+ if (sizeType === 'area') {
35
+ return size;
36
+ }
37
+ switch (type) {
38
+ case 'cross':
39
+ return (5 * size * size) / 9;
40
+ case 'diamond':
41
+ return (0.5 * size * size) / Math.sqrt(3);
42
+ case 'square':
43
+ return size * size;
44
+ case 'star': {
45
+ const angle = 18 * RADIAN;
46
+ return 1.25 * size * size * (Math.tan(angle) - Math.tan(angle * 2) * Math.tan(angle) ** 2);
47
+ }
48
+ case 'triangle':
49
+ return (Math.sqrt(3) * size * size) / 4;
50
+ case 'wye':
51
+ return ((21 - 10 * Math.sqrt(3)) * size * size) / 8;
52
+ default:
53
+ return (Math.PI * size * size) / 4;
54
+ }
55
+ };
56
+
57
+ const registerSymbol = (key, factory) => {
58
+ symbolFactories['symbol' + upperFirst(key)] = factory;
59
+ };
60
+
61
+ /** Renders a symbol from a set of predefined shapes. */
62
+ export function Symbols(symbolsProps) {
63
+ const { type = 'circle', size = 64, sizeType = 'area', ...rest } = symbolsProps;
64
+ const props = { ...rest, type, size, sizeType };
65
+ // Runtime guard (recharts#6197): `type` can arrive as a non-string despite
66
+ // the declared union; fall back to 'circle'.
67
+ let realType = 'circle';
68
+ if (typeof type === 'string') {
69
+ realType = type;
70
+ }
71
+ const getSymbolPath = () => {
72
+ const symbolFactory = getSymbolFactory(realType);
73
+ const symbolGen = shapeSymbol().type(symbolFactory).size(
74
+ calculateAreaSize(size, sizeType, realType),
75
+ );
76
+ const s = symbolGen();
77
+ if (s === null) {
78
+ return undefined;
79
+ }
80
+ return s;
81
+ };
82
+ const { className, cx, cy } = props;
83
+ const filteredProps = svgPropertiesAndEvents(props);
84
+ if (isNumber(cx) && isNumber(cy) && isNumber(size)) {
85
+ return <path
86
+ {...filteredProps}
87
+ className={clsx('recharts-symbols', className)}
88
+ transform={'translate(' + cx + ', ' + cy + ')'}
89
+ d={getSymbolPath()}
90
+ />;
91
+ }
92
+ return null;
93
+ }
94
+
95
+ Symbols.registerSymbol = registerSymbol;
@@ -0,0 +1,15 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export type SymbolType = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
3
+ export interface SymbolsProps {
4
+ type?: SymbolType;
5
+ size?: number;
6
+ sizeType?: 'area' | 'diameter';
7
+ cx?: number;
8
+ cy?: number;
9
+ className?: unknown;
10
+ [key: string]: unknown;
11
+ }
12
+ export declare const Symbols: {
13
+ (props: SymbolsProps): unknown;
14
+ registerSymbol: (key: string, factory: unknown) => void;
15
+ };
@@ -0,0 +1,56 @@
1
+ // Port of shape/Trapezoid.tsx — the funnel-chart segment. Phase 0 ports the
2
+ // STATIC path (isUpdateAnimationActive defaults false); the update animation
3
+ // and the getTotalLength entrance dash arrive with the Phase 5 animation port.
4
+ // Path strings mirror upstream's roundTemplateLiteral output byte-for-byte.
5
+ import { clsx } from 'clsx';
6
+ import { resolveDefaultProps } from '../util/resolveDefaultProps';
7
+ import { svgPropertiesAndEvents } from '../util/svgPropertiesAndEvents.ts';
8
+ import { roundTemplateLiteral } from '../util/round';
9
+
10
+ const getTrapezoidPath = (x, y, upperWidth, lowerWidth, height) => {
11
+ const widthGap = upperWidth - lowerWidth;
12
+ let path;
13
+ path = roundTemplateLiteral`M ${x},${y}`;
14
+ path += roundTemplateLiteral`L ${x + upperWidth},${y}`;
15
+ path += roundTemplateLiteral`L ${x + upperWidth - widthGap / 2},${y + height}`;
16
+ path += roundTemplateLiteral`L ${x + upperWidth - widthGap / 2 - lowerWidth},${y + height}`;
17
+ path += roundTemplateLiteral`L ${x},${y} Z`;
18
+ return path;
19
+ };
20
+
21
+ export const defaultTrapezoidProps = {
22
+ x: 0,
23
+ y: 0,
24
+ upperWidth: 0,
25
+ lowerWidth: 0,
26
+ height: 0,
27
+ isUpdateAnimationActive: false,
28
+ animationBegin: 0,
29
+ animationDuration: 1500,
30
+ animationEasing: 'ease',
31
+ };
32
+
33
+ export function Trapezoid(outsideProps) {
34
+ const trapezoidProps = resolveDefaultProps(outsideProps, defaultTrapezoidProps);
35
+ const { x, y, upperWidth, lowerWidth, height, className } = trapezoidProps;
36
+
37
+ if (
38
+ x !== +x || y !== +y || upperWidth !== +upperWidth || lowerWidth !== +lowerWidth ||
39
+ height !== +height ||
40
+ upperWidth === 0 && lowerWidth === 0 ||
41
+ height === 0
42
+ ) {
43
+ return null;
44
+ }
45
+ const layerClass = clsx('recharts-trapezoid', className);
46
+
47
+ // Static path — the update-animation branch is a Phase 5 port. Upstream's
48
+ // static branch wraps the path in a <g>, so mirror that.
49
+ return <g>
50
+ <path
51
+ {...svgPropertiesAndEvents(trapezoidProps)}
52
+ className={layerClass}
53
+ d={getTrapezoidPath(x, y, upperWidth, lowerWidth, height)}
54
+ />
55
+ </g>;
56
+ }
@@ -0,0 +1,29 @@
1
+ // Type declaration for the .tsrx component (resolved by relative path).
2
+ export interface TrapezoidProps {
3
+ x?: number;
4
+ y?: number;
5
+ upperWidth?: number;
6
+ lowerWidth?: number;
7
+ height?: number;
8
+ className?: unknown;
9
+ isUpdateAnimationActive?: boolean;
10
+ animationBegin?: number;
11
+ animationDuration?: number;
12
+ animationEasing?: string;
13
+ [key: string]: unknown;
14
+ }
15
+ export declare const defaultTrapezoidProps: Required<
16
+ Pick<
17
+ TrapezoidProps,
18
+ | 'x'
19
+ | 'y'
20
+ | 'upperWidth'
21
+ | 'lowerWidth'
22
+ | 'height'
23
+ | 'isUpdateAnimationActive'
24
+ | 'animationBegin'
25
+ | 'animationDuration'
26
+ | 'animationEasing'
27
+ >
28
+ >;
29
+ export declare const Trapezoid: (props: TrapezoidProps) => unknown;
@@ -0,0 +1,7 @@
1
+ // Recharts' own isolated redux context — port of state/RechartsReduxContext.ts.
2
+ // A dedicated context (NOT @octanejs/redux's default) so a chart's store never
3
+ // interferes with an app-level redux store the host page may be running.
4
+ import { createContext } from 'octane';
5
+ import type { ReactReduxContextValue } from '@octanejs/redux';
6
+
7
+ export const RechartsReduxContext = createContext<ReactReduxContextValue | null>(null);
@@ -0,0 +1,24 @@
1
+ // Port of state/RechartsStoreProvider.tsx — one isolated RTK store per chart,
2
+ // provided through the custom RechartsReduxContext (via @octanejs/redux's
3
+ // Provider). A PANORAMA chart (the Brush preview) renders NO provider and
4
+ // inherits the parent chart's store.
5
+ import { useRef } from 'octane';
6
+ import { Provider } from '@octanejs/redux';
7
+ import { createRechartsStore } from './store';
8
+ import { useIsPanorama } from '../context/PanoramaContext';
9
+ import { RechartsReduxContext } from './RechartsReduxContext';
10
+
11
+ export function RechartsStoreProvider(props) {
12
+ const { preloadedState, children, reduxStoreName } = props;
13
+ const isPanorama = useIsPanorama();
14
+ // One store per CHART (not per page): recharts supports multiple independent
15
+ // charts, so the store rides a ref, created on first render.
16
+ const storeRef = useRef(null);
17
+ if (isPanorama) {
18
+ return children;
19
+ }
20
+ if (storeRef.current == null) {
21
+ storeRef.current = createRechartsStore(preloadedState, reduxStoreName);
22
+ }
23
+ return <Provider context={RechartsReduxContext} store={storeRef.current}>{children}</Provider>;
24
+ }
@@ -0,0 +1,13 @@
1
+ // Port of state/ReportChartProps.tsx — publishes the chart root's props into
2
+ // the rootProps slice.
3
+ import { useEffect } from 'octane';
4
+ import { updateOptions } from './rootPropsSlice';
5
+ import { useAppDispatch } from './hooks';
6
+
7
+ export function ReportChartProps(props: Record<string, unknown>): null {
8
+ const dispatch = useAppDispatch();
9
+ useEffect(() => {
10
+ dispatch(updateOptions(props));
11
+ }, [dispatch, props]);
12
+ return null;
13
+ }
@@ -0,0 +1,15 @@
1
+ // Port of state/ReportEventSettings.tsx.
2
+ import { memo, useEffect } from 'octane';
3
+ import { useAppDispatch } from './hooks';
4
+ import { setEventSettings } from './eventSettingsSlice';
5
+ import { propsAreEqual } from '../util/propsAreEqual';
6
+
7
+ const ReportEventSettingsImpl = (props: Record<string, unknown>): null => {
8
+ const dispatch = useAppDispatch();
9
+ useEffect(() => {
10
+ dispatch(setEventSettings(props));
11
+ }, [dispatch, props]);
12
+ return null;
13
+ };
14
+
15
+ export const ReportEventSettings = memo(ReportEventSettingsImpl, propsAreEqual);
@@ -0,0 +1,22 @@
1
+ // Port of state/ReportMainChartProps.tsx — layout + margin land in the store
2
+ // via effect (never during render), skipped entirely inside a Brush panorama.
3
+ import { memo, useEffect } from 'octane';
4
+ import { useIsPanorama } from '../context/PanoramaContext';
5
+ import { setLayout, setMargin } from './layoutSlice';
6
+ import { useAppDispatch } from './hooks';
7
+ import { propsAreEqual } from '../util/propsAreEqual';
8
+
9
+ function ReportMainChartPropsImpl(props: { layout: unknown; margin: unknown }): null {
10
+ const { layout, margin } = props;
11
+ const dispatch = useAppDispatch();
12
+ const isPanorama = useIsPanorama();
13
+ useEffect(() => {
14
+ if (!isPanorama) {
15
+ dispatch(setLayout(layout));
16
+ dispatch(setMargin(margin));
17
+ }
18
+ }, [dispatch, isPanorama, layout, margin]);
19
+ return null;
20
+ }
21
+
22
+ export const ReportMainChartProps = memo(ReportMainChartPropsImpl, propsAreEqual);
@@ -0,0 +1,61 @@
1
+ // Port of state/SetGraphicalItem.tsx — registers a graphical item's settings
2
+ // in the store on layout-effect timing (add on mount, replace on change,
3
+ // remove on unmount).
4
+ import { memo, useLayoutEffect, useRef } from 'octane';
5
+ import { useAppDispatch } from './hooks';
6
+ import {
7
+ addCartesianGraphicalItem,
8
+ addPolarGraphicalItem,
9
+ removeCartesianGraphicalItem,
10
+ removePolarGraphicalItem,
11
+ replaceCartesianGraphicalItem,
12
+ replacePolarGraphicalItem,
13
+ } from './graphicalItemsSlice';
14
+
15
+ const SetCartesianGraphicalItemImpl = (props: Record<string, unknown>): null => {
16
+ const dispatch = useAppDispatch();
17
+ const prevPropsRef = useRef<Record<string, unknown> | null>(null);
18
+ useLayoutEffect(() => {
19
+ if (prevPropsRef.current === null) {
20
+ dispatch(addCartesianGraphicalItem(props));
21
+ } else if (prevPropsRef.current !== props) {
22
+ dispatch(replaceCartesianGraphicalItem({ prev: prevPropsRef.current, next: props }));
23
+ }
24
+ prevPropsRef.current = props;
25
+ }, [dispatch, props]);
26
+ useLayoutEffect(() => {
27
+ return () => {
28
+ if (prevPropsRef.current) {
29
+ dispatch(removeCartesianGraphicalItem(prevPropsRef.current));
30
+ prevPropsRef.current = null;
31
+ }
32
+ };
33
+ }, [dispatch]);
34
+ return null;
35
+ };
36
+
37
+ export const SetCartesianGraphicalItem = memo(SetCartesianGraphicalItemImpl);
38
+
39
+ const SetPolarGraphicalItemImpl = (props: Record<string, unknown>): null => {
40
+ const dispatch = useAppDispatch();
41
+ const prevPropsRef = useRef<Record<string, unknown> | null>(null);
42
+ useLayoutEffect(() => {
43
+ if (prevPropsRef.current === null) {
44
+ dispatch(addPolarGraphicalItem(props));
45
+ } else if (prevPropsRef.current !== props) {
46
+ dispatch(replacePolarGraphicalItem({ prev: prevPropsRef.current, next: props }));
47
+ }
48
+ prevPropsRef.current = props;
49
+ }, [dispatch, props]);
50
+ useLayoutEffect(() => {
51
+ return () => {
52
+ if (prevPropsRef.current) {
53
+ dispatch(removePolarGraphicalItem(prevPropsRef.current));
54
+ prevPropsRef.current = null;
55
+ }
56
+ };
57
+ }, [dispatch]);
58
+ return null;
59
+ };
60
+
61
+ export const SetPolarGraphicalItem = memo(SetPolarGraphicalItemImpl);
@@ -0,0 +1,61 @@
1
+ // Port of state/SetLegendPayload.tsx — legend payload registration (cartesian
2
+ // skips panorama; polar gates on the polar layouts).
3
+ import { useLayoutEffect, useRef } from 'octane';
4
+ import { useIsPanorama } from '../context/PanoramaContext';
5
+ import { selectChartLayout } from '../context/chartLayoutContext';
6
+ import { useAppDispatch, useAppSelector } from './hooks';
7
+ import { addLegendPayload, replaceLegendPayload, removeLegendPayload } from './legendSlice';
8
+
9
+ export function SetLegendPayload(props: { legendPayload: unknown }): null {
10
+ const { legendPayload } = props;
11
+ const dispatch = useAppDispatch();
12
+ const isPanorama = useIsPanorama();
13
+ const prevPayloadRef = useRef<unknown>(null);
14
+ useLayoutEffect(() => {
15
+ if (isPanorama) {
16
+ return;
17
+ }
18
+ if (prevPayloadRef.current === null) {
19
+ dispatch(addLegendPayload(legendPayload));
20
+ } else if (prevPayloadRef.current !== legendPayload) {
21
+ dispatch(replaceLegendPayload({ prev: prevPayloadRef.current, next: legendPayload }));
22
+ }
23
+ prevPayloadRef.current = legendPayload;
24
+ }, [dispatch, isPanorama, legendPayload]);
25
+ useLayoutEffect(() => {
26
+ return () => {
27
+ if (prevPayloadRef.current) {
28
+ dispatch(removeLegendPayload(prevPayloadRef.current));
29
+ prevPayloadRef.current = null;
30
+ }
31
+ };
32
+ }, [dispatch]);
33
+ return null;
34
+ }
35
+
36
+ export function SetPolarLegendPayload(props: { legendPayload: unknown }): null {
37
+ const { legendPayload } = props;
38
+ const dispatch = useAppDispatch();
39
+ const layout = useAppSelector(selectChartLayout);
40
+ const prevPayloadRef = useRef<unknown>(null);
41
+ useLayoutEffect(() => {
42
+ if (layout !== 'centric' && layout !== 'radial') {
43
+ return;
44
+ }
45
+ if (prevPayloadRef.current === null) {
46
+ dispatch(addLegendPayload(legendPayload));
47
+ } else if (prevPayloadRef.current !== legendPayload) {
48
+ dispatch(replaceLegendPayload({ prev: prevPayloadRef.current, next: legendPayload }));
49
+ }
50
+ prevPayloadRef.current = legendPayload;
51
+ }, [dispatch, layout, legendPayload]);
52
+ useLayoutEffect(() => {
53
+ return () => {
54
+ if (prevPayloadRef.current) {
55
+ dispatch(removeLegendPayload(prevPayloadRef.current));
56
+ prevPayloadRef.current = null;
57
+ }
58
+ };
59
+ }, [dispatch]);
60
+ return null;
61
+ }