@octanejs/recharts 0.1.62 → 0.1.64
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/cartesian/Area.tsrx
CHANGED
|
@@ -91,8 +91,9 @@ export type BaseValue = number | 'dataMin' | 'dataMax';
|
|
|
91
91
|
/**
|
|
92
92
|
* Our base value array has payload in it, and we expose it externally too.
|
|
93
93
|
*/
|
|
94
|
-
type BaseValueCoordinate<DataPointType = any> =
|
|
95
|
-
|
|
94
|
+
type BaseValueCoordinate<DataPointType = any> = NullableCoordinate & {
|
|
95
|
+
payload: DataPointType | undefined;
|
|
96
|
+
};
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
99
|
* Internal props, combination of external props + defaultProps + private Recharts state
|
|
@@ -114,8 +115,8 @@ interface InternalAreaProps extends ZIndexable {
|
|
|
114
115
|
height: number;
|
|
115
116
|
hide: boolean;
|
|
116
117
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
* ID is mandatory internally, but optional externally.
|
|
119
|
+
*/
|
|
119
120
|
id: string;
|
|
120
121
|
isAnimationActive: boolean | 'auto';
|
|
121
122
|
isRange?: boolean;
|
|
@@ -143,235 +144,237 @@ interface InternalAreaProps extends ZIndexable {
|
|
|
143
144
|
/**
|
|
144
145
|
* External props, intended for end users to fill in
|
|
145
146
|
*/
|
|
146
|
-
interface AreaProps<DataPointType = any, DataValueType = any>
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
interface AreaProps<DataPointType = any, DataValueType = any>
|
|
148
|
+
extends
|
|
149
|
+
DataProvider<DataPointType>,
|
|
150
|
+
Required<DataConsumer<DataPointType, DataValueType>>,
|
|
151
|
+
ZIndexable {
|
|
149
152
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
* The active dot is rendered on the closest data point when user interacts with the chart. Options:
|
|
154
|
+
*
|
|
155
|
+
* - `false`: dots do not change on user activity; both active and inactive dots follow the `dot` prop (see below)
|
|
156
|
+
* - `true`: renders the active dot with default settings
|
|
157
|
+
* - `object`: the props of the active dot. This will be merged with the internal calculated props of the active dot
|
|
158
|
+
* - `OctaneElement`: the custom active dot element
|
|
159
|
+
* - `function`: a render function of the custom active dot
|
|
160
|
+
*
|
|
161
|
+
* @defaultValue true
|
|
162
|
+
* @example <Area dataKey="value" activeDot={false} />
|
|
163
|
+
* @example <Area dataKey="value" activeDot={{ stroke: 'red', strokeWidth: 2, r: 10 }} />
|
|
164
|
+
* @example <Area dataKey="value" activeDot={CustomizedActiveDot} />
|
|
165
|
+
*
|
|
166
|
+
* @see {@link https://recharts.github.io/en-US/examples/SimpleLineChart/ A line chart with customized active dot}
|
|
167
|
+
*/
|
|
165
168
|
activeDot?: ActiveDotType;
|
|
166
169
|
/**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
* Specifies when the animation should begin, the unit of this option is ms.
|
|
171
|
+
* @defaultValue 0
|
|
172
|
+
*/
|
|
170
173
|
animationBegin?: number;
|
|
171
174
|
/**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
* Specifies the duration of animation, the unit of this option is ms.
|
|
176
|
+
* @defaultValue 1500
|
|
177
|
+
*/
|
|
175
178
|
animationDuration?: AnimationDuration;
|
|
176
179
|
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
* The type of easing function.
|
|
181
|
+
* @defaultValue 'ease'
|
|
182
|
+
*/
|
|
180
183
|
animationEasing?: EasingInput;
|
|
181
184
|
/**
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
* Custom animation function for interpolating data items.
|
|
186
|
+
* When provided, this replaces the default animation interpolation.
|
|
187
|
+
*
|
|
188
|
+
* @param prevItems The items from the previous animation frame, or null on first render
|
|
189
|
+
* @param nextItems The target items to animate towards
|
|
190
|
+
* @param animationElapsedTime A normalized time value (0 = start, 1 = end)
|
|
191
|
+
* @returns The interpolated items at time animationElapsedTime
|
|
192
|
+
*
|
|
193
|
+
* @since 3.9
|
|
194
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
195
|
+
*/
|
|
193
196
|
animationInterpolateFn?: AnimationInterpolateFn<AreaPointItem, CartesianLayout>;
|
|
194
197
|
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
198
|
+
* Strategy for matching previous items to next items during animation.
|
|
199
|
+
* Determines how Recharts pairs old data points with new data points
|
|
200
|
+
* to create smooth transitions.
|
|
201
|
+
*
|
|
202
|
+
* - `matchByIndex` (default): match by array position with proportional stretching
|
|
203
|
+
* - `matchAppend`: match sequentially by index and treat newly appended items as new
|
|
204
|
+
* - `matchByDataKey('someKey')`: match by a data key from the payload
|
|
205
|
+
* - Custom function `(item, index) => key`: match by the returned key
|
|
206
|
+
*
|
|
207
|
+
* @defaultValue index
|
|
208
|
+
* @see matchByIndex
|
|
209
|
+
* @see matchByDataKey
|
|
210
|
+
* @see matchAppend
|
|
211
|
+
*
|
|
212
|
+
* @since 3.9
|
|
213
|
+
* @see {@link https://recharts.github.io/en-US/guide/animations/ Animations guide}
|
|
214
|
+
*/
|
|
212
215
|
animationMatchBy?: AnimationMatchByProp<AreaPointItem>;
|
|
213
216
|
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
217
|
+
* Configures the starting value used to build the internal baseline for non-ranged, non-stacked areas.
|
|
218
|
+
*
|
|
219
|
+
* WARNING despite the name `dataMin`|`dataMax` this actually reads the domain instead, so it should rather be
|
|
220
|
+
* `domainMin`|`domainMax`. This looks like a small detail,
|
|
221
|
+
* but it's actually important because domains are usually extended automatically.
|
|
222
|
+
* For example the default numerical domain starts from 0.
|
|
223
|
+
*
|
|
224
|
+
* - `number`: uses the corresponding axis value as a flat baseline
|
|
225
|
+
* - `dataMin`: uses the minimum of the value-axis domain
|
|
226
|
+
* - `dataMax`: uses the maximum of the value-axis domain
|
|
227
|
+
*
|
|
228
|
+
* Ignored when the area is stacked or when `dataKey` already returns `[min, max]` tuples.
|
|
229
|
+
*
|
|
230
|
+
* Note that the baseValue does not interact with `animationInterpolateFn`;
|
|
231
|
+
* baseValue is always animated by linear interpolation.
|
|
232
|
+
* If you want a custom animation then have your `dataKey` return a tuple of two values instead of a single number
|
|
233
|
+
* which will also render a ranged Area, and that does work with your custom `animationInterpolateFn`.
|
|
234
|
+
*/
|
|
232
235
|
baseValue?: BaseValue;
|
|
233
236
|
className?: string;
|
|
234
237
|
/**
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
* Whether to connect the area across null points.
|
|
239
|
+
*
|
|
240
|
+
* @defaultValue false
|
|
241
|
+
* @see {@link https://recharts.github.io/en-US/examples/AreaChartConnectNulls/ AreaChart with connectNull true and false}
|
|
242
|
+
*/
|
|
240
243
|
connectNulls?: boolean;
|
|
241
244
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
* Renders a circle element at each data point. Options:
|
|
246
|
+
*
|
|
247
|
+
* - `false`: no dots are drawn;
|
|
248
|
+
* - `true`: renders the dots with default settings;
|
|
249
|
+
* - `object`: the props of the dot. This will be merged with the internal calculated props of each dot;
|
|
250
|
+
* - `OctaneElement`: the custom dot element;
|
|
251
|
+
* - `function`: a render function of the custom dot.
|
|
252
|
+
*
|
|
253
|
+
* @defaultValue false
|
|
254
|
+
*/
|
|
252
255
|
dot?: DotType;
|
|
253
256
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
* Hides the whole graphical element when true.
|
|
258
|
+
*
|
|
259
|
+
* Hiding an element is different from removing it from the chart:
|
|
260
|
+
* Hidden graphical elements are still visible in Legend,
|
|
261
|
+
* and can be included in axis domain calculations,
|
|
262
|
+
* depending on `includeHidden` props of your XAxis/YAxis.
|
|
263
|
+
*
|
|
264
|
+
* @defaultValue false
|
|
265
|
+
*/
|
|
263
266
|
hide?: boolean;
|
|
264
267
|
/**
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
* Unique identifier of this component.
|
|
269
|
+
* Used as an HTML attribute `id`, and also to identify this element internally.
|
|
270
|
+
*
|
|
271
|
+
* If undefined, Recharts will generate a unique ID automatically.
|
|
272
|
+
*/
|
|
270
273
|
id?: string;
|
|
271
274
|
/**
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
* If set false, animation of area will be disabled.
|
|
276
|
+
* If set "auto", will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
|
|
277
|
+
* @defaultValue 'auto'
|
|
278
|
+
*/
|
|
276
279
|
isAnimationActive?: boolean | 'auto';
|
|
277
280
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
281
|
+
* Renders one label for each data point. Options:
|
|
282
|
+
*
|
|
283
|
+
* - `true`: renders default labels
|
|
284
|
+
* - `false`: no labels are rendered
|
|
285
|
+
* - `object`: the props of LabelList component
|
|
286
|
+
* - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
|
|
287
|
+
* HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
|
|
288
|
+
* - `function`: a render function of custom label
|
|
289
|
+
*
|
|
290
|
+
* @defaultValue false
|
|
291
|
+
*/
|
|
289
292
|
label?: ImplicitLabelListType;
|
|
290
293
|
/**
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
* The type of icon in legend.
|
|
295
|
+
* If set to 'none', no legend item will be rendered.
|
|
296
|
+
* @defaultValue 'line'
|
|
297
|
+
*/
|
|
295
298
|
legendType?: LegendType;
|
|
296
299
|
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
* The name of data.
|
|
301
|
+
* This option will be used in tooltip and legend to represent this graphical item.
|
|
302
|
+
* If no value was set to this option, the value of dataKey will be used alternatively.
|
|
303
|
+
*/
|
|
301
304
|
name?: string | number;
|
|
302
305
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
306
|
+
* The customized event handler of animation end
|
|
307
|
+
*/
|
|
305
308
|
onAnimationEnd?: () => void;
|
|
306
309
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
* The customized event handler of animation start
|
|
311
|
+
*/
|
|
309
312
|
onAnimationStart?: () => void;
|
|
310
313
|
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
314
|
+
* If set a OctaneElement, the shape of area can be customized.
|
|
315
|
+
* If set a function, the function will be called to render customized shape.
|
|
316
|
+
* By default, renders a filled curve path with a clipPath entrance animation.
|
|
317
|
+
*
|
|
318
|
+
* During animations the shape receives additional props: `animationElapsedTime`, `isAnimating`, and `isEntrance`.
|
|
319
|
+
* When a custom shape is provided, the built-in clipPath entrance animation is skipped.
|
|
320
|
+
*
|
|
321
|
+
* @see AreaRevealShape — the default entrance animation, available for import from recharts
|
|
322
|
+
* @example <Area dataKey="value" shape={CustomizedShapeComponent} />
|
|
323
|
+
* @example <Area dataKey="value" shape={renderShapeFunction} />
|
|
324
|
+
*/
|
|
322
325
|
shape?: ActiveShape<AreaRevealShapeProps, SVGPathElement>;
|
|
323
326
|
/**
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
* When two Areas have the same axisId and same stackId, then the two Areas are stacked in the chart.
|
|
328
|
+
*/
|
|
326
329
|
stackId?: StackId;
|
|
327
330
|
/**
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
+
* The stroke color. If "none", no line will be drawn.
|
|
332
|
+
* @defaultValue '#3182bd'
|
|
333
|
+
*/
|
|
331
334
|
stroke?: string;
|
|
332
335
|
/**
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
+
* The width of the stroke
|
|
337
|
+
* @defaultValue 1
|
|
338
|
+
*/
|
|
336
339
|
strokeWidth?: string | number;
|
|
337
340
|
tooltipType?: TooltipType;
|
|
338
341
|
/**
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
* The interpolation type of curve. Allows custom interpolation function.
|
|
343
|
+
*
|
|
344
|
+
* @defaultValue linear
|
|
345
|
+
* @link https://d3js.org/d3-shape/curve
|
|
346
|
+
* @see {@link https://recharts.github.io/en-US/examples/CardinalAreaChart/ An AreaChart which has two area with different interpolation.}
|
|
347
|
+
*/
|
|
345
348
|
type?: CurveType;
|
|
346
349
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
350
|
+
* The unit of data. This option will be used in tooltip.
|
|
351
|
+
*/
|
|
349
352
|
unit?: string | number;
|
|
350
353
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
* Formats the value displayed in the tooltip for this Area.
|
|
355
|
+
* When set, takes precedence over the `formatter` prop on the Tooltip component.
|
|
356
|
+
*/
|
|
354
357
|
formatter?: Formatter;
|
|
355
358
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
+
* The id of XAxis which is corresponding to the data. Required when there are multiple XAxes.
|
|
360
|
+
* @defaultValue 0
|
|
361
|
+
*/
|
|
359
362
|
xAxisId?: AxisId;
|
|
360
363
|
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
+
* The id of YAxis which is corresponding to the data. Required when there are multiple YAxes.
|
|
365
|
+
* @defaultValue 0
|
|
366
|
+
*/
|
|
364
367
|
yAxisId?: AxisId;
|
|
365
368
|
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
369
|
+
* Z-Index of this component and its children. The higher the value,
|
|
370
|
+
* the more on top it will be rendered.
|
|
371
|
+
* Components with higher zIndex will appear in front of components with lower zIndex.
|
|
372
|
+
* If undefined or 0, the content is rendered in the default layer without portals.
|
|
373
|
+
*
|
|
374
|
+
* @since 3.4
|
|
375
|
+
* @defaultValue 100
|
|
376
|
+
* @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
|
|
377
|
+
*/
|
|
375
378
|
zIndex?: number;
|
|
376
379
|
}
|
|
377
380
|
|
|
@@ -398,10 +401,10 @@ const defaultAreaAnimateItems: AnimationInterpolateFn<AreaPointItem, CartesianLa
|
|
|
398
401
|
}
|
|
399
402
|
if (item.status === 'added') {
|
|
400
403
|
/*
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
404
|
+
* Here we just return the final position without interpolating
|
|
405
|
+
* so that we can allow the default initial animation that is done by clipPath in AreaRevealShape.
|
|
406
|
+
* If you want your own custom animations then you may want to interpolate this one as well.
|
|
407
|
+
*/
|
|
405
408
|
return [item.next];
|
|
406
409
|
}
|
|
407
410
|
// removed: drop
|
|
@@ -436,21 +439,19 @@ export const defaultAreaProps = {
|
|
|
436
439
|
/**
|
|
437
440
|
* Because of naming conflict, we are forced to ignore certain (valid) SVG attributes.
|
|
438
441
|
*/
|
|
439
|
-
type AreaSvgProps =
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
>;
|
|
442
|
+
type AreaSvgProps = Omit<
|
|
443
|
+
CurveProps,
|
|
444
|
+
'points' | 'ref' | 'layout' | 'path' | 'pathRef' | 'baseLine' | 'dangerouslySetInnerHTML'
|
|
445
|
+
>;
|
|
444
446
|
|
|
445
447
|
type InternalProps = AreaSvgProps & InternalAreaProps;
|
|
446
448
|
|
|
447
|
-
export type Props<DataPointType, ValueAxisType> =
|
|
448
|
-
|
|
449
|
+
export type Props<DataPointType, ValueAxisType> = AreaSvgProps &
|
|
450
|
+
AreaProps<DataPointType, ValueAxisType>;
|
|
449
451
|
|
|
450
|
-
type PropsWithDefaults<DataPointType, ValueAxisType> =
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
>;
|
|
452
|
+
type PropsWithDefaults<DataPointType, ValueAxisType> = WithIdRequired<
|
|
453
|
+
RequiresDefaultProps<Props<DataPointType, ValueAxisType>, typeof defaultAreaProps>
|
|
454
|
+
>;
|
|
454
455
|
|
|
455
456
|
function getLegendItemColor(
|
|
456
457
|
stroke: string | undefined,
|
|
@@ -538,16 +539,18 @@ function AreaDotsWrapper({
|
|
|
538
539
|
const { needClip, dot, dataKey } = props;
|
|
539
540
|
const areaProps: DotsDotProps = svgPropertiesNoEvents(props);
|
|
540
541
|
|
|
541
|
-
return
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
542
|
+
return (
|
|
543
|
+
<Dots
|
|
544
|
+
points={points}
|
|
545
|
+
dot={dot}
|
|
546
|
+
className="recharts-area-dots"
|
|
547
|
+
dotClassName="recharts-area-dot"
|
|
548
|
+
dataKey={dataKey}
|
|
549
|
+
baseProps={areaProps}
|
|
550
|
+
needClip={needClip}
|
|
551
|
+
clipPathId={clipPathId}
|
|
552
|
+
/>
|
|
553
|
+
);
|
|
551
554
|
}
|
|
552
555
|
|
|
553
556
|
function AreaLabelListProvider({
|
|
@@ -559,30 +562,32 @@ function AreaLabelListProvider({
|
|
|
559
562
|
children: OctaneNode;
|
|
560
563
|
points: ReadonlyArray<AreaPointItem>;
|
|
561
564
|
}) {
|
|
562
|
-
const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
|
|
563
|
-
point
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
565
|
+
const labelListEntries: ReadonlyArray<CartesianLabelListEntry> = points.map(
|
|
566
|
+
(point): CartesianLabelListEntry => {
|
|
567
|
+
const viewBox: TrapezoidViewBox = {
|
|
568
|
+
x: point.x ?? 0,
|
|
569
|
+
y: point.y ?? 0,
|
|
570
|
+
width: 0,
|
|
571
|
+
lowerWidth: 0,
|
|
572
|
+
upperWidth: 0,
|
|
573
|
+
height: 0,
|
|
574
|
+
};
|
|
575
|
+
return {
|
|
576
|
+
...viewBox,
|
|
577
|
+
value: point.value,
|
|
578
|
+
payload: point.payload,
|
|
579
|
+
parentViewBox: undefined,
|
|
580
|
+
viewBox,
|
|
581
|
+
fill: undefined,
|
|
582
|
+
};
|
|
583
|
+
},
|
|
584
|
+
);
|
|
582
585
|
|
|
583
|
-
return
|
|
584
|
-
value={showLabels ? labelListEntries : undefined}
|
|
585
|
-
|
|
586
|
+
return (
|
|
587
|
+
<CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
|
|
588
|
+
{children}
|
|
589
|
+
</CartesianLabelListContextProvider>
|
|
590
|
+
);
|
|
586
591
|
}
|
|
587
592
|
|
|
588
593
|
function StaticArea({
|
|
@@ -624,13 +629,16 @@ function StaticArea({
|
|
|
624
629
|
isEntrance,
|
|
625
630
|
};
|
|
626
631
|
|
|
627
|
-
return
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
<
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
632
|
+
return (
|
|
633
|
+
<>
|
|
634
|
+
{points?.length > 1 && (
|
|
635
|
+
<Layer clipPath={needClip ? `url(#clipPath-${clipPathId})` : undefined}>
|
|
636
|
+
<Shape option={shape} DefaultShape={defaultAreaProps.shape} shapeProps={curveProps} />
|
|
637
|
+
</Layer>
|
|
638
|
+
)}
|
|
639
|
+
<AreaDotsWrapper points={points} props={propsWithoutId} clipPathId={clipPathId} />
|
|
640
|
+
</>
|
|
641
|
+
);
|
|
634
642
|
}
|
|
635
643
|
|
|
636
644
|
function interpolateScalarBaseLine(
|
|
@@ -696,49 +704,57 @@ function AreaWithAnimation({
|
|
|
696
704
|
baseLineAnimationItems = null;
|
|
697
705
|
}
|
|
698
706
|
|
|
699
|
-
return
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
707
|
+
return (
|
|
708
|
+
<AnimatedItems
|
|
709
|
+
animationInput={animationInput}
|
|
710
|
+
animationIdPrefix="recharts-area-"
|
|
711
|
+
items={points}
|
|
712
|
+
previousItemsRef={previousPointsRef}
|
|
713
|
+
isAnimationActive={isAnimationActive}
|
|
714
|
+
animationBegin={animationBegin}
|
|
715
|
+
animationDuration={animationDuration}
|
|
716
|
+
animationEasing={animationEasing}
|
|
717
|
+
onAnimationStart={handleAnimationStart}
|
|
718
|
+
onAnimationEnd={handleAnimationEnd}
|
|
719
|
+
animationInterpolateFn={animationInterpolateFn}
|
|
720
|
+
animationMatchBy={animationMatchBy}
|
|
721
|
+
layout={layout}
|
|
722
|
+
>
|
|
723
|
+
{(stepPoints, animationElapsedTime, isEntrance) => {
|
|
724
|
+
let stepBaseLine: number | ReadonlyArray<NullableCoordinate> | undefined;
|
|
725
|
+
if (animationElapsedTime === 1) {
|
|
726
|
+
stepBaseLine = baseLine;
|
|
727
|
+
} else if (Array.isArray(baseLine)) {
|
|
728
|
+
stepBaseLine = animationInterpolateFn(
|
|
729
|
+
baseLineAnimationItems,
|
|
730
|
+
animationElapsedTime,
|
|
731
|
+
layout,
|
|
732
|
+
);
|
|
733
|
+
} else {
|
|
734
|
+
stepBaseLine = isEntrance
|
|
735
|
+
? baseLine
|
|
736
|
+
: interpolateScalarBaseLine(baseLine, prevBaseLine, animationElapsedTime);
|
|
737
|
+
}
|
|
738
|
+
baseLineAnimationState.syncStepValue(stepBaseLine, animationElapsedTime);
|
|
739
|
+
return (
|
|
740
|
+
<AreaLabelListProvider showLabels={!isAnimating} points={points}>
|
|
741
|
+
{props.children}
|
|
742
|
+
<StaticArea
|
|
743
|
+
points={stepPoints}
|
|
744
|
+
baseLine={stepBaseLine}
|
|
745
|
+
needClip={needClip}
|
|
746
|
+
clipPathId={clipPathId}
|
|
747
|
+
props={props}
|
|
748
|
+
animationElapsedTime={animationElapsedTime}
|
|
749
|
+
isAnimating={isAnimating || animationElapsedTime < 1}
|
|
750
|
+
isEntrance={isEntrance}
|
|
751
|
+
/>
|
|
752
|
+
<LabelListFromLabelProp label={props.label} />
|
|
753
|
+
</AreaLabelListProvider>
|
|
754
|
+
);
|
|
755
|
+
}}
|
|
756
|
+
</AnimatedItems>
|
|
757
|
+
);
|
|
742
758
|
}
|
|
743
759
|
|
|
744
760
|
/*
|
|
@@ -755,23 +771,25 @@ function RenderArea({
|
|
|
755
771
|
props: InternalProps;
|
|
756
772
|
}) {
|
|
757
773
|
/*
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
774
|
+
* These two must be refs, not state!
|
|
775
|
+
* Because we want to store the most recent shape of the animation in case we have to interrupt the animation;
|
|
776
|
+
* that happens when user initiates another animation before the current one finishes.
|
|
777
|
+
*
|
|
778
|
+
* If this was a useState, then every step in the animation would trigger a re-render.
|
|
779
|
+
* So, useRef it is.
|
|
780
|
+
*/
|
|
765
781
|
const previousPointsRef = useRef<ReadonlyArray<AreaPointItem> | null>(null);
|
|
766
782
|
const previousBaselineRef = useRef<BaseLineType | undefined>(undefined);
|
|
767
783
|
|
|
768
|
-
return
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
784
|
+
return (
|
|
785
|
+
<AreaWithAnimation
|
|
786
|
+
needClip={needClip}
|
|
787
|
+
clipPathId={clipPathId}
|
|
788
|
+
props={props}
|
|
789
|
+
previousPointsRef={previousPointsRef}
|
|
790
|
+
previousBaselineRef={previousBaselineRef}
|
|
791
|
+
/>
|
|
792
|
+
);
|
|
775
793
|
}
|
|
776
794
|
|
|
777
795
|
function AreaWithState(props: InternalProps) {
|
|
@@ -805,39 +823,44 @@ function AreaWithState(props: InternalProps) {
|
|
|
805
823
|
? `url(#clipPath-${clipDot ? '' : 'dots-'}${clipPathId})`
|
|
806
824
|
: undefined;
|
|
807
825
|
|
|
808
|
-
return
|
|
809
|
-
<
|
|
810
|
-
{
|
|
811
|
-
|
|
812
|
-
<
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
<
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
itemDataKey={props.dataKey}
|
|
829
|
-
activeDot={props.activeDot}
|
|
830
|
-
clipPath={activePointsClipPath}
|
|
831
|
-
/>
|
|
832
|
-
{props.isRange && Array.isArray(baseLine) &&
|
|
826
|
+
return (
|
|
827
|
+
<ZIndexLayer zIndex={zIndex}>
|
|
828
|
+
<Layer className={layerClass}>
|
|
829
|
+
{needClip && (
|
|
830
|
+
<defs>
|
|
831
|
+
<GraphicalItemClipPath clipPathId={clipPathId} xAxisId={xAxisId} yAxisId={yAxisId} />
|
|
832
|
+
{!clipDot && (
|
|
833
|
+
<clipPath id={`clipPath-dots-${clipPathId}`}>
|
|
834
|
+
<rect
|
|
835
|
+
x={left - dotSize / 2}
|
|
836
|
+
y={top - dotSize / 2}
|
|
837
|
+
width={width + dotSize}
|
|
838
|
+
height={height + dotSize}
|
|
839
|
+
/>
|
|
840
|
+
</clipPath>
|
|
841
|
+
)}
|
|
842
|
+
</defs>
|
|
843
|
+
)}
|
|
844
|
+
<RenderArea needClip={needClip} clipPathId={clipPathId} props={props} />
|
|
845
|
+
</Layer>
|
|
833
846
|
<ActivePoints
|
|
834
|
-
points={
|
|
847
|
+
points={points}
|
|
835
848
|
mainColor={getLegendItemColor(props.stroke, props.fill)}
|
|
836
849
|
itemDataKey={props.dataKey}
|
|
837
850
|
activeDot={props.activeDot}
|
|
838
851
|
clipPath={activePointsClipPath}
|
|
839
|
-
/>
|
|
840
|
-
|
|
852
|
+
/>
|
|
853
|
+
{props.isRange && Array.isArray(baseLine) && (
|
|
854
|
+
<ActivePoints
|
|
855
|
+
points={baseLine}
|
|
856
|
+
mainColor={getLegendItemColor(props.stroke, props.fill)}
|
|
857
|
+
itemDataKey={props.dataKey}
|
|
858
|
+
activeDot={props.activeDot}
|
|
859
|
+
clipPath={activePointsClipPath}
|
|
860
|
+
/>
|
|
861
|
+
)}
|
|
862
|
+
</ZIndexLayer>
|
|
863
|
+
);
|
|
841
864
|
}
|
|
842
865
|
|
|
843
866
|
function AreaImpl<DataPointType, ValueAxisType>(
|
|
@@ -869,7 +892,7 @@ function AreaImpl<DataPointType, ValueAxisType>(
|
|
|
869
892
|
useAppSelector((state) => selectArea(state, props.id, isPanorama)) ?? {};
|
|
870
893
|
const plotArea = usePlotArea();
|
|
871
894
|
|
|
872
|
-
if (layout !== 'horizontal' && layout !== 'vertical' || plotArea == null) {
|
|
895
|
+
if ((layout !== 'horizontal' && layout !== 'vertical') || plotArea == null) {
|
|
873
896
|
// Can't render Area in an unsupported layout
|
|
874
897
|
return null;
|
|
875
898
|
}
|
|
@@ -885,32 +908,34 @@ function AreaImpl<DataPointType, ValueAxisType>(
|
|
|
885
908
|
return null;
|
|
886
909
|
}
|
|
887
910
|
|
|
888
|
-
return
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
911
|
+
return (
|
|
912
|
+
<AreaWithState
|
|
913
|
+
{...everythingElse}
|
|
914
|
+
activeDot={activeDot}
|
|
915
|
+
animationBegin={animationBegin}
|
|
916
|
+
animationDuration={animationDuration}
|
|
917
|
+
animationEasing={animationEasing}
|
|
918
|
+
baseLine={baseLine}
|
|
919
|
+
connectNulls={connectNulls}
|
|
920
|
+
dot={dot}
|
|
921
|
+
fill={fill}
|
|
922
|
+
fillOpacity={fillOpacity}
|
|
923
|
+
height={height}
|
|
924
|
+
hide={hide}
|
|
925
|
+
layout={layout}
|
|
926
|
+
isAnimationActive={isAnimationActive}
|
|
927
|
+
isRange={isRange}
|
|
928
|
+
legendType={legendType}
|
|
929
|
+
needClip={needClip}
|
|
930
|
+
points={points}
|
|
931
|
+
stroke={stroke}
|
|
932
|
+
width={width}
|
|
933
|
+
left={left}
|
|
934
|
+
top={top}
|
|
935
|
+
xAxisId={xAxisId}
|
|
936
|
+
yAxisId={yAxisId}
|
|
937
|
+
/>
|
|
938
|
+
);
|
|
914
939
|
}
|
|
915
940
|
|
|
916
941
|
export const getBaseValue = (
|
|
@@ -928,8 +953,7 @@ export const getBaseValue = (
|
|
|
928
953
|
return baseValue;
|
|
929
954
|
}
|
|
930
955
|
|
|
931
|
-
const numericAxis =
|
|
932
|
-
layout === 'horizontal' ? yAxis : xAxis;
|
|
956
|
+
const numericAxis = layout === 'horizontal' ? yAxis : xAxis;
|
|
933
957
|
const domain = numericAxis.scale.domain() as readonly [number, number];
|
|
934
958
|
|
|
935
959
|
if (numericAxis.type === 'number') {
|
|
@@ -1005,19 +1029,19 @@ export function computeArea({
|
|
|
1005
1029
|
const value1 = valueAsArray?.[1] ?? null;
|
|
1006
1030
|
|
|
1007
1031
|
const isBreakPoint =
|
|
1008
|
-
value1 == null || hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null;
|
|
1032
|
+
value1 == null || (hasStack && !connectNulls && getValueByDataKey(entry, dataKey) == null);
|
|
1009
1033
|
|
|
1010
1034
|
if (isHorizontalLayout) {
|
|
1011
1035
|
return {
|
|
1012
1036
|
x: getCateCoordinateOfLine({ axis: xAxis, ticks: xAxisTicks, bandSize, entry, index }),
|
|
1013
|
-
y: isBreakPoint ? null : yAxis.scale.map(value1) ?? null,
|
|
1037
|
+
y: isBreakPoint ? null : (yAxis.scale.map(value1) ?? null),
|
|
1014
1038
|
value: valueAsArray,
|
|
1015
1039
|
payload: entry,
|
|
1016
1040
|
};
|
|
1017
1041
|
}
|
|
1018
1042
|
|
|
1019
1043
|
return {
|
|
1020
|
-
x: isBreakPoint ? null : xAxis.scale.map(value1) ?? null,
|
|
1044
|
+
x: isBreakPoint ? null : (xAxis.scale.map(value1) ?? null),
|
|
1021
1045
|
y: getCateCoordinateOfLine({ axis: yAxis, ticks: yAxisTicks, bandSize, entry, index }),
|
|
1022
1046
|
value: valueAsArray,
|
|
1023
1047
|
payload: entry,
|
|
@@ -1031,12 +1055,12 @@ export function computeArea({
|
|
|
1031
1055
|
if (isHorizontalLayout) {
|
|
1032
1056
|
return {
|
|
1033
1057
|
x: entry.x,
|
|
1034
|
-
y: x != null && entry.y != null ? yAxis.scale.map(x) ?? null : null,
|
|
1058
|
+
y: x != null && entry.y != null ? (yAxis.scale.map(x) ?? null) : null,
|
|
1035
1059
|
payload: entry.payload,
|
|
1036
1060
|
};
|
|
1037
1061
|
}
|
|
1038
1062
|
return {
|
|
1039
|
-
x: x != null ? xAxis.scale.map(x) ?? null : null,
|
|
1063
|
+
x: x != null ? (xAxis.scale.map(x) ?? null) : null,
|
|
1040
1064
|
y: entry.y,
|
|
1041
1065
|
payload: entry.payload,
|
|
1042
1066
|
};
|
|
@@ -1058,40 +1082,44 @@ function AreaFn<DataPointType = any, ValueAxisType = any>(
|
|
|
1058
1082
|
const props = resolveDefaultProps(outsideProps, defaultAreaProps);
|
|
1059
1083
|
const isPanorama = useIsPanorama();
|
|
1060
1084
|
// Report all props to Redux store first, before calling hooks, to avoid circular dependencies.
|
|
1061
|
-
return
|
|
1062
|
-
{
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1085
|
+
return (
|
|
1086
|
+
<RegisterGraphicalItemId id={props.id} type="area">
|
|
1087
|
+
{(id) => (
|
|
1088
|
+
<>
|
|
1089
|
+
<SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
|
|
1090
|
+
<SetAreaTooltipEntrySettings
|
|
1091
|
+
dataKey={props.dataKey}
|
|
1092
|
+
data={props.data}
|
|
1093
|
+
stroke={props.stroke}
|
|
1094
|
+
strokeWidth={props.strokeWidth}
|
|
1095
|
+
fill={props.fill}
|
|
1096
|
+
name={props.name}
|
|
1097
|
+
hide={props.hide}
|
|
1098
|
+
unit={props.unit}
|
|
1099
|
+
formatter={props.formatter}
|
|
1100
|
+
tooltipType={props.tooltipType}
|
|
1101
|
+
id={id}
|
|
1102
|
+
/>
|
|
1103
|
+
<SetCartesianGraphicalItem
|
|
1104
|
+
type="area"
|
|
1105
|
+
id={id}
|
|
1106
|
+
data={props.data}
|
|
1107
|
+
dataKey={props.dataKey}
|
|
1108
|
+
xAxisId={props.xAxisId}
|
|
1109
|
+
yAxisId={props.yAxisId}
|
|
1110
|
+
zAxisId={0}
|
|
1111
|
+
stackId={getNormalizedStackId(props.stackId)}
|
|
1112
|
+
hide={props.hide}
|
|
1113
|
+
barSize={undefined}
|
|
1114
|
+
baseValue={props.baseValue}
|
|
1115
|
+
isPanorama={isPanorama}
|
|
1116
|
+
connectNulls={props.connectNulls}
|
|
1117
|
+
/>
|
|
1118
|
+
<AreaImpl {...props} id={id} />
|
|
1119
|
+
</>
|
|
1120
|
+
)}
|
|
1121
|
+
</RegisterGraphicalItemId>
|
|
1122
|
+
);
|
|
1095
1123
|
}
|
|
1096
1124
|
|
|
1097
1125
|
/**
|