@@ -31,14 +31,14 @@ import {
31
31
VictorySliceLabelPlacementType ,
32
32
VictorySliceLabelPositionType ,
33
33
} from "./slice" ;
34
- import { CurvedLabel , CurvedLabelProps } from "./curved-label" ;
34
+ import { CurvedLabel } from "./curved-label" ;
35
35
36
36
export interface VictoryPieProps
37
37
extends Omit < VictoryCommonProps , "polar" > ,
38
38
VictoryDatableProps ,
39
39
VictoryLabelableProps ,
40
40
VictoryMultiLabelableProps {
41
- curvedLabelComponent ?: React . ReactElement ;
41
+ curvedLabelComponent ?: React . ReactElement ;
42
42
colorScale ?: ColorScalePropType ;
43
43
cornerRadius ?: SliceNumberOrCallback < SliceProps , "cornerRadius" > ;
44
44
endAngle ?: number ;
@@ -161,7 +161,7 @@ class VictoryPieBase extends React.Component<VictoryPieProps> {
161
161
"groupComponent" ,
162
162
"containerComponent" ,
163
163
"labelIndicatorComponent" ,
164
- "curvedLabelComponent"
164
+ "curvedLabelComponent" ,
165
165
] ;
166
166
167
167
// Overridden in victory-native
@@ -188,7 +188,6 @@ class VictoryPieBase extends React.Component<VictoryPieProps> {
188
188
labelIndicator &&
189
189
labelPosition === "centroid" &&
190
190
labelPlacement !== "curved" ;
191
- let groupComponentTransform ;
192
191
193
192
const children : React . ReactElement [ ] = [ ] ;
194
193
@@ -217,31 +216,25 @@ class VictoryPieBase extends React.Component<VictoryPieProps> {
217
216
// label arc. We need to pass this id to the href of textPath component which will
218
217
// have label value(tspan) as child component.
219
218
if ( labelPlacement === "curved" && curvedLabelComponent ) {
219
+ // create labelPath
220
+ const pathComponent : React . ReactElement = < Path /> ;
220
221
const labelPathComponents = this . dataKeys . map ( ( _dataKey , index ) => {
221
- const curvedLabelProps : CurvedLabelProps = this . getComponentProps (
222
- curvedLabelComponent ,
223
- "curvedLabels " ,
222
+ const curvedLabelPathProps = this . getComponentProps (
223
+ pathComponent ,
224
+ "curvedLabelPaths " ,
224
225
index ,
225
226
) ;
226
-
227
- // create labelPath
228
- const pathComponent : React . ReactElement = < Path /> ;
229
- return React . cloneElement ( pathComponent , {
230
- d : curvedLabelProps . path ,
231
- id : curvedLabelProps . id ,
232
- key : index ,
233
- } ) ;
227
+ return React . cloneElement ( pathComponent , curvedLabelPathProps ) ;
234
228
} ) ;
235
229
children . push ( ...labelPathComponents ) ;
236
230
237
231
const curvedLabelComponents = this . dataKeys
238
232
. map ( ( _dataKey , index ) => {
239
- const curvedLabelProps : CurvedLabelProps = this . getComponentProps (
233
+ const curvedLabelProps = this . getComponentProps (
240
234
curvedLabelComponent ,
241
235
"curvedLabels" ,
242
236
index ,
243
237
) ;
244
- groupComponentTransform = curvedLabelProps . transform ;
245
238
if (
246
239
( curvedLabelProps as any ) . text !== undefined &&
247
240
( curvedLabelProps as any ) . text !== null
@@ -299,9 +292,16 @@ class VictoryPieBase extends React.Component<VictoryPieProps> {
299
292
children . push ( ...labelIndicatorComponents ) ;
300
293
}
301
294
if ( labelPlacement === "curved" ) {
302
- const groupCloneElement = React . cloneElement ( groupComponent , {
303
- transform : groupComponentTransform ,
304
- } ) ;
295
+ const groupComponentProps = this . getComponentProps (
296
+ groupComponent ,
297
+ "groupComponentProps" ,
298
+ 0 ,
299
+ ) ;
300
+
301
+ const groupCloneElement = React . cloneElement (
302
+ groupComponent ,
303
+ groupComponentProps ,
304
+ ) ;
305
305
return this . renderContainer ( groupCloneElement , children ) ;
306
306
}
307
307
return this . renderContainer ( groupComponent , children ) ;
0 commit comments