{
const container = d3.select(
html`<div style="position:relative;"><div id="tooltip" style="position: absolute; opacity: 0;"></div></div>`
);
const svg = container.append("svg").attr("viewBox", `0 0 ${700} ${700}`);
svg
.attr("width", 700 + "px")
.attr("height", 700 + "px");
svg.append('div').attr('id', 'tooltip').attr('style', 'position: absolute; opacity: 0;');
svg.selectAll('rect')
.data(data)
.enter()
.append('rect')
.attr('x', function(d) { return d.x * side })
.attr('y', function(d) { return 700 - side - d.y * side })
.attr('height', side)
.attr('width', side)
.attr('fill', function(d) { return magma(d.z) })
.on('mouseover', function(d, i) {
d3.select('#tooltip').style('opacity', 1).text(`(${i.x}, ${i.y}) = ${i.z}`)
})
.on('mouseout', function() {
d3.select('#tooltip').style('opacity', 0)
})
.on('mousemove', function() {
d3.select('#tooltip').style('left', (d3.event.pageX+10) + 'px').style('top', (d3.event.pageY+10) + 'px')
})
return container.node();
}