@octanejs/recharts 0.1.16 → 0.1.18

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 (88) hide show
  1. package/package.json +4 -4
  2. package/src/animation/CSSTransitionAnimate.tsrx +142 -0
  3. package/src/cartesian/Area.tsrx +1096 -0
  4. package/src/cartesian/Area.tsrx.d.ts +340 -0
  5. package/src/cartesian/AreaRevealShape.tsrx +202 -0
  6. package/src/cartesian/CartesianGrid.tsrx +643 -0
  7. package/src/cartesian/CartesianGrid.tsrx.d.ts +219 -0
  8. package/src/cartesian/ErrorBar.tsrx +322 -0
  9. package/src/cartesian/ErrorBar.tsrx.d.ts +131 -0
  10. package/src/cartesian/Funnel.tsrx +833 -0
  11. package/src/cartesian/Funnel.tsrx.d.ts +274 -0
  12. package/src/cartesian/ReferenceLine.tsrx +452 -0
  13. package/src/cartesian/ReferenceLine.tsrx.d.ts +178 -0
  14. package/src/cartesian/Scatter.tsrx +1076 -0
  15. package/src/cartesian/Scatter.tsrx.d.ts +351 -0
  16. package/src/cartesian/ZAxis.tsrx +148 -0
  17. package/src/cartesian/ZAxis.tsrx.d.ts +102 -0
  18. package/src/chart/AreaChart.tsrx +22 -0
  19. package/src/chart/AreaChart.tsrx.d.ts +12 -0
  20. package/src/chart/ComposedChart.tsrx +22 -0
  21. package/src/chart/ComposedChart.tsrx.d.ts +12 -0
  22. package/src/chart/FunnelChart.tsrx +22 -0
  23. package/src/chart/FunnelChart.tsrx.d.ts +12 -0
  24. package/src/chart/PieChart.tsrx +31 -0
  25. package/src/chart/PieChart.tsrx.d.ts +31 -0
  26. package/src/chart/PolarChart.tsrx +121 -0
  27. package/src/chart/RadarChart.tsrx +53 -0
  28. package/src/chart/RadarChart.tsrx.d.ts +31 -0
  29. package/src/chart/RadialBarChart.tsrx +31 -0
  30. package/src/chart/RadialBarChart.tsrx.d.ts +31 -0
  31. package/src/chart/Sankey.tsrx +1542 -0
  32. package/src/chart/Sankey.tsrx.d.ts +253 -0
  33. package/src/chart/ScatterChart.tsrx +22 -0
  34. package/src/chart/ScatterChart.tsrx.d.ts +12 -0
  35. package/src/chart/SunburstChart.tsrx +495 -0
  36. package/src/chart/SunburstChart.tsrx.d.ts +146 -0
  37. package/src/chart/types.ts +19 -0
  38. package/src/component/Cursor.tsrx +157 -0
  39. package/src/component/DefaultLegendContent.tsrx +288 -0
  40. package/src/component/DefaultLegendContent.tsrx.d.ts +125 -0
  41. package/src/component/DefaultTooltipContent.tsrx +215 -0
  42. package/src/component/DefaultTooltipContent.tsrx.d.ts +87 -0
  43. package/src/component/Legend.tsrx +302 -0
  44. package/src/component/Legend.tsrx.d.ts +88 -0
  45. package/src/component/ResponsiveContainer.ts +1 -22
  46. package/src/component/ResponsiveContainer.tsrx +171 -0
  47. package/src/component/ResponsiveContainer.tsrx.d.ts +81 -0
  48. package/src/component/Tooltip.tsrx +425 -0
  49. package/src/component/Tooltip.tsrx.d.ts +246 -0
  50. package/src/component/TooltipBoundingBox.tsrx +135 -0
  51. package/src/context/CellsContext.ts +12 -0
  52. package/src/context/legendPayloadContext.tsrx +11 -0
  53. package/src/context/useTooltipAxis.ts +20 -0
  54. package/src/index.d.ts +236 -0
  55. package/src/index.ts +67 -0
  56. package/src/polar/Pie.tsrx +1224 -0
  57. package/src/polar/Pie.tsrx.d.ts +436 -0
  58. package/src/polar/PolarAngleAxis.tsrx +554 -0
  59. package/src/polar/PolarAngleAxis.tsrx.d.ts +215 -0
  60. package/src/polar/PolarGrid.tsrx +317 -0
  61. package/src/polar/PolarGrid.tsrx.d.ts +117 -0
  62. package/src/polar/PolarRadiusAxis.tsrx +463 -0
  63. package/src/polar/PolarRadiusAxis.tsrx.d.ts +209 -0
  64. package/src/polar/Radar.tsrx +696 -0
  65. package/src/polar/Radar.tsrx.d.ts +215 -0
  66. package/src/polar/RadialBar.tsrx +887 -0
  67. package/src/polar/RadialBar.tsrx.d.ts +340 -0
  68. package/src/state/ReportPolarOptions.tsrx +11 -0
  69. package/src/state/selectors/areaSelectors.ts +257 -0
  70. package/src/state/selectors/funnelSelectors.ts +86 -0
  71. package/src/state/selectors/pieSelectors.ts +134 -0
  72. package/src/state/selectors/polarGridSelectors.ts +43 -0
  73. package/src/state/selectors/polarScaleSelectors.ts +159 -0
  74. package/src/state/selectors/polarSelectors.ts +198 -0
  75. package/src/state/selectors/radarSelectors.ts +228 -0
  76. package/src/state/selectors/radialBarSelectors.ts +511 -0
  77. package/src/state/selectors/scatterSelectors.ts +168 -0
  78. package/src/util/FunnelUtils.tsrx +19 -0
  79. package/src/util/RadialBarUtils.tsrx +29 -0
  80. package/src/util/ScatterUtils.tsrx +34 -0
  81. package/src/util/cursor/getCursorPoints.ts +45 -0
  82. package/src/util/cursor/getCursorRectangle.ts +28 -0
  83. package/src/util/cursor/getRadialCursorPoints.ts +31 -0
  84. package/src/util/payload/getUniqPayload.ts +28 -0
  85. package/src/util/scale/CartesianScaleHelper.ts +71 -0
  86. package/src/util/tooltip/translate.ts +168 -0
  87. package/src/util/types.ts +3 -0
  88. package/src/util/useElementOffset.ts +147 -0
@@ -0,0 +1,228 @@
1
+ import { createSelector } from 'reselect';
2
+ import { RechartsRootState } from '../store';
3
+ import {
4
+ AngleAxisForRadar,
5
+ computeRadarPoints,
6
+ RadarComposedData,
7
+ RadiusAxisForRadar,
8
+ } from '../../polar/Radar';
9
+ import { BaseAxisWithScale } from './axisSelectors';
10
+ import { selectPolarAxisScale, selectPolarAxisTicks } from './polarScaleSelectors';
11
+ import { selectAngleAxis, selectPolarViewBox, selectRadiusAxis } from './polarAxisSelectors';
12
+ import { AxisId } from '../cartesianAxisSlice';
13
+ import { selectChartDataAndAlwaysIgnoreIndexes } from './dataSelectors';
14
+ import { ChartDataState } from '../chartDataSlice';
15
+ import { DataKey, LayoutType, PolarViewBoxRequired, TickItem } from '../../util/types';
16
+ import { selectChartLayout } from '../../context/chartLayoutContext';
17
+ import { getBandSizeOfAxis, isCategoricalAxis } from '../../util/ChartUtils';
18
+ import { AngleAxisSettings, RadiusAxisSettings } from '../polarAxisSlice';
19
+ import { selectUnfilteredPolarItems } from './polarSelectors';
20
+ import { GraphicalItemId } from '../graphicalItemsSlice';
21
+ import { RechartsScale } from '../../util/scale/RechartsScale';
22
+
23
+ const selectRadiusAxisScale = (
24
+ state: RechartsRootState,
25
+ radiusAxisId: AxisId,
26
+ ): RechartsScale | undefined => selectPolarAxisScale(state, 'radiusAxis', radiusAxisId);
27
+
28
+ const selectRadiusAxisForRadar: (
29
+ state: RechartsRootState,
30
+ radiusAxisId: AxisId,
31
+ ) => RadiusAxisForRadar | undefined = createSelector(
32
+ [selectRadiusAxisScale],
33
+ (scale: RechartsScale | undefined): RadiusAxisForRadar | undefined => {
34
+ if (scale == null) {
35
+ return undefined;
36
+ }
37
+ return { scale };
38
+ },
39
+ );
40
+
41
+ export const selectRadiusAxisForBandSize: (
42
+ state: RechartsRootState,
43
+ radiusAxisId: AxisId,
44
+ ) => BaseAxisWithScale | undefined = createSelector(
45
+ [selectRadiusAxis, selectRadiusAxisScale],
46
+ (
47
+ axisSettings: RadiusAxisSettings | undefined,
48
+ scale: RechartsScale | undefined,
49
+ ): BaseAxisWithScale | undefined => {
50
+ if (axisSettings == null || scale == null) {
51
+ return undefined;
52
+ }
53
+ return {
54
+ ...axisSettings,
55
+ scale,
56
+ };
57
+ },
58
+ );
59
+
60
+ const selectRadiusAxisTicks = (
61
+ state: RechartsRootState,
62
+ radiusAxisId: AxisId,
63
+ _angleAxisId: AxisId,
64
+ isPanorama: boolean,
65
+ ): ReadonlyArray<TickItem> | undefined => {
66
+ return selectPolarAxisTicks(state, 'radiusAxis', radiusAxisId, isPanorama);
67
+ };
68
+
69
+ const selectAngleAxisForRadar = (
70
+ state: RechartsRootState,
71
+ _radiusAxisId: AxisId,
72
+ angleAxisId: AxisId,
73
+ ): AngleAxisSettings => selectAngleAxis(state, angleAxisId);
74
+
75
+ const selectPolarAxisScaleForRadar = (
76
+ state: RechartsRootState,
77
+ _radiusAxisId: AxisId,
78
+ angleAxisId: AxisId,
79
+ ): RechartsScale | undefined => selectPolarAxisScale(state, 'angleAxis', angleAxisId);
80
+
81
+ export const selectAngleAxisForBandSize: (
82
+ state: RechartsRootState,
83
+ _radiusAxisId: AxisId,
84
+ angleAxisId: AxisId,
85
+ ) => BaseAxisWithScale | undefined = createSelector(
86
+ [selectAngleAxisForRadar, selectPolarAxisScaleForRadar],
87
+ (
88
+ axisSettings: AngleAxisSettings,
89
+ scale: RechartsScale | undefined,
90
+ ): BaseAxisWithScale | undefined => {
91
+ if (axisSettings == null || scale == null) {
92
+ return undefined;
93
+ }
94
+ return {
95
+ ...axisSettings,
96
+ scale,
97
+ };
98
+ },
99
+ );
100
+
101
+ const selectAngleAxisTicks = (
102
+ state: RechartsRootState,
103
+ _radiusAxisId: AxisId,
104
+ angleAxisId: AxisId,
105
+ isPanorama: boolean,
106
+ ): ReadonlyArray<TickItem> | undefined => {
107
+ return selectPolarAxisTicks(state, 'angleAxis', angleAxisId, isPanorama);
108
+ };
109
+
110
+ export const selectAngleAxisWithScaleAndViewport: (
111
+ state: RechartsRootState,
112
+ _radiusAxisId: AxisId,
113
+ angleAxisId: AxisId,
114
+ ) => AngleAxisForRadar | undefined = createSelector(
115
+ [selectAngleAxisForRadar, selectPolarAxisScaleForRadar, selectPolarViewBox],
116
+ (
117
+ axisOptions: AngleAxisSettings,
118
+ scale: RechartsScale | undefined,
119
+ polarViewBox: PolarViewBoxRequired | undefined,
120
+ ): AngleAxisForRadar | undefined => {
121
+ if (polarViewBox == null || scale == null) {
122
+ return undefined;
123
+ }
124
+ return {
125
+ scale,
126
+ type: axisOptions.type,
127
+ dataKey: axisOptions.dataKey,
128
+ cx: polarViewBox.cx,
129
+ cy: polarViewBox.cy,
130
+ };
131
+ },
132
+ );
133
+
134
+ const pickId = (
135
+ _state: RechartsRootState,
136
+ _radiusAxisId: AxisId,
137
+ _angleAxisId: AxisId,
138
+ _isPanorama: boolean,
139
+ radarId: GraphicalItemId,
140
+ ): GraphicalItemId => radarId;
141
+
142
+ const selectBandSizeOfAxis: (
143
+ state: RechartsRootState,
144
+ radiusAxisId: AxisId,
145
+ angleAxisId: AxisId,
146
+ isPanorama: boolean,
147
+ radarId: GraphicalItemId,
148
+ ) => number | undefined = createSelector(
149
+ [
150
+ selectChartLayout,
151
+ selectRadiusAxisForBandSize,
152
+ selectRadiusAxisTicks,
153
+ selectAngleAxisForBandSize,
154
+ selectAngleAxisTicks,
155
+ ],
156
+ (
157
+ layout: LayoutType,
158
+ radiusAxis: BaseAxisWithScale | undefined,
159
+ radiusAxisTicks: ReadonlyArray<TickItem> | undefined,
160
+ angleAxis: BaseAxisWithScale | undefined,
161
+ angleAxisTicks: ReadonlyArray<TickItem> | undefined,
162
+ ) => {
163
+ if (isCategoricalAxis(layout, 'radiusAxis')) {
164
+ return getBandSizeOfAxis(radiusAxis, radiusAxisTicks, false);
165
+ }
166
+ return getBandSizeOfAxis(angleAxis, angleAxisTicks, false);
167
+ },
168
+ );
169
+
170
+ const selectSynchronisedRadarDataKey: (
171
+ state: RechartsRootState,
172
+ _radiusAxisId: AxisId,
173
+ _angleAxisId: AxisId,
174
+ _isPanorama: boolean,
175
+ radarId: GraphicalItemId,
176
+ ) => DataKey<any> | undefined = createSelector(
177
+ [selectUnfilteredPolarItems, pickId],
178
+ (graphicalItems, radarId) => {
179
+ if (graphicalItems == null) {
180
+ return undefined;
181
+ }
182
+ // Find the radar item with the given radarId
183
+ const pgis = graphicalItems.find((item) => item.type === 'radar' && radarId === item.id);
184
+ // If found, return its dataKey
185
+ return pgis?.dataKey;
186
+ },
187
+ );
188
+
189
+ export const selectRadarPoints: (
190
+ state: RechartsRootState,
191
+ radiusAxisId: AxisId,
192
+ angleAxisId: AxisId,
193
+ isPanorama: boolean,
194
+ radarId: GraphicalItemId,
195
+ ) => RadarComposedData | undefined = createSelector(
196
+ [
197
+ selectRadiusAxisForRadar,
198
+ selectAngleAxisWithScaleAndViewport,
199
+ selectChartDataAndAlwaysIgnoreIndexes,
200
+ selectSynchronisedRadarDataKey,
201
+ selectBandSizeOfAxis,
202
+ ],
203
+ (
204
+ radiusAxis: RadiusAxisForRadar | undefined,
205
+ angleAxis: AngleAxisForRadar | undefined,
206
+ { chartData, dataStartIndex, dataEndIndex }: ChartDataState,
207
+ dataKey: DataKey<any> | undefined,
208
+ bandSize: number | undefined,
209
+ ): RadarComposedData | undefined => {
210
+ if (
211
+ radiusAxis == null ||
212
+ angleAxis == null ||
213
+ chartData == null ||
214
+ bandSize == null ||
215
+ dataKey == null
216
+ ) {
217
+ return undefined;
218
+ }
219
+ const displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
220
+ return computeRadarPoints({
221
+ radiusAxis,
222
+ angleAxis,
223
+ displayedData,
224
+ dataKey,
225
+ bandSize,
226
+ });
227
+ },
228
+ );