How to use the @nivo/core.midAngle 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 / 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,
                }
github plouc / nivo / packages / chord / src / ChordRibbons.js View on Github external
const getRibbonAngles = ({ source, target }, useMiddleAngle, springConfig) => {
    let firstArc
    let secondArc
    if (source.startAngle < target.startAngle) {
        firstArc = source
        secondArc = target
    } else {
        firstArc = target
        secondArc = source
    }

    let angles
    if (useMiddleAngle === true) {
        const firstMiddleAngle = midAngle(firstArc)
        const secondMiddleAngle = midAngle(secondArc)

        angles = {
            sourceStartAngle: firstMiddleAngle,
            sourceEndAngle: firstMiddleAngle,
            targetStartAngle: secondMiddleAngle,
            targetEndAngle: secondMiddleAngle,
        }
    } else {
        angles = {
            sourceStartAngle: firstArc.startAngle,
            sourceEndAngle: firstArc.endAngle,
            targetStartAngle: secondArc.startAngle,
            targetEndAngle: secondArc.endAngle,
        }
    }
github plouc / nivo / packages / chord / src / ChordRibbons.js View on Github external
const getRibbonAngles = ({ source, target }, useMiddleAngle, springConfig) => {
    let firstArc
    let secondArc
    if (source.startAngle < target.startAngle) {
        firstArc = source
        secondArc = target
    } else {
        firstArc = target
        secondArc = source
    }

    let angles
    if (useMiddleAngle === true) {
        const firstMiddleAngle = midAngle(firstArc)
        const secondMiddleAngle = midAngle(secondArc)

        angles = {
            sourceStartAngle: firstMiddleAngle,
            sourceEndAngle: firstMiddleAngle,
            targetStartAngle: secondMiddleAngle,
            targetEndAngle: secondMiddleAngle,
        }
    } else {
        angles = {
            sourceStartAngle: firstArc.startAngle,
            sourceEndAngle: firstArc.endAngle,
            targetStartAngle: secondArc.startAngle,
            targetEndAngle: secondArc.endAngle,
        }
    }
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 / chord / src / ChordCanvas.js View on Github external
arcs.forEach(arc => {
                        const angle = midAngle(arc)
                        const props = getPolarLabelProps(radius + labelOffset, angle, labelRotation)

                        ctx.save()
                        ctx.translate(props.x, props.y)
                        ctx.rotate(degreesToRadians(props.rotate))

                        ctx.textAlign = props.align
                        ctx.textBaseline = props.baseline
                        ctx.fillStyle = getLabelTextColor(arc, theme)
                        ctx.fillText(arc.label, 0, 0)

                        ctx.restore()
                    })
github plouc / nivo / packages / chord / src / ChordLabels.js View on Github external
styles={arcs.map(arc => {
                const angle = midAngle(arc)

                return {
                    key: arc.id,
                    data: arc,
                    style: {
                        angle: spring(angle, springConfig),
                    },
                }
            })}
        >
github plouc / nivo / packages / chord / src / ChordLabels.js View on Github external
{arcs.map(arc => {
                    const color = getColor(arc, theme)
                    const angle = midAngle(arc)
                    const textProps = getPolarLabelProps(radius, angle, rotation)

                    return (
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 (