chart2 = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
groupBySelectedCountry.forEach((d,i,e)=> {
console.log("==============")
svg.selectAll(`rect.${i}`)
.data(groupBySelectedCountry.get(i))
.join('rect')
.attr('y', d => yScale(d['col_name']))
.attr('x', xScale(i))
.attr('width', xScale.bandwidth() * 0.95)
.attr('height', yScale.bandwidth())
.attr('fill', d => colorScale(d['rate']))
})
const xAxis = svg.append("g")
.attr("id", "xAxisG")
.attr("transform", `translate(0 ,${margin.top + 20})`)
.call(d3.axisTop(xScale))
.attr("font-size", 5)
.call(g => g.select(".domain")
.remove())
xAxis.selectAll("text")
.attr("transform", `translate(8, 0) rotate(-90)`)
.style("text-anchor", "start")
svg.append("g")
.attr("transform", `translate(${margin.left}, 0)`)
.call(d3.axisLeft(yScale))
.attr("font-size", 5)
.call(g => g.select(".domain")
.remove())
return svg.node();
}