MCPcopy
hub / github.com/plouc/nivo / useArcLabels

Function useArcLabels

packages/arcs/src/arc_labels/useArcLabels.ts:20–54  ·  view source on GitHub ↗
({
    data,
    offset,
    skipAngle,
    label,
    textColor,
}: {
    data: Datum[]
    offset?: number
    skipAngle?: number
    label: PropertyAccessor<Datum, string>
    textColor: InheritedColorConfig<Datum>
})

Source from the content-addressed store, hash-verified

18 * about the parameters.
19 */
20export 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}

Callers 1

InnerPieCanvasFunction · 0.90

Calls 4

usePropertyAccessorFunction · 0.90
useThemeFunction · 0.90
useInheritedColorFunction · 0.90
useArcCentersFunction · 0.90

Tested by

no test coverage detected