chart = {
const svg = d3
.create("svg")
.attr("height", 500)
.attr("width", width);
svg
.selectAll(".artist")
.data(by_artist, d => d.key)
.join("rect")
.on("mouseenter", function(d) {
let text = "";
d.values.forEach(dd => (text = text + " " + dd.geo));
const pos = d3.mouse(this);
tip.attr("transform", `translate(${pos[0]}, ${pos[1] - 10})`);
tipText.text(d.key + " " + d.values.length + ' countries');
const { x, y, width: w, height: h } = tipText.node().getBBox();
tipRect
.attr("width", w)
.attr("height", h)
.attr("x", x)
.attr("y", y)
.attr("fill", "rgb(0, 255, 245)");
})
.on("mousemove", function(d) {
const pos = d3.mouse(this);
tip.attr("transform", `translate(${pos[0]}, ${pos[1] - 10})`);
})
.on("mouseout", function(d) {
})
.call(drawRect);
const tip = svg.append("g").style("pointer-events", "none");
const tipRect = tip.append("rect");
const tipText = tip.append("text").style("text-anchor", "middle");
return svg.node();
}