({
data,
offset,
skipAngle,
label,
textColor,
}: {
data: Datum[]
offset?: number
skipAngle?: number
label: PropertyAccessor<Datum, string>
textColor: InheritedColorConfig<Datum>
})
| 18 | * about the parameters. |
| 19 | */ |
| 20 | export const useArcLabels = <Datum extends DatumWithArcAndColor>({ |
| 21 | data, |
| 22 | offset, |
| 23 | skipAngle, |
| 24 | label, |
| 25 | textColor, |
| 26 | }: { |
| 27 | data: Datum[] |
| 28 | offset?: number |
| 29 | skipAngle?: number |
| 30 | label: PropertyAccessor<Datum, string> |
| 31 | textColor: InheritedColorConfig<Datum> |
| 32 | }) => { |
| 33 | const getLabel = usePropertyAccessor<Datum, string>(label) |
| 34 | |
| 35 | const theme = useTheme() |
| 36 | const getTextColor = useInheritedColor<Datum>(textColor, theme) |
| 37 | |
| 38 | const computeExtraProps = useCallback( |
| 39 | (datum: Datum) => { |
| 40 | return { |
| 41 | label: getLabel(datum), |
| 42 | textColor: getTextColor(datum), |
| 43 | } |
| 44 | }, |
| 45 | [getLabel, getTextColor] |
| 46 | ) |
| 47 | |
| 48 | return useArcCenters<Datum, Omit<ArcLabel<Datum>, keyof ArcCenter<Datum>>>({ |
| 49 | data, |
| 50 | offset, |
| 51 | skipAngle, |
| 52 | computeExtraProps, |
| 53 | }) |
| 54 | } |
no test coverage detected