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

148
Visualizações
Updating data using D3.js and creating new graphical elements only works when the array of data is shortened

I have an update() function that runs initially and displays all the data by creating some circles using the distance, angle, and colour. The initial data is an array of objects. The structure is shown below.

[
{
  Category: {string}
  SubCategory: {string}
  Technology: {string}
  Distance: {string | int} 0 - 100
  Angle: {string | int} 0 - 100
  Colour: {string}
  Description: {string}
 },
...
]

The end result is to have some checkbox filters available and to be able to hide and show certain categories. For testing purposes, I have created a few buttons in my application to help do this. There is a global variable called filterArray that initially contains all Category names as strings.

One of the buttons updates this array to contain 2 Category names. One of the buttons updates this array to contain 3 Category names. The last button is what I'm using to update the circles. This last button finds all the circles and removes them and then the update function is run again with the updated filterArray to display the updated list of circles.

The issue that occurs is if you click the 3 Category names button and then click the update button, it displays the correct circles. If you then click the 2 Category names button and click the update button it displays the correct circles. If you then click the 3 Category names button again and click the update button it still only shows 2 categories of circles for some reason.

The application can be viewed over here: https://o4buh.csb.app/

The code for the application can be viewed here: https://codesandbox.io/s/d3-tech-impact-magic-quadrant-o4buh?file=/src/index.js

Any insight or advice would be very much appreciated. Thank you.

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