Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
D3.js tooltip not hovering by mouse, only filling entire page

I have some code to create my tooltip, but it is not hovering by the mouse, it takes up the entire width of the page instead. I used an example on the d3.js page.

var tooltip = d3
  .select("#chart")
  .append("div")
  .style("opacity", 0)
  .attr("class", "tooltip")
  .style("background-color", "white")
  .style("border", "solid")
  .style("border-width", "1px")
  .style("border-radius", "5px")
  .style("padding", "10px");

//creating mouseover function
const mouseover = function (event, d) {
  const subgroupName = d3.select(this.parentNode).datum().key;
  const subgroupValue = d.data[subgroupName];
  tooltip
    .html("Status: " + subgroupName + "<br>" + "Count: " + +subgroupValue)
    .style("opacity", 1);
};
const mousemove = function (event, d) {
  tooltip
    .style("transform", "translateY(-55%)")
    .style("left", event.x / 2 + "px")
    .style("top", event.y / 2 - 30 + "px");
};
const mouseleave = function (event, d) {
  tooltip.style("opacity", 0);
};

This is what it looks like when I hover over one of the bars currently. https://i.stack.imgur.com/1nBjC.png

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!