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

256
Views
D3: Comprender por qué el texto no se muestra en el gráfico

En primer lugar, sé que ha habido preguntas similares aquí, pero todavía parece que necesito un poco de ayuda para entender por qué lo que he hecho hasta ahora no funciona.

Estoy trabajando en este código y quiero agregar algo de texto en cada nodo. Las líneas de código con las que me he metido son las siguientes.

cambié esto

 const node = svg.append('g') .attr('fill', nodeFill) .attr('stroke', nodeStroke) .attr('stroke-opacity', nodeStrokeOpacity) .attr('stroke-width', nodeStrokeWidth) .selectAll('circle') .data(nodes) .join('circle') .attr('r', nodeRadius) .call(drag(simulation));

a

 const node = svg.append('g') .attr('fill', nodeFill) .attr('stroke', nodeStroke) .attr('stroke-opacity', nodeStrokeOpacity) .attr('stroke-width', nodeStrokeWidth) .selectAll('g') .data(nodes) .join('g') .call(drag(simulation)); node.append('circle') .attr('r', nodeRadius); node .append('text') .text('example text') .attr('fill', 'none') .attr('stroke', 'white') .attr('stroke-width', 3);

y agregó la siguiente línea de código a esta sección

 function ticked(): any { link .attr('x1', d => d.source.x) .attr('y1', d => d.source.y) .attr('x2', d => d.target.x) .attr('y2', d => d.target.y); node .attr('cx', d => dx) .attr('cy', d => dy); // Added this line node.attr('transform', d => `translate(${dx},${dy})`); }

pero está rompiendo las cosas. Ahora se representa el texto pero no los círculos.

¿Qué estoy haciendo mal? ¡Cualquier ayuda sería apreciada!

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!