chart = {
const svg = d3.select(".graph_" + selectedYear).append("svg")
.attr("width", width)
.attr("height", height)
.style("font", "14px Montserrat");
svg
.append("rect")
.attr("width", "100%")
.attr("height", "100%")
.style("fill", "#F5F5F2");
const barwidth = 25
const corner = Math.floor((barwidth/2) + 5)
svg.append("g")
.selectAll("path")
.data(freedom_year)
.join("path")
.attr("fill", d => colorScale(d.region_simple))
.attr("d", (d, i) => roundedRect(
scaleX(0),
(i * 28) + margin.top,
1,
barwidth,
[0, 0, corner, 0]
))
.transition().duration(1000)
.attr("d", (d, i) => roundedRect(
scaleX(0),
(i * 28) + margin.top,
scaleX(d.population) - scaleX(0),
barwidth,
[0, 0, corner, 0]
));
svg.append("g")
.call(xAxis)
.style("font-size", "14px");
svg.append("g")
.call(yAxis)
.style("font-size", "14px");
svg.append("g")
.attr("class", "grid")
.attr("transform", "translate(0," + (height - margin.bottom) + ")")
.attr("stroke-opacity", 0.1)
.call(make_x_gridlines()
.tickSize(-height+margin.top+margin.bottom)
.tickFormat("")
)
svg.append("line")
.attr("x1", margin.left)
.attr("x2", margin.left)
.attr("y1", margin.top - 6)
.attr("y2", height)
.attr("stroke-width", "2px")
.style("stroke", "black")
.style("opacity", 1);
return svg.node();
}