canvas = {
const context = DOM.context2d(width, height);
const opacityPostfix = (k = 2) =>
("0" + parseInt((255 / repeat) * k).toString(16)).slice(-2);
var pathPoints;
{
context.canvas.style.background = "hsl(216deg 50% 13%)";
}
{
function draw(pts, yOffset = 0, radius = 5, k = 2) {
const maxV = d3.max(pts, (e) => e.v);
pts.map((pts) => {
const { x, y, v } = pts;
(context.fillStyle =
d3.color(colorMap(v / maxV)).hex() + opacityPostfix(k)),
context.beginPath(),
context.arc(
constants.xScale(x),
constants.yScale(y + yOffset),
radius,
0,
Math.PI * 2
),
context.fill();
});
}
const radius = width / constants.numX / 3;
if (showGridToggle) {
draw(data.points, 0, radius / 2, 3);
}
pathList.map((path) => {
pathPoints = path.map((str) => {
return data.map[str];
});
draw(pathPoints, 0, radius);
});
}
{
context.strokeStyle = "#ff0000" + "80";
context.lineWidth = 3;
context.beginPath();
context.moveTo(constants.xScale(0), constants.yScale(0));
const r = 1,
n = 100;
const thetaScale = d3
.scaleLinear()
.domain([0, n * 2])
.range([0, Math.PI * 2]);
var x, y, theta;
for (let i = 0; i < n + 1; ++i) {
theta = thetaScale(i);
x = (r * (theta - Math.sin(theta))) / Math.PI;
y = (r * (1 - Math.cos(theta))) / 2;
context.lineTo(constants.xScale(x), constants.yScale(y));
}
context.stroke();
}
return context.canvas;
}