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

109
Views
D3 llene rect específico de muchos

Estoy tratando sin suerte de llenar un rect específico de muchos en D3 con una función dentro del atributo de estilo, pero solo llena todos los rect con #fff (blanco).

Quiero llenar un rect si el obj de ese rect (de los datos) está dentro de la matriz monitor.details.

 .style("fill", function (d) { let obj = monitor.details.filter(item => item.host == d.ip && item.port == d.port && item.status == 1); if(Object.values(obj).length > 0) return "#fff" else return "#888" })

código cortado de:

 svg .selectAll() .data(data, function (d, i) { return d.host + ":" + d.port; }) .enter() .append("rect") .attr("x", function (d) { return x(d.host); }) .attr("y", function (d) { return y(d.port); }) .attr("width", x.bandwidth()) .attr("height", y.bandwidth()) .style("fill", function (d) { let obj = monitor.details.filter(item => item.host == d.ip && item.port == d.port && item.status == 1); if(Object.values(obj).length > 0) return "#fff" else return "#888" })

Aún más interesante, encontré en DOM el elemento de ese rect y, de acuerdo con DOM, el relleno es el color real que elegí (en la imagen a continuación, elijo el color rojo), pero no se refleja en la pantalla. ingrese la descripción de la imagen aquí

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!