Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
points.forEach(point => {
ctx.fillStyle = point.color
ctx.beginPath()
ctx.arc(point.x, point.y, pointSize / 2, 0, 2 * Math.PI)
ctx.fill()
if (pointBorderWidth > 0) {
ctx.strokeStyle = point.borderColor
ctx.lineWidth = pointBorderWidth
ctx.stroke()
}
})
}
if (layer === 'mesh' && debugMesh === true) {
renderVoronoiToCanvas(ctx, voronoi)
if (currentPoint) {
renderVoronoiCellToCanvas(ctx, voronoi, currentPoint.index)
}
}
if (layer === 'legends') {
const legendData = series
.map(serie => ({
id: serie.id,
label: serie.id,
color: serie.color,
}))
.reverse()
legends.forEach(legend => {
renderLegendToCanvas(ctx, {
theme,
})
}
if (layer === 'nodes') {
nodes.forEach(node => {
renderNode(ctx, {
node,
getBorderWidth,
getBorderColor,
})
})
}
if (layer === 'mesh' && debugMesh === true) {
renderVoronoiToCanvas(ctx, voronoi)
if (currentNode) {
renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
}
}
if (layer === 'annotations') {
renderAnnotationsToCanvas(ctx, {
annotations: computedAnnotations,
theme,
})
}
if (typeof layer === 'function') {
layer(ctx, {
nodes,
innerWidth,
yScale,
width: innerWidth,
height: innerHeight,
top: axisTop,
right: axisRight,
bottom: axisBottom,
left: axisLeft,
theme,
})
} else if (layer === 'nodes') {
nodes.forEach(node => {
renderNode(ctx, node)
})
} else if (layer === 'mesh') {
if (debugMesh === true) {
renderVoronoiToCanvas(ctx, voronoi)
if (currentNode) {
renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
}
}
} else if (layer === 'legends') {
legends.forEach(legend => {
renderLegendToCanvas(ctx, {
...legend,
data: legendData,
containerWidth: innerWidth,
containerHeight: innerHeight,
theme,
})
})
} else if (typeof layer === 'function') {
layer(ctx, customLayerProps)