@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
|
@@ -49,100 +49,106 @@ import {
|
|
|
49
49
|
*
|
|
50
50
|
* @inline
|
|
51
51
|
*/
|
|
52
|
-
export type ReferenceLineSegment =
|
|
53
|
-
|
|
52
|
+
export type ReferenceLineSegment = readonly [
|
|
53
|
+
{
|
|
54
54
|
x?: number | string;
|
|
55
55
|
y?: number | string;
|
|
56
|
-
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
57
58
|
x?: number | string;
|
|
58
59
|
y?: number | string;
|
|
59
|
-
}
|
|
60
|
+
},
|
|
61
|
+
];
|
|
60
62
|
|
|
61
63
|
type ReferenceCoordinateValue = number | string;
|
|
62
64
|
|
|
63
65
|
interface ReferenceLineProps<
|
|
64
66
|
XValueType extends ReferenceCoordinateValue = any,
|
|
65
67
|
YValueType extends ReferenceCoordinateValue = any,
|
|
66
|
-
>
|
|
68
|
+
>
|
|
69
|
+
extends Overflowable, ZIndexable {
|
|
67
70
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
* If defined, renders a horizontal line on this position.
|
|
72
|
+
*
|
|
73
|
+
* This value is using your chart's domain, so you will provide a data value instead of a pixel value.
|
|
74
|
+
* ReferenceLine will internally calculate the correct pixel position.
|
|
75
|
+
*
|
|
76
|
+
* @example <ReferenceLine y="Page D" />
|
|
77
|
+
*/
|
|
75
78
|
y?: YValueType;
|
|
76
79
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
* If defined, renders a vertical line on this position.
|
|
81
|
+
*
|
|
82
|
+
* This value is using your chart's domain, so you will provide a data value instead of a pixel value.
|
|
83
|
+
* ReferenceLine will internally calculate the correct pixel position.
|
|
84
|
+
*
|
|
85
|
+
* @example <ReferenceLine x="Monday" />
|
|
86
|
+
*/
|
|
84
87
|
x?: XValueType;
|
|
85
88
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
segment?: readonly [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
* Tuple of coordinates. If defined, renders a diagonal line segment.
|
|
90
|
+
*/
|
|
91
|
+
segment?: readonly [
|
|
92
|
+
{
|
|
93
|
+
x?: XValueType;
|
|
94
|
+
y?: YValueType;
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
x?: XValueType;
|
|
98
|
+
y?: YValueType;
|
|
99
|
+
},
|
|
100
|
+
];
|
|
95
101
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
* The position of the reference line when the axis has bandwidth
|
|
103
|
+
* (e.g., a band scale). This determines where within the band
|
|
104
|
+
* the line is drawn.
|
|
105
|
+
* @defaultValue 'middle'
|
|
106
|
+
*/
|
|
101
107
|
position?: BandPosition;
|
|
102
108
|
className?: number | string;
|
|
103
109
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
* The id of y-axis which is corresponding to the data.
|
|
111
|
+
* Required when there are multiple YAxes.
|
|
112
|
+
* @defaultValue 0
|
|
113
|
+
*/
|
|
108
114
|
yAxisId?: number | string;
|
|
109
115
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
* The id of x-axis which is corresponding to the data.
|
|
117
|
+
* Required when there are multiple XAxes.
|
|
118
|
+
* @defaultValue 0
|
|
119
|
+
*/
|
|
114
120
|
xAxisId?: number | string;
|
|
115
121
|
shape?: OctaneElement<SVGElement> | ((props: any) => OctaneElement<SVGElement>);
|
|
116
122
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
* Renders a single label.
|
|
124
|
+
*
|
|
125
|
+
* - `false`: no labels are rendered
|
|
126
|
+
* - `string` | `number`: the content of the label
|
|
127
|
+
* - `object`: the props of LabelList component
|
|
128
|
+
* - `OctaneElement`: a custom SVG label element, such as `<text>` or `<g>`.
|
|
129
|
+
* HTML elements such as `<div>` are not valid inside the chart SVG and may trigger React DOM warnings.
|
|
130
|
+
* - `function`: a render function of custom label
|
|
131
|
+
*
|
|
132
|
+
* @defaultValue false
|
|
133
|
+
*
|
|
134
|
+
* @see {@link https://recharts.github.io/en-US/examples/LineChartWithReferenceLines/ Reference elements with a label}
|
|
135
|
+
*/
|
|
130
136
|
label?: ImplicitLabelType;
|
|
131
137
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
* Z-Index of this component and its children. The higher the value,
|
|
139
|
+
* the more on top it will be rendered.
|
|
140
|
+
* Components with higher zIndex will appear in front of components with lower zIndex.
|
|
141
|
+
* If undefined or 0, the content is rendered in the default layer without portals.
|
|
142
|
+
*
|
|
143
|
+
* @since 3.4
|
|
144
|
+
* @defaultValue 400
|
|
145
|
+
* @see {@link https://recharts.github.io/en-US/guide/zIndex/ Z-Index and layers guide}
|
|
146
|
+
*/
|
|
141
147
|
zIndex?: number;
|
|
142
148
|
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
* The width of the stroke
|
|
150
|
+
* @defaultValue 1
|
|
151
|
+
*/
|
|
146
152
|
strokeWidth?: number | string;
|
|
147
153
|
}
|
|
148
154
|
|
|
@@ -155,8 +161,7 @@ interface ReferenceLineProps<
|
|
|
155
161
|
export type Props<
|
|
156
162
|
XValueType extends ReferenceCoordinateValue = any,
|
|
157
163
|
YValueType extends ReferenceCoordinateValue = any,
|
|
158
|
-
> =
|
|
159
|
-
Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps<XValueType, YValueType>;
|
|
164
|
+
> = Omit<SVGProps<SVGLineElement>, 'viewBox'> & ReferenceLineProps<XValueType, YValueType>;
|
|
160
165
|
|
|
161
166
|
const renderLine = (option: ReferenceLineProps['shape'], props: SVGProps<SVGLineElement>) => {
|
|
162
167
|
let line;
|
|
@@ -167,9 +172,10 @@ const renderLine = (option: ReferenceLineProps['shape'], props: SVGProps<SVGLine
|
|
|
167
172
|
line = option(props);
|
|
168
173
|
} else {
|
|
169
174
|
if (
|
|
170
|
-
!isWellBehavedNumber(props.x1) ||
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
!isWellBehavedNumber(props.x1) ||
|
|
176
|
+
!isWellBehavedNumber(props.y1) ||
|
|
177
|
+
!isWellBehavedNumber(props.x2) ||
|
|
178
|
+
!isWellBehavedNumber(props.y2)
|
|
173
179
|
) {
|
|
174
180
|
return null;
|
|
175
181
|
}
|
|
@@ -310,12 +316,13 @@ export function ReportReferenceLine(props: ReferenceLineSettings): null {
|
|
|
310
316
|
ifOverflow,
|
|
311
317
|
x,
|
|
312
318
|
y,
|
|
313
|
-
segment:
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
segment:
|
|
320
|
+
segment == null
|
|
321
|
+
? segment
|
|
322
|
+
: [
|
|
323
|
+
{ x: segmentStartX, y: segmentStartY },
|
|
324
|
+
{ x: segmentEndX, y: segmentEndY },
|
|
325
|
+
],
|
|
319
326
|
};
|
|
320
327
|
dispatch(addLine(settings));
|
|
321
328
|
return () => {
|
|
@@ -343,18 +350,22 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
|
|
|
343
350
|
const clipPathId = useClipPathId();
|
|
344
351
|
const xAxis = useAppSelector((state) => selectXAxisSettings(state, xAxisId));
|
|
345
352
|
const yAxis = useAppSelector((state) => selectYAxisSettings(state, yAxisId));
|
|
346
|
-
const xAxisScale = useAppSelector(
|
|
347
|
-
|
|
353
|
+
const xAxisScale = useAppSelector((state) =>
|
|
354
|
+
selectAxisScale(state, 'xAxis', xAxisId, isPanorama),
|
|
348
355
|
);
|
|
349
|
-
const yAxisScale = useAppSelector(
|
|
350
|
-
|
|
356
|
+
const yAxisScale = useAppSelector((state) =>
|
|
357
|
+
selectAxisScale(state, 'yAxis', yAxisId, isPanorama),
|
|
351
358
|
);
|
|
352
359
|
|
|
353
360
|
const viewBox = useViewBox();
|
|
354
361
|
|
|
355
362
|
if (
|
|
356
|
-
!clipPathId ||
|
|
357
|
-
|
|
363
|
+
!clipPathId ||
|
|
364
|
+
!viewBox ||
|
|
365
|
+
xAxis == null ||
|
|
366
|
+
yAxis == null ||
|
|
367
|
+
xAxisScale == null ||
|
|
368
|
+
yAxisScale == null
|
|
358
369
|
) {
|
|
359
370
|
return null;
|
|
360
371
|
}
|
|
@@ -380,8 +391,7 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
|
|
|
380
391
|
const { x: x1, y: y1 } = point1;
|
|
381
392
|
const { x: x2, y: y2 } = point2;
|
|
382
393
|
|
|
383
|
-
const clipPath =
|
|
384
|
-
ifOverflow === 'hidden' ? `url(#${clipPathId})` : undefined;
|
|
394
|
+
const clipPath = ifOverflow === 'hidden' ? `url(#${clipPathId})` : undefined;
|
|
385
395
|
|
|
386
396
|
const lineProps: SVGProps<SVGLineElement> = {
|
|
387
397
|
clipPath,
|
|
@@ -394,15 +404,17 @@ function ReferenceLineImpl(props: PropsWithDefaults) {
|
|
|
394
404
|
|
|
395
405
|
const rect = rectWithCoords({ x1, y1, x2, y2 });
|
|
396
406
|
|
|
397
|
-
return
|
|
398
|
-
<
|
|
399
|
-
{
|
|
400
|
-
|
|
401
|
-
<
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
407
|
+
return (
|
|
408
|
+
<ZIndexLayer zIndex={props.zIndex}>
|
|
409
|
+
<Layer className={clsx('recharts-reference-line', className)}>
|
|
410
|
+
{renderLine(shape, lineProps)}
|
|
411
|
+
<CartesianLabelContextProvider {...rect} lowerWidth={rect.width} upperWidth={rect.width}>
|
|
412
|
+
<CartesianLabelFromLabelProp label={props.label} />
|
|
413
|
+
{props.children}
|
|
414
|
+
</CartesianLabelContextProvider>
|
|
415
|
+
</Layer>
|
|
416
|
+
</ZIndexLayer>
|
|
417
|
+
);
|
|
406
418
|
}
|
|
407
419
|
|
|
408
420
|
export const referenceLineDefaultProps = {
|
|
@@ -439,17 +451,19 @@ export function ReferenceLine<
|
|
|
439
451
|
YValueType extends ReferenceCoordinateValue = any,
|
|
440
452
|
>(outsideProps: Props<XValueType, YValueType>) {
|
|
441
453
|
const props: PropsWithDefaults = resolveDefaultProps(outsideProps, referenceLineDefaultProps);
|
|
442
|
-
return
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
454
|
+
return (
|
|
455
|
+
<>
|
|
456
|
+
<ReportReferenceLine
|
|
457
|
+
yAxisId={props.yAxisId}
|
|
458
|
+
xAxisId={props.xAxisId}
|
|
459
|
+
ifOverflow={props.ifOverflow}
|
|
460
|
+
x={props.x}
|
|
461
|
+
y={props.y}
|
|
462
|
+
segment={props.segment}
|
|
463
|
+
/>
|
|
464
|
+
<ReferenceLineImpl {...props} />
|
|
465
|
+
</>
|
|
466
|
+
);
|
|
453
467
|
}
|
|
454
468
|
|
|
455
469
|
ReferenceLine.displayName = 'ReferenceLine';
|