@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
|
@@ -37,69 +37,69 @@ export type ErrorBarDirection = 'x' | 'y';
|
|
|
37
37
|
|
|
38
38
|
export type ErrorBarDataPointFormatter<
|
|
39
39
|
T extends BarRectangleItem | LinePointItem | ScatterPointItem,
|
|
40
|
-
> =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
> = (
|
|
41
|
+
entry: T,
|
|
42
|
+
dataKey: DataKey<T, number[] | number>,
|
|
43
|
+
direction: ErrorBarDirection,
|
|
44
|
+
) => ErrorBarDataItem;
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* External ErrorBar props, visible for users of the library
|
|
48
48
|
*/
|
|
49
49
|
interface ErrorBarProps<DataPointType = any, DataValueType = any> extends ZIndexable {
|
|
50
50
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
* Decides how to extract the value of this ErrorBar from the data:
|
|
52
|
+
* - `string`: the name of the field in the data object;
|
|
53
|
+
* - `number`: the index of the field in the data;
|
|
54
|
+
* - `function`: a function that receives the data object and returns the value of this ErrorBar.
|
|
55
|
+
*
|
|
56
|
+
* The error values can be a single value for symmetric error bars;
|
|
57
|
+
* or an array of a lower and upper error value for asymmetric error bars.
|
|
58
|
+
*/
|
|
59
59
|
dataKey: DataKey<DataPointType, DataValueType>;
|
|
60
60
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
* Width of the error bar ends (the serifs) in pixels.
|
|
62
|
+
* This is not the total width of the error bar, but just the width of the little lines at the ends.
|
|
63
|
+
*
|
|
64
|
+
* The total width of the error bar is determined by the data value plus/minus the error value.
|
|
65
|
+
*
|
|
66
|
+
* @defaultValue 5
|
|
67
|
+
*/
|
|
68
68
|
width?: number;
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
* Direction of the error bar. Usually determined by chart layout, except in Scatter chart.
|
|
71
|
+
* In Scatter chart, "x" means horizontal error bars, "y" means vertical error bars.
|
|
72
|
+
*/
|
|
73
73
|
direction?: ErrorBarDirection;
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* @defaultValue true
|
|
76
|
+
*/
|
|
77
77
|
isAnimationActive?: boolean;
|
|
78
78
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
* @defaultValue 0
|
|
80
|
+
*/
|
|
81
81
|
animationBegin?: number;
|
|
82
82
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
* @defaultValue 400
|
|
84
|
+
*/
|
|
85
85
|
animationDuration?: number;
|
|
86
86
|
/**
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
* @defaultValue ease-in-out
|
|
88
|
+
*/
|
|
89
89
|
animationEasing?: EasingInput;
|
|
90
90
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
* The width of the stroke
|
|
92
|
+
*/
|
|
93
93
|
strokeWidth?: number | string;
|
|
94
94
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
* The stroke color. If "none", no line will be drawn.
|
|
96
|
+
*
|
|
97
|
+
* @defaultValue black
|
|
98
|
+
*/
|
|
99
99
|
stroke?: string;
|
|
100
100
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
* @defaultValue 400
|
|
102
|
+
*/
|
|
103
103
|
zIndex?: number;
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -108,21 +108,20 @@ export type Props = SVGProps<SVGLineElement> & ErrorBarProps;
|
|
|
108
108
|
/**
|
|
109
109
|
* Props after defaults, and required props have been applied.
|
|
110
110
|
*/
|
|
111
|
-
type ErrorBarInternalProps =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
111
|
+
type ErrorBarInternalProps = SVGProps<SVGLineElement> & {
|
|
112
|
+
dataKey: DataKey<any>;
|
|
113
|
+
/** the width of the error bar ends */
|
|
114
|
+
width: number;
|
|
115
|
+
/**
|
|
116
|
+
* Only used for ScatterChart with error bars in two directions.
|
|
117
|
+
* Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
|
|
118
|
+
*/
|
|
119
|
+
direction: ErrorBarDirection;
|
|
120
|
+
isAnimationActive: boolean;
|
|
121
|
+
animationBegin: number;
|
|
122
|
+
animationDuration: number;
|
|
123
|
+
animationEasing: EasingInput;
|
|
124
|
+
};
|
|
126
125
|
|
|
127
126
|
function ErrorBarImpl(props: ErrorBarInternalProps) {
|
|
128
127
|
const {
|
|
@@ -137,8 +136,13 @@ function ErrorBarImpl(props: ErrorBarInternalProps) {
|
|
|
137
136
|
} = props;
|
|
138
137
|
const svgProps = svgPropertiesNoEvents(others);
|
|
139
138
|
|
|
140
|
-
const {
|
|
141
|
-
|
|
139
|
+
const {
|
|
140
|
+
data,
|
|
141
|
+
dataPointFormatter,
|
|
142
|
+
xAxisId,
|
|
143
|
+
yAxisId,
|
|
144
|
+
errorBarOffset: offset,
|
|
145
|
+
} = useErrorBarContext();
|
|
142
146
|
|
|
143
147
|
const xAxis = useXAxis(xAxisId);
|
|
144
148
|
const yAxis = useYAxis(yAxisId);
|
|
@@ -213,32 +217,36 @@ function ErrorBarImpl(props: ErrorBarInternalProps) {
|
|
|
213
217
|
}
|
|
214
218
|
}
|
|
215
219
|
|
|
216
|
-
const scaleDirection: string =
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
{...svgProps}
|
|
226
|
-
>{lineCoordinates.map((c, lineIndex) => {
|
|
227
|
-
const lineStyle = isAnimationActive ? { transformOrigin } : undefined;
|
|
228
|
-
return <CSSTransitionAnimate
|
|
229
|
-
animationId={`error-bar-${direction}_${c.x1}-${c.x2}-${c.y1}-${c.y2}`}
|
|
230
|
-
from={`${scaleDirection}(0)`}
|
|
231
|
-
to={`${scaleDirection}(1)`}
|
|
232
|
-
attributeName="transform"
|
|
233
|
-
begin={animationBegin}
|
|
234
|
-
easing={extractCssEasing(animationEasing)}
|
|
235
|
-
isActive={isAnimationActive}
|
|
236
|
-
duration={animationDuration}
|
|
237
|
-
key={`errorbar-${dataIndex}-${c.x1}-${c.y1}-${c.x2}-${c.y2}-${lineIndex}`}
|
|
220
|
+
const scaleDirection: string = direction === 'x' ? 'scaleX' : 'scaleY';
|
|
221
|
+
|
|
222
|
+
const transformOrigin = direction === 'x' ? `${x}px ${y + offset}px` : `${x + offset}px ${y}px`;
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<Layer
|
|
226
|
+
className="recharts-errorBar"
|
|
227
|
+
key={`bar-${x}-${y}-${value}-${dataIndex}`}
|
|
228
|
+
{...svgProps}
|
|
238
229
|
>
|
|
239
|
-
{(
|
|
240
|
-
|
|
241
|
-
|
|
230
|
+
{lineCoordinates.map((c, lineIndex) => {
|
|
231
|
+
const lineStyle = isAnimationActive ? { transformOrigin } : undefined;
|
|
232
|
+
return (
|
|
233
|
+
<CSSTransitionAnimate
|
|
234
|
+
animationId={`error-bar-${direction}_${c.x1}-${c.x2}-${c.y1}-${c.y2}`}
|
|
235
|
+
from={`${scaleDirection}(0)`}
|
|
236
|
+
to={`${scaleDirection}(1)`}
|
|
237
|
+
attributeName="transform"
|
|
238
|
+
begin={animationBegin}
|
|
239
|
+
easing={extractCssEasing(animationEasing)}
|
|
240
|
+
isActive={isAnimationActive}
|
|
241
|
+
duration={animationDuration}
|
|
242
|
+
key={`errorbar-${dataIndex}-${c.x1}-${c.y1}-${c.x2}-${c.y2}-${lineIndex}`}
|
|
243
|
+
>
|
|
244
|
+
{(style) => <line {...c} style={{ ...lineStyle, ...style }} />}
|
|
245
|
+
</CSSTransitionAnimate>
|
|
246
|
+
);
|
|
247
|
+
})}
|
|
248
|
+
</Layer>
|
|
249
|
+
);
|
|
242
250
|
});
|
|
243
251
|
|
|
244
252
|
return <Layer className="recharts-errorBars">{errorBars}</Layer>;
|
|
@@ -294,29 +302,25 @@ export const errorBarDefaultProps = {
|
|
|
294
302
|
export function ErrorBar(outsideProps: Props) {
|
|
295
303
|
const realDirection: ErrorBarDirection = useErrorBarDirection(outsideProps.direction);
|
|
296
304
|
const props = resolveDefaultProps(outsideProps, errorBarDefaultProps);
|
|
297
|
-
const {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
animationEasing={animationEasing}
|
|
317
|
-
/>
|
|
318
|
-
</ZIndexLayer>
|
|
319
|
-
</>;
|
|
305
|
+
const { width, isAnimationActive, animationBegin, animationDuration, animationEasing, zIndex } =
|
|
306
|
+
props;
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<>
|
|
310
|
+
<ReportErrorBarSettings dataKey={props.dataKey} direction={realDirection} />
|
|
311
|
+
<ZIndexLayer zIndex={zIndex}>
|
|
312
|
+
<ErrorBarImpl
|
|
313
|
+
{...props}
|
|
314
|
+
direction={realDirection}
|
|
315
|
+
width={width}
|
|
316
|
+
isAnimationActive={isAnimationActive}
|
|
317
|
+
animationBegin={animationBegin}
|
|
318
|
+
animationDuration={animationDuration}
|
|
319
|
+
animationEasing={animationEasing}
|
|
320
|
+
/>
|
|
321
|
+
</ZIndexLayer>
|
|
322
|
+
</>
|
|
323
|
+
);
|
|
320
324
|
}
|
|
321
325
|
|
|
322
326
|
ErrorBar.displayName = 'ErrorBar';
|