Tell us what’s happening:
Describe your issue in detail here.
The tooltip boxes won’t appear on the screen even if I hover the cursor through the bars. I have tried appending new div as tooltip, I have tried appending new rect as tootip, none of them succeed. The “title” tooltip previously taught in the tutorials couldn’t get the test suite to pass.
I have even tried to watch FlorinPop’s video on how he solved this challenge, referenced his code, still fail. Resorted to copying the EXACT SAME WAY he made his tooltip, and it still fails to appear on my screen.
I have no idea what I did wrong, and no idea what should I change in order to get it to work. I did not find any relevant answered questions on StackOverflow, w3 school, and developer.mozilla.org that could help me (or the ones I found which I thought could help ultimately still failed).
I have grown pretty frustrating at solving this, staring at the code for hours, typing the same codes again and again that still fail, finding typos that aren’t there, making 0 progress for the entire day. I felt like I had to ask the question here.
Any kind of help and responses would be greatly appreciated. Thank you.
Your code so far
d3.select(‘svg’)
.selectAll(‘div’)
.data(json.data)
.enter()
.append(‘div’)
.style(“width”, function(d) { return xScale(d) + “px”; })
.text(function(d) { return d; })
.on(“mouseover”, function(d){tooltip.text(d); return tooltip.style(“visibility”, “visible”);})
.on(“mouseout”, function(){return tooltip.style(“visibility”, “hidden”);});
var tooltip = svg.append('div')
.attr('class','tooltip')
.data(json.data)
.style("position", "absolute")
.style("z-index", "10")
.attr('width', 200)
.attr('height', 200)
.attr('id', 'tooltip')
.attr('data-date', (d) => d[0])
.text("a simple tooltip")
Challenge: Visualize Data with a Bar Chart
Link to the challenge: