How to use the @nivo/core.radiansToDegrees 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 / props.js View on Github external
label: PropTypes.string.isRequired,
            fill: PropTypes.string.isRequired,
        })
    ).isRequired,
    */
}

export const PieDefaultProps = {
    sortByValue: false,
    innerRadius: 0,
    padAngle: 0,
    cornerRadius: 0,

    // layout
    startAngle: 0,
    endAngle: radiansToDegrees(Math.PI * 2),
    fit: true,

    // border
    borderWidth: 0,
    borderColor: {
        from: 'color',
        modifiers: [['darker', 1]],
    },

    // radial labels
    enableRadialLabels: true,
    radialLabel: 'id',
    radialLabelsTextColor: { theme: 'labels.text.fill' },
    radialLabelsLinkColor: { theme: 'axis.ticks.line.stroke' },

    // slices labels
github plouc / nivo / packages / nivo-pie / src / props.js View on Github external
label: PropTypes.string.isRequired,
            fill: PropTypes.string.isRequired,
        })
    ).isRequired,
    */
}

export const PieDefaultProps = {
    sortByValue: false,
    innerRadius: 0,
    padAngle: 0,
    cornerRadius: 0,

    // layout
    startAngle: 0,
    endAngle: radiansToDegrees(Math.PI * 2),
    fit: true,

    // border
    borderWidth: 0,
    borderColor: 'inherit:darker(1)',

    // radial labels
    enableRadialLabels: true,
    radialLabel: 'id',
    radialLabelsTextColor: 'theme',
    radialLabelsLinkColor: 'theme',

    // slices labels
    enableSlicesLabels: true,
    sliceLabel: 'value',
    slicesLabelsTextColor: 'theme',
github plouc / nivo / packages / radar / src / RadarGridLabels.js View on Github external
const textAnchorFromAngle = _angle => {
    const angle = radiansToDegrees(_angle) + 90
    if (angle <= 10 || angle >= 350 || (angle >= 170 && angle <= 190)) return 'middle'
    if (angle > 180) return 'end'
    return 'start'
}
github plouc / nivo / packages / pie / src / PieLayout.js View on Github external
arcs: pie(data).map(arc => {
                const angle = Math.abs(arc.endAngle - arc.startAngle)

                return {
                    ...arc,
                    angle,
                    angleDeg: radiansToDegrees(angle),
                }
            }),
        })),
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'
            } else {
                positionC = { x: positionB.x - linkHorizontalLength, y: positionB.y }
                labelPosition = {
                    x: positionB.x - linkHorizontalLength - textXOffset,
                    y: positionB.y,
                }
                textAlign = 'right'
            }
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 / nivo-radar / src / RadarGridLabels.js View on Github external
const textAnchorFromAngle = _angle => {
    const angle = radiansToDegrees(_angle) + 90
    if (angle <= 10 || angle >= 350 || (angle >= 170 && angle <= 190)) return 'middle'
    if (angle > 180) return 'end'
    return 'start'
}
github plouc / nivo / packages / annotations / src / compute.js View on Github external
export const getLinkAngle = (sourceX, sourceY, targetX, targetY) => {
    const angle = Math.atan2(targetY - sourceY, targetX - sourceX)
    return absoluteAngleDegrees(radiansToDegrees(angle))
}