Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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()
})
}
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()
})
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
}
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()
})
({ 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 }
}
),
({ 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 }
}
),
({ 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 }
}
),
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()
})
}