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

194
Visualizações
Keep Links Pinned to canvas for react-force-graph-2d

I’m trying to dynamically update react-force-graph-2d, but I don’t want the graph to move like shown in the example here:

https://vasturiano.github.io/react-force-graph/example/dynamic/

Instead, I want the nodes and links to stay in a fixed position once they’re added instead of moving around. Essentially, once a node/link is added, I want it to remain in place unless the user moves the node themselves.

I’ve been able to fix the nodes to canvas using:

node.fx = node.x;
node.fy = node.y;

and have not noticed node flashing, but have not been able to fix the links to the canvas which results in a flash everytime the interval inside the useEffect hook gets called.

When the data rerenders, the links start flashing, and I’m trying to avoid this behavior. The solution used for nodes doesn’t work because link.fx and link.fy are undefined, so I’m wondering how to keep the links in place. Any help would be greatly appreciated.

 <ForceGraph2D
    ref={fgRef}
    graphData={data}
    nodeCanvasObject={
      // fix node to canvas
      node.fx = node.x;
      node.fy = node.y;
    }
    nodeCanvasObjectMode={() => "after"}
    linkCanvasObject={
        // how can I fix the links to the canvas?
    }
    linkCanvasObjectMode={() => "after"}
/>

Expected behavior Links stay fixed to canvas when updated and don't flash.

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