I have a Stackblitz here - https://stackblitz.com/edit/ng-graph-tooltip?file=src%2Fapp%2Fapp.component.html
I have a mouseover event when hovering over the bars
I trying to get the width and x pos of the bar when over it so I can position the tooltip
How can I get the width and x pos when over the bar.
Is this a problem with 'this' in Angular
d3.selectAll('.bar-opacity').on("mouseover", (d:any) => {
const xPos = d3.select(this).attr('x');
const rectWidth = d3.select(this).attr('width');
console.log(xPos)
let html = ''
html += '<div class="">'+d.color+'</div>'
html += '<div class="tooltip-block">'+d.day+'</div>'
d3.select('.chart-tooltip')
.style("left", d3.event.pageX + 5 + "px")
.style("top", d3.event.pageY - 25 + "px")
.html(html)
d3.select('.chart-tooltip').style("display", null)
})
.on("mouseout", ()=>{
d3.select('.chart-tooltip').style("display", "none")
.transition()
.duration(500)
})