@octanejs/recharts 0.1.62 → 0.1.63
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.
- package/package.json +5 -5
- package/src/animation/AnimatedItems.tsrx +36 -31
- package/src/animation/CSSTransitionAnimate.tsrx +1 -2
- package/src/animation/JavascriptAnimate.tsrx +1 -2
- package/src/cartesian/Area.tsrx +414 -386
- package/src/cartesian/AreaRevealShape.tsrx +103 -84
- package/src/cartesian/Bar.tsrx +343 -317
- package/src/cartesian/BarStack.tsrx +33 -28
- package/src/cartesian/CartesianAxis.tsrx +168 -165
- package/src/cartesian/CartesianGrid.tsrx +256 -272
- package/src/cartesian/ErrorBar.tsrx +108 -104
- package/src/cartesian/Funnel.tsrx +405 -382
- package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
- package/src/cartesian/Line.tsrx +190 -177
- package/src/cartesian/LineDrawShape.tsrx +14 -15
- package/src/cartesian/ReferenceLine.tsrx +119 -105
- package/src/cartesian/Scatter.tsrx +416 -398
- package/src/cartesian/XAxis.tsrx +39 -32
- package/src/cartesian/YAxis.tsrx +47 -37
- package/src/cartesian/ZAxis.tsrx +76 -73
- package/src/chart/AreaChart.tsrx +15 -11
- package/src/chart/BarChart.tsrx +15 -11
- package/src/chart/CategoricalChart.tsrx +32 -26
- package/src/chart/ComposedChart.tsrx +15 -11
- package/src/chart/FunnelChart.tsrx +15 -11
- package/src/chart/LineChart.tsrx +15 -11
- package/src/chart/PieChart.tsrx +15 -11
- package/src/chart/PolarChart.tsrx +45 -48
- package/src/chart/RadarChart.tsrx +38 -32
- package/src/chart/RadialBarChart.tsrx +15 -11
- package/src/chart/RechartsWrapper.tsrx +214 -162
- package/src/chart/Sankey.tsrx +412 -378
- package/src/chart/ScatterChart.tsrx +15 -11
- package/src/chart/SunburstChart.tsrx +162 -155
- package/src/component/ActivePoints.tsrx +19 -13
- package/src/component/Cursor.tsrx +25 -18
- package/src/component/DefaultLegendContent.tsrx +131 -127
- package/src/component/DefaultTooltipContent.tsrx +46 -42
- package/src/component/Dots.tsrx +11 -5
- package/src/component/Label.tsrx +69 -55
- package/src/component/LabelList.tsrx +32 -27
- package/src/component/Legend.tsrx +120 -123
- package/src/component/ResponsiveContainer.tsrx +18 -11
- package/src/component/Text.tsrx +50 -43
- package/src/component/Tooltip.tsrx +234 -223
- package/src/component/TooltipBoundingBox.tsrx +34 -34
- package/src/container/ClipPathProvider.tsrx +1 -3
- package/src/container/Layer.tsrx +5 -1
- package/src/container/RootSurface.tsrx +31 -21
- package/src/container/Surface.tsrx +15 -13
- package/src/context/ErrorBarContext.tsrx +5 -5
- package/src/polar/Pie.tsrx +541 -487
- package/src/polar/PolarAngleAxis.tsrx +245 -227
- package/src/polar/PolarGrid.tsrx +139 -127
- package/src/polar/PolarRadiusAxis.tsrx +204 -185
- package/src/polar/Radar.tsrx +274 -264
- package/src/polar/RadialBar.tsrx +408 -361
- package/src/shape/Cross.tsrx +13 -7
- package/src/shape/Curve.tsrx +54 -44
- package/src/shape/Dot.tsrx +10 -8
- package/src/shape/Polygon.tsrx +38 -29
- package/src/shape/Rectangle.tsrx +73 -28
- package/src/shape/Sector.tsrx +30 -18
- package/src/shape/Symbols.tsrx +13 -11
- package/src/shape/Trapezoid.tsrx +16 -11
- package/src/state/RechartsStoreProvider.tsrx +5 -1
- package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
- package/src/util/BarUtils.tsrx +43 -40
- package/src/util/FunnelUtils.tsrx +5 -5
- package/src/util/RadialBarUtils.tsrx +3 -4
- package/src/util/ScatterUtils.tsrx +13 -8
- package/src/zIndex/ZIndexLayer.tsrx +2 -2
- package/src/zIndex/ZIndexPortal.tsrx +2 -8
package/src/polar/Radar.tsrx
CHANGED
|
@@ -72,128 +72,126 @@ export interface RadarPoint {
|
|
|
72
72
|
name?: string | number;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
interface RadarProps<DataPointType = any, DataValueType = any>
|
|
76
|
-
DataPointType,
|
|
77
|
-
DataValueType
|
|
78
|
-
> {
|
|
75
|
+
interface RadarProps<DataPointType = any, DataValueType = any>
|
|
76
|
+
extends ZIndexable, DataConsumer<DataPointType, DataValueType> {
|
|
79
77
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
* @defaultValue true
|
|
79
|
+
*/
|
|
82
80
|
activeDot?: ActiveDotType;
|
|
83
81
|
/**
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
* @defaultValue 0
|
|
83
|
+
*/
|
|
86
84
|
angleAxisId?: string | number;
|
|
87
85
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
* Specifies when the animation should begin, the unit of this option is ms.
|
|
87
|
+
* @defaultValue 0
|
|
88
|
+
*/
|
|
91
89
|
animationBegin?: number;
|
|
92
90
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
* Specifies the duration of animation, the unit of this option is ms.
|
|
92
|
+
* @defaultValue 1500
|
|
93
|
+
*/
|
|
96
94
|
animationDuration?: AnimationDuration;
|
|
97
95
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
* The type of easing function.
|
|
97
|
+
* @defaultValue ease
|
|
98
|
+
*/
|
|
101
99
|
animationEasing?: EasingInput;
|
|
102
100
|
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
* Custom animation function for interpolating data items.
|
|
102
|
+
* When provided, this replaces the default animation interpolation.
|
|
103
|
+
*
|
|
104
|
+
* @param prevItems The items from the previous animation frame, or null on first render
|
|
105
|
+
* @param nextItems The target items to animate towards
|
|
106
|
+
* @param animationElapsedTime A normalized time value (0 = start, 1 = end)
|
|
107
|
+
* @returns The interpolated items at time animationElapsedTime
|
|
108
|
+
*
|
|
109
|
+
* @since 3.9
|
|
110
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
111
|
+
*/
|
|
114
112
|
animationInterpolateFn?: AnimationInterpolateFn<RadarPoint, PolarLayout>;
|
|
115
113
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
114
|
+
* Strategy for matching previous items to next items during animation.
|
|
115
|
+
* Determines how Recharts pairs old data points with new data points
|
|
116
|
+
* to create smooth transitions.
|
|
117
|
+
*
|
|
118
|
+
* - `matchByIndex` (default): match by array position with proportional stretching
|
|
119
|
+
* - `matchAppend`: match sequentially by index and treat newly appended items as new
|
|
120
|
+
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
121
|
+
* - Custom function `(item, index) => key`: match by the returned key
|
|
122
|
+
*
|
|
123
|
+
* @defaultValue index
|
|
124
|
+
* @see matchByIndex
|
|
125
|
+
* @see matchByDataKey
|
|
126
|
+
* @see matchAppend
|
|
127
|
+
*/
|
|
130
128
|
animationMatchBy?: AnimationMatchByProp<RadarPoint>;
|
|
131
129
|
baseLinePoints?: RadarPoint[];
|
|
132
130
|
className?: string;
|
|
133
131
|
connectNulls?: boolean;
|
|
134
132
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
* Renders a circle element at each data point. Options:
|
|
134
|
+
*
|
|
135
|
+
* - `false`: no dots are drawn;
|
|
136
|
+
* - `true`: renders the dots with default settings;
|
|
137
|
+
* - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
|
|
138
|
+
* - `OctaneElement`: the custom dot element;
|
|
139
|
+
* - `function`: a render function of the custom dot.
|
|
140
|
+
*
|
|
141
|
+
* @defaultValue false
|
|
142
|
+
*/
|
|
145
143
|
dot?: DotType;
|
|
146
144
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
* @defaultValue false
|
|
146
|
+
*/
|
|
149
147
|
hide?: boolean;
|
|
150
148
|
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
* If set false, animation of polygon will be disabled.
|
|
150
|
+
* If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
|
|
151
|
+
* @defaultValue auto
|
|
152
|
+
*/
|
|
155
153
|
isAnimationActive?: boolean | 'auto';
|
|
156
154
|
isRange?: boolean;
|
|
157
155
|
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
156
|
+
* Renders one label for each point. Options:
|
|
157
|
+
* - `true`: renders default labels;
|
|
158
|
+
* - `false`: no labels are rendered;
|
|
159
|
+
* - `object`: the props of LabelList component;
|
|
160
|
+
* - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
|
|
161
|
+
* HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
|
|
162
|
+
* - `function`: a render function of custom label.
|
|
163
|
+
*
|
|
164
|
+
* @defaultValue false
|
|
165
|
+
*/
|
|
168
166
|
label?: ImplicitLabelListType;
|
|
169
167
|
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
* The type of icon in legend. If set to 'none', no legend item will be rendered.
|
|
169
|
+
* @defaultValue rect
|
|
170
|
+
*/
|
|
173
171
|
legendType?: LegendType;
|
|
174
172
|
/**
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
* The customized event handler of animation end
|
|
174
|
+
*/
|
|
177
175
|
onAnimationEnd?: () => void;
|
|
178
176
|
/**
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
* The customized event handler of animation start
|
|
178
|
+
*/
|
|
181
179
|
onAnimationStart?: () => void;
|
|
182
180
|
onMouseEnter?: (props: InternalRadarProps, e: NativeMouseEvent<SVGPathElement>) => void;
|
|
183
181
|
onMouseLeave?: (props: InternalRadarProps, e: NativeMouseEvent<SVGPathElement>) => void;
|
|
184
182
|
/**
|
|
185
|
-
|
|
186
|
-
|
|
183
|
+
* @defaultValue 0
|
|
184
|
+
*/
|
|
187
185
|
radiusAxisId?: string | number;
|
|
188
186
|
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
* If set a OctaneElement, the shape of radar can be customized.
|
|
188
|
+
* If set a function, the function will be called to render customized shape.
|
|
189
|
+
*/
|
|
192
190
|
shape?: OctaneElement<SVGElement> | ((props: any) => OctaneElement<SVGElement>);
|
|
193
191
|
tooltipType?: TooltipType;
|
|
194
192
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
193
|
+
* @defaultValue 100
|
|
194
|
+
*/
|
|
197
195
|
zIndex?: number;
|
|
198
196
|
}
|
|
199
197
|
|
|
@@ -206,11 +204,11 @@ export type AngleAxisForRadar = {
|
|
|
206
204
|
cy: number;
|
|
207
205
|
};
|
|
208
206
|
|
|
209
|
-
export type Props<DataPointType = any, DataValueType = any> =
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
export type Props<DataPointType = any, DataValueType = any> = Omit<
|
|
208
|
+
SVGProps<SVGGraphicsElement>,
|
|
209
|
+
'onMouseEnter' | 'onMouseLeave' | 'points' | 'ref'
|
|
210
|
+
> &
|
|
211
|
+
RadarProps<DataPointType, DataValueType>;
|
|
214
212
|
|
|
215
213
|
export type RadarComposedData = {
|
|
216
214
|
points: RadarPoint[];
|
|
@@ -241,44 +239,46 @@ const computeLegendPayloadFromRadarSectors = (
|
|
|
241
239
|
];
|
|
242
240
|
};
|
|
243
241
|
|
|
244
|
-
const SetRadarTooltipEntrySettings = React.memo(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
242
|
+
const SetRadarTooltipEntrySettings = React.memo(
|
|
243
|
+
({
|
|
244
|
+
dataKey,
|
|
245
|
+
stroke,
|
|
246
|
+
strokeWidth,
|
|
247
|
+
fill,
|
|
248
|
+
name,
|
|
249
|
+
hide,
|
|
250
|
+
tooltipType,
|
|
251
|
+
id,
|
|
252
|
+
}: Pick<
|
|
253
|
+
WithIdRequired<PropsWithDefaults>,
|
|
254
|
+
'dataKey' | 'stroke' | 'strokeWidth' | 'fill' | 'name' | 'hide' | 'tooltipType' | 'id'
|
|
255
|
+
>) => {
|
|
256
|
+
const tooltipEntrySettings: TooltipPayloadConfiguration = {
|
|
257
|
+
/*
|
|
258
|
+
* I suppose this here _could_ return props.points
|
|
259
|
+
* because while Radar does not support item tooltip mode, it _could_ support it.
|
|
260
|
+
* But when I actually do return the points here, a defaultIndex test starts failing.
|
|
261
|
+
* So, undefined it is.
|
|
262
|
+
*/
|
|
263
|
+
dataDefinedOnItem: undefined,
|
|
264
|
+
getPosition: noop,
|
|
265
|
+
settings: {
|
|
266
|
+
stroke,
|
|
267
|
+
strokeWidth,
|
|
268
|
+
fill,
|
|
269
|
+
nameKey: undefined, // RadarChart does not have nameKey unfortunately
|
|
270
|
+
dataKey,
|
|
271
|
+
name: getTooltipNameProp(name, dataKey),
|
|
272
|
+
hide,
|
|
273
|
+
type: tooltipType,
|
|
274
|
+
color: getLegendItemColor(stroke, fill),
|
|
275
|
+
unit: '', // why doesn't Radar support unit?
|
|
276
|
+
graphicalItemId: id,
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
282
|
|
|
283
283
|
function RadarDotsWrapper({
|
|
284
284
|
points,
|
|
@@ -292,14 +292,16 @@ function RadarDotsWrapper({
|
|
|
292
292
|
|
|
293
293
|
const baseProps = svgPropertiesNoEvents(propsWithoutId);
|
|
294
294
|
|
|
295
|
-
return
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
295
|
+
return (
|
|
296
|
+
<Dots
|
|
297
|
+
points={points}
|
|
298
|
+
dot={dot}
|
|
299
|
+
className="recharts-radar-dots"
|
|
300
|
+
dotClassName="recharts-radar-dot"
|
|
301
|
+
dataKey={dataKey}
|
|
302
|
+
baseProps={baseProps}
|
|
303
|
+
/>
|
|
304
|
+
);
|
|
303
305
|
}
|
|
304
306
|
|
|
305
307
|
export function computeRadarPoints({
|
|
@@ -318,16 +320,14 @@ export function computeRadarPoints({
|
|
|
318
320
|
const { cx, cy } = angleAxis;
|
|
319
321
|
let isRange = false;
|
|
320
322
|
const points: RadarPoint[] = [];
|
|
321
|
-
const angleBandSize =
|
|
322
|
-
angleAxis.type !== 'number' ? bandSize ?? 0 : 0;
|
|
323
|
+
const angleBandSize = angleAxis.type !== 'number' ? (bandSize ?? 0) : 0;
|
|
323
324
|
|
|
324
325
|
displayedData.forEach((entry, i) => {
|
|
325
326
|
const name = getValueByDataKey(entry, angleAxis.dataKey, i);
|
|
326
327
|
const value = getValueByDataKey(entry, dataKey);
|
|
327
328
|
const angle: number = (angleAxis.scale.map(name) ?? 0) + angleBandSize;
|
|
328
|
-
const pointValue =
|
|
329
|
-
|
|
330
|
-
const radius: number = isNullish(pointValue) ? 0 : radiusAxis.scale.map(pointValue) ?? 0;
|
|
329
|
+
const pointValue = Array.isArray(value) ? last(value) : value;
|
|
330
|
+
const radius: number = isNullish(pointValue) ? 0 : (radiusAxis.scale.map(pointValue) ?? 0);
|
|
331
331
|
|
|
332
332
|
if (Array.isArray(value) && value.length >= 2) {
|
|
333
333
|
isRange = true;
|
|
@@ -352,7 +352,7 @@ export function computeRadarPoints({
|
|
|
352
352
|
points.forEach((point: RadarPoint) => {
|
|
353
353
|
if (Array.isArray(point.value)) {
|
|
354
354
|
const baseValue = point.value[0];
|
|
355
|
-
const radius: number = isNullish(baseValue) ? 0 : radiusAxis.scale.map(baseValue) ?? 0;
|
|
355
|
+
const radius: number = isNullish(baseValue) ? 0 : (radiusAxis.scale.map(baseValue) ?? 0);
|
|
356
356
|
|
|
357
357
|
baseLinePoints.push({
|
|
358
358
|
...point,
|
|
@@ -378,9 +378,9 @@ function RadarLabelListProvider({
|
|
|
378
378
|
children: OctaneNode;
|
|
379
379
|
}) {
|
|
380
380
|
/*
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
* Radar provides a Cartesian label list context. Do we want to also provide a polar label list context?
|
|
382
|
+
* That way, users can choose to use polar positions for the Radar labels.
|
|
383
|
+
*/
|
|
384
384
|
// const labelListEntries: ReadonlyArray<PolarLabelListEntry> = points.map(
|
|
385
385
|
// (point): PolarLabelListEntry => ({
|
|
386
386
|
// value: point.value,
|
|
@@ -399,30 +399,32 @@ function RadarLabelListProvider({
|
|
|
399
399
|
// }),
|
|
400
400
|
// );
|
|
401
401
|
|
|
402
|
-
const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
|
|
403
|
-
point
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
421
|
-
|
|
402
|
+
const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
|
|
403
|
+
(point): CartesianLabelListEntry => {
|
|
404
|
+
const viewBox: TrapezoidViewBox = {
|
|
405
|
+
x: point.x,
|
|
406
|
+
y: point.y,
|
|
407
|
+
width: 0,
|
|
408
|
+
lowerWidth: 0,
|
|
409
|
+
upperWidth: 0,
|
|
410
|
+
height: 0,
|
|
411
|
+
};
|
|
412
|
+
return {
|
|
413
|
+
...viewBox,
|
|
414
|
+
value: point.value ?? '',
|
|
415
|
+
payload: point.payload,
|
|
416
|
+
parentViewBox: undefined,
|
|
417
|
+
viewBox,
|
|
418
|
+
fill: undefined,
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
);
|
|
422
422
|
|
|
423
|
-
return
|
|
424
|
-
value={showLabels ? labelListEntries : undefined}
|
|
425
|
-
|
|
423
|
+
return (
|
|
424
|
+
<CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
|
|
425
|
+
{children}
|
|
426
|
+
</CartesianLabelListContextProvider>
|
|
427
|
+
);
|
|
426
428
|
}
|
|
427
429
|
|
|
428
430
|
function StaticPolygon({
|
|
@@ -462,20 +464,24 @@ function StaticPolygon({
|
|
|
462
464
|
} else if (typeof shape === 'function') {
|
|
463
465
|
radar = shape({ ...props, points });
|
|
464
466
|
} else {
|
|
465
|
-
radar =
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
467
|
+
radar = (
|
|
468
|
+
<Polygon
|
|
469
|
+
{...svgPropertiesAndEvents(props)}
|
|
470
|
+
onMouseEnter={handleMouseEnter}
|
|
471
|
+
onMouseLeave={handleMouseLeave}
|
|
472
|
+
points={points}
|
|
473
|
+
baseLinePoints={isRange ? baseLinePoints : undefined}
|
|
474
|
+
connectNulls={connectNulls}
|
|
475
|
+
/>
|
|
476
|
+
);
|
|
473
477
|
}
|
|
474
478
|
|
|
475
|
-
return
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
+
return (
|
|
480
|
+
<Layer className="recharts-radar-polygon">
|
|
481
|
+
{radar}
|
|
482
|
+
<RadarDotsWrapper props={props} points={points} />
|
|
483
|
+
</Layer>
|
|
484
|
+
);
|
|
479
485
|
}
|
|
480
486
|
|
|
481
487
|
const defaultRadarAnimateItems: AnimationInterpolateFn<RadarPoint, PolarLayout> = (
|
|
@@ -553,49 +559,51 @@ function PolygonWithAnimation({
|
|
|
553
559
|
|
|
554
560
|
if (layout == null) return null;
|
|
555
561
|
|
|
556
|
-
return
|
|
557
|
-
<
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
562
|
+
return (
|
|
563
|
+
<RadarLabelListProvider showLabels={!isAnimating} points={points}>
|
|
564
|
+
<AnimatedItems
|
|
565
|
+
animationInput={animationInput}
|
|
566
|
+
animationIdPrefix="recharts-radar-"
|
|
567
|
+
items={points}
|
|
568
|
+
previousItemsRef={previousPointsRef}
|
|
569
|
+
isAnimationActive={isAnimationActive}
|
|
570
|
+
animationBegin={animationBegin}
|
|
571
|
+
animationDuration={animationDuration}
|
|
572
|
+
animationEasing={animationEasing}
|
|
573
|
+
onAnimationStart={handleAnimationStart}
|
|
574
|
+
onAnimationEnd={handleAnimationEnd}
|
|
575
|
+
animationInterpolateFn={animationInterpolateFn}
|
|
576
|
+
animationMatchBy={animationMatchBy}
|
|
577
|
+
layout={layout}
|
|
578
|
+
>
|
|
579
|
+
{(stepData, animationElapsedTime) => {
|
|
580
|
+
const stepBaseLinePoints =
|
|
581
|
+
animationElapsedTime === 1
|
|
582
|
+
? baseLinePoints
|
|
583
|
+
: animationInterpolateFn(baseLineAnimationItems, animationElapsedTime, layout);
|
|
584
|
+
baseLineAnimationState.syncStepValue(stepBaseLinePoints, animationElapsedTime);
|
|
585
|
+
return (
|
|
586
|
+
<StaticPolygon points={stepData} baseLinePoints={stepBaseLinePoints} props={props} />
|
|
587
|
+
);
|
|
588
|
+
}}
|
|
589
|
+
</AnimatedItems>
|
|
590
|
+
<LabelListFromLabelProp label={props.label} />
|
|
591
|
+
{props.children}
|
|
592
|
+
</RadarLabelListProvider>
|
|
593
|
+
);
|
|
588
594
|
}
|
|
589
595
|
|
|
590
596
|
function RenderPolygon(props: InternalRadarProps) {
|
|
591
597
|
const previousPointsRef = useRef<ReadonlyArray<RadarPoint> | undefined>(undefined);
|
|
592
598
|
const previousBaseLinePointsRef = useRef<ReadonlyArray<RadarPoint> | undefined>(undefined);
|
|
593
599
|
|
|
594
|
-
return
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
600
|
+
return (
|
|
601
|
+
<PolygonWithAnimation
|
|
602
|
+
props={props}
|
|
603
|
+
previousPointsRef={previousPointsRef}
|
|
604
|
+
previousBaseLinePointsRef={previousBaseLinePointsRef}
|
|
605
|
+
/>
|
|
606
|
+
);
|
|
599
607
|
}
|
|
600
608
|
|
|
601
609
|
export const defaultRadarProps = {
|
|
@@ -628,41 +636,39 @@ function RadarWithState(props: InternalRadarProps) {
|
|
|
628
636
|
|
|
629
637
|
const layerClass = clsx('recharts-radar', className);
|
|
630
638
|
|
|
631
|
-
return
|
|
632
|
-
<
|
|
633
|
-
<
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
return (
|
|
640
|
+
<ZIndexLayer zIndex={props.zIndex}>
|
|
641
|
+
<Layer className={layerClass}>
|
|
642
|
+
<RenderPolygon {...props} />
|
|
643
|
+
</Layer>
|
|
644
|
+
<ActivePoints
|
|
645
|
+
points={points}
|
|
646
|
+
mainColor={getLegendItemColor(props.stroke, props.fill)}
|
|
647
|
+
itemDataKey={props.dataKey}
|
|
648
|
+
activeDot={props.activeDot}
|
|
649
|
+
/>
|
|
650
|
+
</ZIndexLayer>
|
|
651
|
+
);
|
|
642
652
|
}
|
|
643
653
|
|
|
644
654
|
function RadarImpl(props: WithIdRequired<PropsWithDefaults>) {
|
|
645
655
|
const isPanorama = useIsPanorama();
|
|
646
|
-
const radarPoints = useAppSelector(
|
|
647
|
-
(state
|
|
648
|
-
state,
|
|
649
|
-
props.radiusAxisId,
|
|
650
|
-
props.angleAxisId,
|
|
651
|
-
isPanorama,
|
|
652
|
-
props.id,
|
|
653
|
-
),
|
|
656
|
+
const radarPoints = useAppSelector((state) =>
|
|
657
|
+
selectRadarPoints(state, props.radiusAxisId, props.angleAxisId, isPanorama, props.id),
|
|
654
658
|
);
|
|
655
659
|
|
|
656
660
|
if (radarPoints?.points == null) {
|
|
657
661
|
return null;
|
|
658
662
|
}
|
|
659
663
|
|
|
660
|
-
return
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
return (
|
|
665
|
+
<RadarWithState
|
|
666
|
+
{...props}
|
|
667
|
+
points={radarPoints?.points}
|
|
668
|
+
baseLinePoints={radarPoints?.baseLinePoints}
|
|
669
|
+
isRange={radarPoints?.isRange}
|
|
670
|
+
/>
|
|
671
|
+
);
|
|
666
672
|
}
|
|
667
673
|
|
|
668
674
|
/**
|
|
@@ -673,31 +679,35 @@ export function Radar<DataPointType = any, DataValueType = any>(
|
|
|
673
679
|
outsideProps: Props<DataPointType, DataValueType>,
|
|
674
680
|
) {
|
|
675
681
|
const props: PropsWithDefaults = resolveDefaultProps(outsideProps, defaultRadarProps);
|
|
676
|
-
return
|
|
677
|
-
{
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
682
|
+
return (
|
|
683
|
+
<RegisterGraphicalItemId id={props.id} type="radar">
|
|
684
|
+
{(id) => (
|
|
685
|
+
<>
|
|
686
|
+
<SetPolarGraphicalItem
|
|
687
|
+
type="radar"
|
|
688
|
+
id={id}
|
|
689
|
+
data={undefined}
|
|
690
|
+
dataKey={props.dataKey}
|
|
691
|
+
hide={props.hide}
|
|
692
|
+
angleAxisId={props.angleAxisId}
|
|
693
|
+
radiusAxisId={props.radiusAxisId}
|
|
694
|
+
/>
|
|
695
|
+
<SetPolarLegendPayload legendPayload={computeLegendPayloadFromRadarSectors(props)} />
|
|
696
|
+
<SetRadarTooltipEntrySettings
|
|
697
|
+
dataKey={props.dataKey}
|
|
698
|
+
stroke={props.stroke}
|
|
699
|
+
strokeWidth={props.strokeWidth}
|
|
700
|
+
fill={props.fill}
|
|
701
|
+
name={props.name}
|
|
702
|
+
hide={props.hide}
|
|
703
|
+
tooltipType={props.tooltipType}
|
|
704
|
+
id={id}
|
|
705
|
+
/>
|
|
706
|
+
<RadarImpl {...props} id={id} />
|
|
707
|
+
</>
|
|
708
|
+
)}
|
|
709
|
+
</RegisterGraphicalItemId>
|
|
710
|
+
);
|
|
701
711
|
}
|
|
702
712
|
|
|
703
713
|
Radar.displayName = 'Radar';
|