plotDataCanvas = () => {
const canvas = document.getElementById("canvas"),
width = 800,
height = 600,
xScale = d3.scaleLinear().domain([0, 1]).range([0, width]).nice(),
yScale = d3.scaleLinear().domain([1, 0]).range([0, height]).nice();
canvas.setAttribute("width", 800);
canvas.setAttribute("height", 600);
const context = canvas.getContext("2d");
const r = 3;
{
context.rect(0, 0, width, height);
context.fillStyle = "white";
context.fill();
}
function drawCategory(category) {
context.beginPath();
data
.filter((d) => d.category === category)
.map((d) => {
context.moveTo(xScale(d.x), yScale(d.y));
context.arc(xScale(d.x), yScale(d.y), r, 0, Math.PI * 2);
});
context.fillStyle = colorScheme[category];
context.fill();
}
for (let category = 0; category < categories; ++category) {
drawCategory(category);
}
}