chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const bandajdust = 0.8
const tooltip = d3.select("body").append("div")
.attr("class", "svg-tooltip")
.style("position", "absolute")
.style("visibility", "hidden");
const bars = svg.append("g")
.attr("fill-opacity", 0.5)
.attr("class", "bars")
.selectAll("rect")
.data(data)
.join("rect")
.attr("x", (d, i) => x(i))
.attr("y", d => y(d.upper_bound))
.attr("ry",x.bandwidth()*bandajdust/2)
.attr("xy",x.bandwidth()*bandajdust/2)
.attr("height", d => y(d.lower_bound)-y(d.upper_bound))
.attr("width", x.bandwidth()*bandajdust)
.attr("fill", d => (d.ml > 1) ? negativeColor : positiveColor)
const circles = svg.append("g")
.selectAll("circle")
.data(data)
.join("circle")
.attr("cx", (d, i) => x(i)+x.bandwidth()*bandajdust/2)
.attr("cy", d => y(d.ml))
.attr("fill", "white")
.attr("stroke", "#ccc")
.attr("r", x.bandwidth()*bandajdust/2)
const states = svg.append("g")
.selectAll("text")
.data(data)
.join("text")
.text(d => d.state)
.attr("transform", (d,i) => "translate("+x(i)+" "+y(d.ml)+")")
.attr("text-anchor", "start")
.style("font", "12px sans-serif")
.attr("dx", ".30em")
.attr("dy", ".30em")
.attr("fill", d => (d.ml > 1) ? negativeColor: positiveColor)
.on("mouseover", function(d){
tooltip
.style("visibility", "visible")
.text(`${siglas[d.state]} ${d.ml}`)
})
.on("mousemove", function(){
tooltip.style("top", (d3.event.pageY-10)+"px").style("left",(d3.event.pageX+10)+"px");
})
.on("mouseout", function(){
tooltip.style("visibility", "hidden");
});
svg.append("g")
.call(yAxis);
return svg.node();
}