{
let canvas = d3
.create("canvas")
.style("margin", `${pad}px`)
.attr("width", w)
.attr("height", h);
let ctx = canvas.node().getContext("2d");
data.forEach(function (o) {
ctx.fillStyle = color(o.cylinders);
ctx.fillRect(
x_scale(o.year) + 5,
y_scale(o.accumulation),
x_scale(71) - x_scale(70) - 15,
y_scale(o.height) - y_scale(0) + 3
);
});
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(pad, y_scale(0));
ctx.lineTo(w - pad, y_scale(0));
ctx.stroke();
ctx.fillStyle = "black";
ctx.lineWidth = 0.5;
d3.range(70, 83).forEach(function (x) {
ctx.beginPath();
ctx.moveTo(x_scale(x) + 26, y_scale(0));
ctx.lineTo(x_scale(x) + 26, y_scale(0) + 8);
ctx.stroke();
ctx.fillText(x, x_scale(x) + 20, y_scale(0) + 15);
});
ctx.lineWidth = 1;
d3.range(0, 45, 5).forEach(function (y) {
ctx.beginPath();
ctx.moveTo(pad, y_scale(y));
ctx.lineTo(pad + 5, y_scale(y));
ctx.stroke();
ctx.fillText(y, pad - 15, y_scale(y) + 3);
});
return canvas.node();
}