Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda