Skip to content

Commit

Permalink
feat(pie): fix angle padding
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Dec 18, 2020
1 parent cfc0cb6 commit 3baba4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions packages/arcs/src/useArcGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import { useMemo } from 'react'
import { arc as d3Arc } from 'd3-shape'
import { ArcGenerator, Arc } from './types'

export const useArcGenerator = ({ cornerRadius = 0 }: { cornerRadius: number }): ArcGenerator =>
export const useArcGenerator = ({
cornerRadius = 0,
padAngle = 0,
}: {
cornerRadius?: number
padAngle?: number
}): ArcGenerator =>
useMemo(
() =>
d3Arc<Arc>()
.innerRadius(arc => arc.innerRadius)
.outerRadius(arc => arc.outerRadius)
.cornerRadius(cornerRadius),
[cornerRadius]
.cornerRadius(cornerRadius)
.padAngle(padAngle),
[cornerRadius, padAngle]
)
3 changes: 2 additions & 1 deletion packages/pie/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const usePie = <RawDatum>({
activeOuterRadiusOffset,
})

const arcGenerator = useArcGenerator({ cornerRadius })
const arcGenerator = useArcGenerator({ cornerRadius, padAngle: degreesToRadians(padAngle) })

return { dataWithArc, arcGenerator, setActiveId }
}
Expand Down Expand Up @@ -334,6 +334,7 @@ export const usePieFromBox = <RawDatum>({

const arcGenerator = useArcGenerator({
cornerRadius,
padAngle: degreesToRadians(padAngle),
})

return {
Expand Down

0 comments on commit 3baba4c

Please sign in to comment.