Reputation: 105
how could i get the tooltip alignment fixed, so that the tooltip shows above the bar
http://jsbin.com/mutirodawa/edit?html,output
bar
.on("mousemove", function(d) {
divTooltip.style("right", d3.event.pageX + 30 + "px");
divTooltip.style("top", d3.event.pageY + 45 + "px");
divTooltip.style("display", "inline-block");
var x = d3.event.pageX,
y = d3.event.pageY
var elements = document.querySelectorAll(':hover');
l = elements.length
l = l - 1
elementData = elements[l].__data__
divTooltip.html(elementData.name + "<br>" + elementData.value);
});
bar
.on("mouseout", function(d) {
divTooltip.style("display", "none");
});
Upvotes: 0
Views: 42
Reputation: 102174
To make the tooltip showing above each bar, I attached the handler to each bar individually:
http://jsbin.com/pixicunasi/1/edit?html,js,output
Upvotes: 1