chart = {
const svg = d3.select(DOM.svg(width, height))
.attr("viewBox", `${-width / 2} ${-height / 2} ${width} ${height}`)
.style("width", "100%")
.style("height", "auto")
.style("font", "10px sans-serif");
let chartNum = 0;
svg.append("g")
.selectAll("g")
.data(d3.stack().keys(data.columns.slice(2))(data))
.join("g")
.selectAll("path")
.data(d => d)
.join("path")
.attr("fill", (d, i) => {
if(0 <= i && i < 4) {
return ["#c89c55", "#e1af60", "#fac36b"][chartNum]
} else if (4 <= i && i < 8) {
return ["#309022", "#36a226", "#3cb52b", "#4fbc40"][chartNum]
} else if (8 <= i && i< 13) {
return ["#981c31", "#ab2037", "#be243e", "#c43951"][chartNum]
} else {
return ["#0a5478", "#0b5f87", "#0d6a96", "#2578a0"][i === 16 ? chartNum++ : chartNum]
}
})
.attr("d", arc)
.on("click", function(d){return tooltip.style("visibility", "visible")})
.append('title')
.text(function(d){
return d;
})
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
let tooltip = svg.append("g").style("visibility", "hidden")
tooltip.append("rect")
.attr("width", 300)
.attr("height", 400)
.attr("stroke", "#000")
.attr('stroke', 'black')
.attr('fill', '#69a3b2')
.attr("x", -150)
.attr("y", -100)
.on("click", (d) => tooltip.style("visibility", "hidden"))
tooltip.append("text").attr("y", -90).attr("x",-140).text("demo text")
return svg.node();
}