barras = {
const width = 600
const height = 1950
let colorScale = d3.scaleLinear()
.domain([40, 90])
.range(["Red","Blue"]);
countries.sort((a, b) => a.life_expect - b.life_expect);
const svg = d3.select(DOM.svg(width, height));
svg.append("text")
.attr("x", width / 2)
.attr("y", 30)
.attr("text-anchor", "middle")
.style("font-size", "24px")
.style("font-family", "Arial")
.style("font-weight", "bold")
.text("Expectativa de Vida por País");
svg.selectAll('rect')
.data(countries)
.enter()
.append('rect')
.attr('x', 10)
.attr('y', (d, i) => i * 30 + 60)
.attr('height', 20)
.attr('width', (d) => xScale(d.life_expect * 2))
.attr('fill', (d) => colorScale(d.life_expect));
svg.selectAll('text.label')
.data(countries)
.enter()
.append('text')
.attr('class', 'label')
.attr('x', (d) => d.life_expect * 2.2)
.attr('y', (d, i) => i * 30 + 60 + 15)
.text((d) => `${d.country} : ${d.life_expect}`)
.style("font-family", "Arial")
.style("font-size", "14px");
svg.append("g")
.attr("transform", "translate(0," + height + ")" )
.call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}