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

231
Visualizações
Unable to add ellipsis on first load d3

I don't know why this happens, when I first load my chart the text can't be ellipsised. But after I went to another page and back again, it worked fine. Is there something wrong with my code.

   tickVertical
        .selectAll('text')
        .each(function () {
          // @ts-ignore
          const self = select(this);
          // @ts-ignore
          let textLength = self.node().getComputedTextLength();
          let text = self.text();

          while (textLength > 50 && text.length > 0) {
            text = text.slice(0, -1);
            self.text(text + '...');
            // @ts-ignore
            textLength = self.node().getComputedTextLength();
          }
        })
        .attr('fill', 'white')
        .attr('font-size', '8px')
        .each(function (d: any) {
          select(this).append('title').text(d);
        });

The bug from each method, after I console.log the text and textlength is 0.

enter image description here

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