@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
|
@@ -11,16 +11,20 @@ const allowedTooltipTypes: ReadonlyArray<TooltipEventType> = ['item'];
|
|
|
11
11
|
* @provides CartesianViewBoxContext
|
|
12
12
|
* @provides CartesianChartContext
|
|
13
13
|
*/
|
|
14
|
-
export function ScatterChart<DataPointType = unknown>(
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export function ScatterChart<DataPointType = unknown>(
|
|
15
|
+
props: CartesianChartProps<DataPointType> & {
|
|
16
|
+
ref?: Ref<SVGSVGElement>;
|
|
17
|
+
},
|
|
18
|
+
) {
|
|
17
19
|
const { ref, ...rest } = props;
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
return (
|
|
21
|
+
<CartesianChart
|
|
22
|
+
chartName="ScatterChart"
|
|
23
|
+
defaultTooltipEventType="item"
|
|
24
|
+
validateTooltipEventTypes={allowedTooltipTypes}
|
|
25
|
+
tooltipPayloadSearcher={arrayTooltipSearcher}
|
|
26
|
+
categoricalChartProps={rest}
|
|
27
|
+
ref={ref}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
26
30
|
}
|
|
@@ -62,85 +62,85 @@ interface SunburstNode extends SunburstData {
|
|
|
62
62
|
export interface SunburstChartProps extends EventThrottlingProps {
|
|
63
63
|
className?: string;
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
* The source data. Each element should be an object.
|
|
66
|
+
* The properties of each object represent the values of different data dimensions.
|
|
67
|
+
*
|
|
68
|
+
* Use the `dataKey` prop to specify which properties to use.
|
|
69
|
+
*
|
|
70
|
+
* @example data={[{ name: 'a', value: 12, fill: '#8884d8' }, { name: 'b', value: 5, fill: '#83a6ed' }]}
|
|
71
|
+
*/
|
|
72
72
|
data: SunburstData;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
* The width of chart container.
|
|
75
|
+
* Can be a number or a percent string like "100%".
|
|
76
|
+
*
|
|
77
|
+
* @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
|
|
78
|
+
*/
|
|
79
79
|
width?: number | Percent;
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
* The height of chart container.
|
|
82
|
+
* Can be a number or a percent string like "100%".
|
|
83
|
+
*
|
|
84
|
+
* @see {@link https://recharts.github.io/en-US/guide/sizes/ Chart sizing guide}
|
|
85
|
+
*/
|
|
86
86
|
height?: number | Percent;
|
|
87
87
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
* If true, then it will listen to container size changes and adapt the SVG chart accordingly.
|
|
89
|
+
* If false, then it renders the chart at the specified width and height and will stay that way
|
|
90
|
+
* even if the container size changes.
|
|
91
|
+
*
|
|
92
|
+
* This is similar to ResponsiveContainer but without the need for an extra wrapper component.
|
|
93
|
+
* The `responsive` prop also uses standard CSS sizing rules, instead of custom resolution logic (like ResponsiveContainer does).
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
96
|
responsive?: boolean;
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
* Distance between sectors.
|
|
99
|
+
*
|
|
100
|
+
* @defaultValue 2
|
|
101
|
+
*/
|
|
102
102
|
padding?: number;
|
|
103
103
|
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
* Decides how to extract value from the data.
|
|
105
|
+
*
|
|
106
|
+
* @defaultValue value
|
|
107
|
+
*/
|
|
108
108
|
dataKey?: string;
|
|
109
109
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
* Name represents each sector in the tooltip.
|
|
111
|
+
* This allows you to extract the name from the data:
|
|
112
|
+
*
|
|
113
|
+
* - `string`: the name of the field in the data object;
|
|
114
|
+
* - `number`: the index of the field in the data;
|
|
115
|
+
* - `function`: a function that receives the data object and returns the name.
|
|
116
|
+
*
|
|
117
|
+
* @defaultValue name
|
|
118
|
+
*/
|
|
119
119
|
nameKey?: DataKey<any>;
|
|
120
120
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
* Padding between each hierarchical level.
|
|
122
|
+
*/
|
|
123
123
|
ringPadding?: number;
|
|
124
124
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
* The radius of the inner circle at the center of the chart.
|
|
126
|
+
*
|
|
127
|
+
* @defaultValue 50
|
|
128
|
+
*/
|
|
129
129
|
innerRadius?: number;
|
|
130
130
|
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
* Outermost edge of the chart.
|
|
132
|
+
* Defaults to the max possible radius for a circle inscribed in the chart container
|
|
133
|
+
*/
|
|
134
134
|
outerRadius?: number;
|
|
135
135
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
* The x-coordinate of center in pixels.
|
|
137
|
+
* If undefined, it will be set to half of the chart width.
|
|
138
|
+
*/
|
|
139
139
|
cx?: number;
|
|
140
140
|
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
* The y-coordinate of center in pixels.
|
|
142
|
+
* If undefined, it will be set to half of the chart height.
|
|
143
|
+
*/
|
|
144
144
|
cy?: number;
|
|
145
145
|
/** Angle in degrees from which the chart should start. */
|
|
146
146
|
startAngle?: number;
|
|
@@ -150,8 +150,8 @@ export interface SunburstChartProps extends EventThrottlingProps {
|
|
|
150
150
|
fill?: string;
|
|
151
151
|
stroke?: string;
|
|
152
152
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
* An object with svg text options to control the appearance of the chart labels.
|
|
154
|
+
*/
|
|
155
155
|
textOptions?: TextProps;
|
|
156
156
|
onMouseEnter?: (node: SunburstData, e: NativeMouseEvent) => void;
|
|
157
157
|
onMouseLeave?: (node: SunburstData, e: NativeMouseEvent) => void;
|
|
@@ -185,41 +185,43 @@ function getMaxDepthOf(node: SunburstData): number {
|
|
|
185
185
|
return 1 + Math.max(...childDepths);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
const SetSunburstTooltipEntrySettings = React.memo(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
188
|
+
const SetSunburstTooltipEntrySettings = React.memo(
|
|
189
|
+
({
|
|
190
|
+
dataKey,
|
|
191
|
+
nameKey,
|
|
192
|
+
data,
|
|
193
|
+
stroke,
|
|
194
|
+
fill,
|
|
195
|
+
positions,
|
|
196
|
+
id,
|
|
197
|
+
}: Pick<
|
|
198
|
+
WithIdRequired<SunburstChartProps>,
|
|
199
|
+
'dataKey' | 'data' | 'stroke' | 'fill' | 'nameKey' | 'id'
|
|
200
|
+
> & {
|
|
201
|
+
positions: SunburstPositionMap;
|
|
202
|
+
}) => {
|
|
203
|
+
const tooltipEntrySettings: TooltipPayloadConfiguration = {
|
|
204
|
+
dataDefinedOnItem: data.children,
|
|
205
|
+
getPosition: (index) => positions.get(index),
|
|
206
|
+
// Sunburst does not support many of the properties as other charts do so there's plenty of defaults here
|
|
207
|
+
settings: {
|
|
208
|
+
stroke,
|
|
209
|
+
strokeWidth: undefined,
|
|
210
|
+
fill,
|
|
211
|
+
nameKey,
|
|
212
|
+
dataKey,
|
|
213
|
+
// if there is a nameKey use it, otherwise make the name of the tooltip the dataKey itself
|
|
214
|
+
name: nameKey ? undefined : dataKey,
|
|
215
|
+
hide: false,
|
|
216
|
+
type: undefined,
|
|
217
|
+
color: fill,
|
|
218
|
+
unit: '',
|
|
219
|
+
graphicalItemId: id,
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
|
|
223
|
+
},
|
|
224
|
+
);
|
|
223
225
|
|
|
224
226
|
// Why is margin not a sunburst prop? No clue. Probably it should be
|
|
225
227
|
const defaultSunburstMargin: Margin = {
|
|
@@ -273,8 +275,9 @@ export const defaultSunburstChartProps = {
|
|
|
273
275
|
...initialEventSettingsState,
|
|
274
276
|
} as const satisfies Partial<SunburstChartProps>;
|
|
275
277
|
|
|
276
|
-
type InternalSunburstChartProps =
|
|
277
|
-
|
|
278
|
+
type InternalSunburstChartProps = WithIdRequired<
|
|
279
|
+
RequiresDefaultProps<SunburstChartProps, typeof defaultSunburstChartProps>
|
|
280
|
+
>;
|
|
278
281
|
|
|
279
282
|
const SunburstChartImpl = ({
|
|
280
283
|
className,
|
|
@@ -383,14 +386,12 @@ const SunburstChartImpl = ({
|
|
|
383
386
|
<g key={`sunburst-sector-${d.name}-${i}`}>
|
|
384
387
|
<Sector
|
|
385
388
|
onClick={() => handleClick(nodeWithIndex)}
|
|
386
|
-
onMouseEnter={(e: NativeMouseEvent<SVGPathElement>) =>
|
|
387
|
-
nodeWithIndex,
|
|
388
|
-
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
e,
|
|
393
|
-
)}
|
|
389
|
+
onMouseEnter={(e: NativeMouseEvent<SVGPathElement>) =>
|
|
390
|
+
handleMouseEnter(nodeWithIndex, e)
|
|
391
|
+
}
|
|
392
|
+
onMouseLeave={(e: NativeMouseEvent<SVGPathElement>) =>
|
|
393
|
+
handleMouseLeave(nodeWithIndex, e)
|
|
394
|
+
}
|
|
394
395
|
fill={fillColor}
|
|
395
396
|
stroke={stroke}
|
|
396
397
|
strokeWidth={padding}
|
|
@@ -407,7 +408,9 @@ const SunburstChartImpl = ({
|
|
|
407
408
|
textAnchor="middle"
|
|
408
409
|
x={textX + cx}
|
|
409
410
|
y={cy - textY}
|
|
410
|
-
>
|
|
411
|
+
>
|
|
412
|
+
{d[dataKey]}
|
|
413
|
+
</Text>
|
|
411
414
|
</g>,
|
|
412
415
|
);
|
|
413
416
|
|
|
@@ -431,19 +434,21 @@ const SunburstChartImpl = ({
|
|
|
431
434
|
drawArcs(data.children, { radius: thickness, innerR: innerRadius, initialAngle: startAngle });
|
|
432
435
|
|
|
433
436
|
const layerClass = clsx('recharts-sunburst', className);
|
|
434
|
-
return
|
|
435
|
-
<
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
437
|
+
return (
|
|
438
|
+
<Surface width={width} height={height}>
|
|
439
|
+
<Layer className={layerClass}>{sectors}</Layer>
|
|
440
|
+
<SetSunburstTooltipEntrySettings
|
|
441
|
+
dataKey={dataKey}
|
|
442
|
+
nameKey={nameKey}
|
|
443
|
+
data={data}
|
|
444
|
+
stroke={stroke}
|
|
445
|
+
fill={fill}
|
|
446
|
+
positions={positions}
|
|
447
|
+
id={id}
|
|
448
|
+
/>
|
|
449
|
+
{children}
|
|
450
|
+
</Surface>
|
|
451
|
+
);
|
|
447
452
|
};
|
|
448
453
|
|
|
449
454
|
/**
|
|
@@ -468,41 +473,43 @@ export const SunburstChart = (outsideProps: SunburstChartProps) => {
|
|
|
468
473
|
throttledEvents,
|
|
469
474
|
} = props;
|
|
470
475
|
const [tooltipPortal, setTooltipPortal] = useState<HTMLElement | null>(null);
|
|
471
|
-
return
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
<
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
476
|
+
return (
|
|
477
|
+
<RechartsStoreProvider
|
|
478
|
+
preloadedState={preloadedState}
|
|
479
|
+
reduxStoreName={className ?? 'SunburstChart'}
|
|
480
|
+
>
|
|
481
|
+
<ReportChartSize width={width} height={height} />
|
|
482
|
+
<ReportChartMargin margin={defaultSunburstMargin} />
|
|
483
|
+
<ReportEventSettings throttleDelay={throttleDelay} throttledEvents={throttledEvents} />
|
|
484
|
+
<TooltipPortalContext value={tooltipPortal}>
|
|
485
|
+
<RechartsWrapper
|
|
486
|
+
className={className}
|
|
487
|
+
width={width}
|
|
488
|
+
height={height}
|
|
489
|
+
responsive={responsive}
|
|
490
|
+
style={style}
|
|
491
|
+
ref={(node: HTMLDivElement) => {
|
|
492
|
+
if (tooltipPortal == null && node != null) {
|
|
493
|
+
setTooltipPortal(node);
|
|
494
|
+
}
|
|
495
|
+
}}
|
|
496
|
+
onMouseEnter={undefined}
|
|
497
|
+
onMouseLeave={undefined}
|
|
498
|
+
onClick={undefined}
|
|
499
|
+
onMouseMove={undefined}
|
|
500
|
+
onMouseDown={undefined}
|
|
501
|
+
onMouseUp={undefined}
|
|
502
|
+
onContextMenu={undefined}
|
|
503
|
+
onDoubleClick={undefined}
|
|
504
|
+
onTouchStart={undefined}
|
|
505
|
+
onTouchMove={undefined}
|
|
506
|
+
onTouchEnd={undefined}
|
|
507
|
+
>
|
|
508
|
+
<RegisterGraphicalItemId id={externalId} type="sunburst">
|
|
509
|
+
{(id) => <SunburstChartImpl {...props} id={id} />}
|
|
510
|
+
</RegisterGraphicalItemId>
|
|
511
|
+
</RechartsWrapper>
|
|
512
|
+
</TooltipPortalContext>
|
|
513
|
+
</RechartsStoreProvider>
|
|
514
|
+
);
|
|
508
515
|
};
|
|
@@ -65,7 +65,11 @@ function ActivePoint(activePointProps: {
|
|
|
65
65
|
} else {
|
|
66
66
|
dot = <Dot {...dotProps} />;
|
|
67
67
|
}
|
|
68
|
-
return
|
|
68
|
+
return (
|
|
69
|
+
<Layer className="recharts-active-dot" clipPath={clipPath}>
|
|
70
|
+
{dot}
|
|
71
|
+
</Layer>
|
|
72
|
+
);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
export function ActivePoints(props: ActivePointsProps) {
|
|
@@ -82,20 +86,22 @@ export function ActivePoints(props: ActivePointsProps) {
|
|
|
82
86
|
if (points == null || activeDataPoints == null) {
|
|
83
87
|
return null;
|
|
84
88
|
}
|
|
85
|
-
const activePoint: PointType | undefined = points.find(
|
|
86
|
-
|
|
89
|
+
const activePoint: PointType | undefined = points.find((p) =>
|
|
90
|
+
activeDataPoints.includes(p.payload),
|
|
87
91
|
);
|
|
88
92
|
if (isNullish(activePoint)) {
|
|
89
93
|
return null;
|
|
90
94
|
}
|
|
91
|
-
return
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
return (
|
|
96
|
+
<ZIndexLayer zIndex={zIndex}>
|
|
97
|
+
<ActivePoint
|
|
98
|
+
point={activePoint}
|
|
99
|
+
childIndex={Number(activeTooltipIndex)}
|
|
100
|
+
mainColor={mainColor}
|
|
101
|
+
dataKey={itemDataKey}
|
|
102
|
+
activeDot={activeDot}
|
|
103
|
+
clipPath={clipPath}
|
|
104
|
+
/>
|
|
105
|
+
</ZIndexLayer>
|
|
106
|
+
);
|
|
101
107
|
}
|
|
@@ -39,13 +39,12 @@ export interface CursorProps extends ZIndexable {
|
|
|
39
39
|
index: TooltipIndex | undefined;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
export type CursorConnectedProps =
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
42
|
+
export type CursorConnectedProps = CursorProps & {
|
|
43
|
+
tooltipAxisBandSize: number;
|
|
44
|
+
layout: LayoutType;
|
|
45
|
+
offset: ChartOffsetInternal;
|
|
46
|
+
chartName: string;
|
|
47
|
+
};
|
|
49
48
|
|
|
50
49
|
function RenderCursor({
|
|
51
50
|
cursor,
|
|
@@ -79,7 +78,11 @@ export function CursorInternal(props: CursorConnectedProps) {
|
|
|
79
78
|
const activeCoordinate = coordinate;
|
|
80
79
|
const activePayload = payload;
|
|
81
80
|
const activeTooltipIndex = index;
|
|
82
|
-
if (
|
|
81
|
+
if (
|
|
82
|
+
!cursor ||
|
|
83
|
+
!activeCoordinate ||
|
|
84
|
+
(chartName !== 'ScatterChart' && tooltipEventType !== 'axis')
|
|
85
|
+
) {
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
85
88
|
let restProps, cursorComp: ComponentType<any>, preferredZIndex: number;
|
|
@@ -124,9 +127,11 @@ export function CursorInternal(props: CursorConnectedProps) {
|
|
|
124
127
|
className: clsx('recharts-tooltip-cursor', extraClassName),
|
|
125
128
|
};
|
|
126
129
|
|
|
127
|
-
return
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
+
return (
|
|
131
|
+
<ZIndexLayer zIndex={props.zIndex ?? preferredZIndex}>
|
|
132
|
+
<RenderCursor cursor={cursor} cursorComp={cursorComp} cursorProps={cursorProps} />
|
|
133
|
+
</ZIndexLayer>
|
|
134
|
+
);
|
|
130
135
|
}
|
|
131
136
|
|
|
132
137
|
/*
|
|
@@ -147,11 +152,13 @@ export function Cursor(props: CursorProps) {
|
|
|
147
152
|
return null;
|
|
148
153
|
}
|
|
149
154
|
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
return (
|
|
156
|
+
<CursorInternal
|
|
157
|
+
{...props}
|
|
158
|
+
offset={offset}
|
|
159
|
+
layout={layout}
|
|
160
|
+
tooltipAxisBandSize={tooltipAxisBandSize}
|
|
161
|
+
chartName={chartName}
|
|
162
|
+
/>
|
|
163
|
+
);
|
|
157
164
|
}
|