Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const labels = indices.map((index, i) => {
const position = positionFromAngle(angles[i], radius + labelOffset)
const textAnchor = textAnchorFromAngle(angles[i])
return {
id: index,
angle: radiansToDegrees(angles[i]),
anchor: textAnchor,
...position,
}
})
.map(arc => {
const angle = midAngle(arc) - Math.PI / 2
const position = positionFromAngle(angle, centerRadius)
return (
({ startAngle, endAngle, radius, arcGenerator }) => {
const position = positionFromAngle(
startAngle + (endAngle - startAngle) * 0.5 - Math.PI / 2,
radius
)
return {
path: arcGenerator({ startAngle, endAngle }),
tipX: position.x,
tipY: position.y,
}
}
),
{arcs.filter(arc => skipAngle === 0 || arc.angleDeg > skipAngle).map(arc => {
const angle = midAngle(arc) - Math.PI / 2
const position = positionFromAngle(angle, centerRadius)
return (
keys.forEach(key => {
const pointData = {
index,
key,
value: datum[key],
color: colorByKey[key],
}
acc.push({
key: `${key}.${index}`,
label: enableLabel ? getLabel(pointData) : null,
style: {
fill: fillColor(pointData),
stroke: strokeColor(pointData),
...positionFromAngle(angleStep * i - Math.PI / 2, radiusScale(datum[key])),
},
data: pointData,
})
})
{angles.map((angle, i) => {
const position = positionFromAngle(angle, radius)
return (
const labels = indices.map((index, i) => {
const position = positionFromAngle(angles[i], radius + labelOffset)
const textAnchor = textAnchorFromAngle(angles[i])
return {
key: `label.${i}`,
label: index,
textAnchor,
...position,
}
})
const { path, tipX, tipY } = useMemo(() => {
const position = positionFromAngle(
startAngle + (endAngle - startAngle) * 0.5 - Math.PI / 2,
radius
)
return {
path: arcGenerator({ startAngle, endAngle }),
tipX: position.x,
tipY: position.y,
}
}, [startAngle, endAngle, radius, arcGenerator])
.map(arc => {
const angle = absoluteAngleRadians(midAngle(arc) - Math.PI / 2)
const positionA = positionFromAngle(angle, radius + linkOffset)
const positionB = positionFromAngle(angle, radius + linkOffset + linkDiagonalLength)
let positionC
let labelPosition
let textAlign
if (
absoluteAngleDegrees(radiansToDegrees(angle)) < 90 ||
absoluteAngleDegrees(radiansToDegrees(angle)) >= 270
) {
positionC = { x: positionB.x + linkHorizontalLength, y: positionB.y }
labelPosition = {
x: positionB.x + linkHorizontalLength + textXOffset,
y: positionB.y,
}
textAlign = 'left'
const SectionLabel = memo(({ section, index, radius }) => {
const centerAngle = section.x - Math.PI * 0.5
const startAngle = centerAngle - Math.PI * 0.15
const endAngle = centerAngle + Math.PI * 0.15
const startPoint = positionFromAngle(startAngle, radius + 14)
const endPoint = positionFromAngle(endAngle, radius + 14)
return (
<>