chart = {
const svg = d3
.create("svg")
.attr("viewBox", [-50, 0, width, 11 * pick_artist.length + margin.bottom]);
svg
.append("g")
.attr("fill", "steelblue")
.selectAll("rect")
.data(pick_artist)
.join(enter => enter.append('rect'))
.attr("x", d => xScale(rank_extent))
.attr("y", d => yScale(d.country))
.attr("width", d => xScale(d.rank) - xScale(0))
.attr("height", yScale.bandwidth());
svg
.append("g")
.attr("transform", `translate(0, ${height - margin.bottom})`)
.call(xAxis);
svg.append("g").call(yAxis);
svg
.append("text")
.attr("class", "text")
.attr("transform", `translate(${width / 2},${height - margin.bottom + 40})`)
.style("text-anchor", "middle")
.style("font-size", "18px")
.text("Ranking");
svg
.append("text")
.attr("class", "text")
.attr(
"transform",
`rotate(-90), translate(${-width / 2},${margin.left - 100})`
)
.style("text-anchor", "middle")
.style("font-size", "18px")
.text("Countries");
svg
.append("text")
.attr("class", "text")
.attr("transform", `translate(${width / 2}, ${margin.top - 30})`)
.style("text-anchor", "middle")
.style("font-size", "30px")
.style("font-weight", "bold")
.text("Artists appears on Countries");
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();
}