viz = {
let canvas = d3
.create('canvas')
.attr("width", columns)
.attr('height', rows);
let context = canvas.node().getContext('2d');
let colorScale = d3.scaleLinear().domain([0, rows]);
let drag = d3
.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
canvas.call(drag);
function dragstarted(event, d) {}
function dragged(event, d) {
let mouseX = d3.mouse(this)[0];
let mouseY = d3.mouse(this)[1];
let deathIndex = mouseY * columns + mouseX;
var sameCountry = coordinateDataset.filter(function(death) {
return coordinateDataset[deathIndex].country == death.country;
});
sameCountry.forEach(function(d) {
context.fillStyle = d3.interpolateBlues(colorScale(d.y));
context.globalAlpha = .1;
context.fillRect(d.x, d.y, 1, 1);
});
}
function dragended(event, d) {
clear();
}
return canvas.node();
}