{
const formatTime = d3.utcFormat("%d/%m/%Y");
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg
.append("g")
.attr("fill", color)
.selectAll("rect")
.data(obitsPerDay100)
.enter()
.append("rect")
.attr("x", (d, i) => x(i))
.attr("y", d => y(d.obits))
.attr("height", d => y(0) - y(d.obits))
.attr("width", x.bandwidth())
.on('mouseover', function(ev, d) {
tooltip
.html(
`<div>Data: ${formatTime(d.date)} </div><div>Óbitos: ${d3.format(
".2f"
)(d.obits)}</div>`
)
.style('visibility', 'visible');
d3.select(this)
.transition()
.attr('fill', hoverColor);
})
.on('mousemove', function(ev, d) {
tooltip
.style('top', 100 + 'px')
.style('left', Math.min(width - 120, ev.pageX + 10) + 'px');
})
.on('mouseout', function(ev, d) {
tooltip.html(``).style('visibility', 'hidden');
d3.select(this)
.transition()
.attr('fill', color);
});
return svg.node();
}