How to use the @nivo/core.positionFromAngle function in @nivo/core

To help you get started, we’ve selected a few @nivo/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plouc / nivo / packages / radar / src / RadarGridLabels.js View on Github external
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,
        }
    })
github plouc / nivo / packages / pie / src / PieSlicesLabels.js View on Github external
.map(arc => {
                        const angle = midAngle(arc) - Math.PI / 2
                        const position = positionFromAngle(angle, centerRadius)

                        return (
github plouc / nivo / packages / nivo-radar / src / RadarTooltipItem.js View on Github external
({ 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,
            }
        }
    ),
github plouc / nivo / packages / nivo-pie / src / PieSlicesLabels.js View on Github external
{arcs.filter(arc => skipAngle === 0 || arc.angleDeg > skipAngle).map(arc => {
                    const angle = midAngle(arc) - Math.PI / 2
                    const position = positionFromAngle(angle, centerRadius)

                    return (
github plouc / nivo / packages / radar / src / RadarDots.js View on Github external
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,
            })
        })
github plouc / nivo / packages / nivo-radar / src / RadarGrid.js View on Github external
{angles.map((angle, i) => {
                const position = positionFromAngle(angle, radius)
                return (
github plouc / nivo / packages / nivo-radar / src / RadarGridLabels.js View on Github external
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,
        }
    })
github plouc / nivo / packages / radar / src / RadarTooltipItem.js View on Github external
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])
github plouc / nivo / packages / pie / src / compute.js View on Github external
.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'
github StateOfJS / State-of-JS-2019 / src / modules_not_used / features / blocks / _FeaturesRadialClusterOverviewBlock.js View on Github external
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 (
        <>