How to use the @nivo/core.degreesToRadians 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 / treemap / src / TreeMapCanvas.js View on Github external
.forEach(node => {
                    const labelTextColor = getLabelTextColor(node)

                    const rotate = orientLabel && node.height > node.width

                    this.ctx.save()
                    this.ctx.translate(node.x + node.width / 2, node.y + node.height / 2)
                    this.ctx.rotate(degreesToRadians(rotate ? -90 : 0))

                    this.ctx.fillStyle = labelTextColor
                    this.ctx.fillText(node.label, 0, 0)

                    this.ctx.restore()
                })
        }
github plouc / nivo / packages / calendar / src / CalendarCanvas.js View on Github external
monthLegends.forEach(month => {
            this.ctx.save()
            this.ctx.translate(month.x, month.y)
            this.ctx.rotate(degreesToRadians(month.rotation))
            this.ctx.fillText(monthLegend(month.year, month.month, month.date), 0, 0)
            this.ctx.restore()
        })
github plouc / nivo / packages / annotations / src / compute.js View on Github external
if (isPlainObject(noteY)) {
        if (noteY.abs !== undefined) {
            computedNoteY = noteY.abs
        }
    } else {
        computedNoteY = y + noteY
    }

    let computedX = x
    let computedY = y

    const angle = getLinkAngle(x, y, computedNoteX, computedNoteY)

    if (type === 'circle') {
        const position = positionFromAngle(degreesToRadians(angle), size / 2)
        computedX += position.x
        computedY += position.y
    }

    if (type === 'rect') {
        const eighth = Math.round((angle + 90) / 45) % 8
        if (eighth === 0) {
            computedY -= height / 2
        }
        if (eighth === 1) {
            computedX += width / 2
            computedY -= height / 2
        }
        if (eighth === 2) {
            computedX += width / 2
        }
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 / pie / src / PieLayout.js View on Github external
({ sortByValue, padAngle, startAngle, endAngle }) => {
                const pie = d3Pie()
                    .value(d => d.value)
                    .padAngle(degreesToRadians(padAngle))
                    .startAngle(degreesToRadians(startAngle))
                    .endAngle(degreesToRadians(endAngle))

                if (sortByValue !== true) pie.sortValues(null)

                return { pie }
            }
        ),
github plouc / nivo / packages / pie / src / PieLayout.js View on Github external
({ sortByValue, padAngle, startAngle, endAngle }) => {
                const pie = d3Pie()
                    .value(d => d.value)
                    .padAngle(degreesToRadians(padAngle))
                    .startAngle(degreesToRadians(startAngle))
                    .endAngle(degreesToRadians(endAngle))

                if (sortByValue !== true) pie.sortValues(null)

                return { pie }
            }
        ),
github plouc / nivo / packages / pie / src / PieLayout.js View on Github external
({ sortByValue, padAngle, startAngle, endAngle }) => {
                const pie = d3Pie()
                    .value(d => d.value)
                    .padAngle(degreesToRadians(padAngle))
                    .startAngle(degreesToRadians(startAngle))
                    .endAngle(degreesToRadians(endAngle))

                if (sortByValue !== true) pie.sortValues(null)

                return { pie }
            }
        ),
github plouc / nivo / packages / nivo-treemap / src / TreeMapCanvas.js View on Github external
nodes.filter(({ label }) => label !== undefined).forEach(node => {
                const labelTextColor = getLabelTextColor(node)

                const rotate = orientLabel && node.height > node.width

                this.ctx.save()
                this.ctx.translate(node.x + node.width / 2, node.y + node.height / 2)
                this.ctx.rotate(degreesToRadians(rotate ? -90 : 0))

                this.ctx.fillStyle = labelTextColor
                this.ctx.fillText(node.label, 0, 0)

                this.ctx.restore()
            })
        }