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

281
Views
D3 agrega texto a círculos en una línea que no funciona correctamente

Creé algunos gráficos de líneas en d3. Después de eso, agregué algunos círculos a cada tercer elemento de la línea. Ahora quiero agregar texto a esos círculos.

 // created a circle variable var circles=g2 .append("g") .attr("id","symbols-b") .selectAll("circles") .data(slicesCircle) .enter() .append("g") circles.style("fill", function(d){ return d.color=color(d.id); }) //append circles circles .selectAll("circle") .data(function (d){return d.values}) .enter() .filter((d,i)=>(i%3==0) && i>0) //to attach every 3rd datapoint .append("circle") .attr("r", 7.5) .attr("cx", function(d,i) {return xScale(d.date);}) .attr("cy", function(d,i) {return yScale(d.measurement);}) // Using the circle variable again to append text circles .selectAll("circle") .data(function (d){return d.values}) .enter() .filter((d,i)=>(i%3==0) && i>0) .append("text") .attr("x",function(d,i) {return xScale(d.date);}) .attr("y",function(d,i) {return yScale(d.measurement);}) .text("0") // testing with 0 .style("stroke","white") .style("font-size","12px")

Pero cuando estoy ejecutando el código, los últimos 2 bloques, a pesar de ser los mismos, generan salidas diferentes. Los círculos se generan muy bien, pero cuando agrego texto al mismo bloque de código, comienza más tarde. series de tiempo . Incapaz de entender por qué..

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Se cambió .selectAll("círculo") a .selelctAll("texto") para seleccionar cada marcador de posición de texto en lugar de círculo. Trabajó

 // Using the circle variable again to append text circles .selectAll("circle") .data(function (d){return d.values}) .enter() .filter((d,i)=>(i%3==0) && i>0) .append("text") .attr("x",function(d,i) {return xScale(d.date);}) .attr("y",function(d,i) {return yScale(d.measurement);}) .text("0") // testing with 0 .style("stroke","white") .style("font-size","12px")
 // Using the circle variable again to append text circles .selectAll("text") .data(function (d){return d.values}) .enter() .filter((d,i)=>(i%3==0) && i>0) .append("text") .attr("x",function(d,i) {return xScale(d.date);}) .attr("y",function(d,i) {return yScale(d.measurement);}) .text("0") // testing with 0 .style("stroke","white") .style("font-size","12px")
about 4 years ago · Juan Pablo Isaza Report
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!