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

196
Views
¿Por qué mi D3 svg no se muestra en la pantalla?

¡Aquí está mi código! Estoy usando la biblioteca angular y d3 para hacer una forma simple, pero no aparece nada en la pantalla.

Archivo TS de gráfico circular:

 @Component({ selector: 'pie-chart', templateUrl: './pie-chart.component.html', styleUrls: ['./pie-chart.component.css'], }) export class PieChartComponent { svg = d3 .select('#canvasarea') .append('svg') .attr('width', 400) .attr('height', 100); circle = this.svg .append('circle') .attr('cx', 200) .attr('cy', 200) .attr('r', 50) .attr('fill', 'blue'); }

Archivo HTML de gráfico circular:

 <div id="canvasarea"></div>

aplicación-componente.html:

 <pie-chart></pie-chart>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Como se mencionó anteriormente, de hecho, debe agregar un radio con el atributo r. Y también necesita que la vista se haya renderizado en su componente angular para agregar el svg y realizar la operación en él

 import { AfterViewInit, Component } from '@angular/core'; import * as d3 from 'd3'; @Component({ selector: 'pie-chart', templateUrl: './pie-chart.component.html', styleUrls: ['./pie-chart.component.css'], }) export class PieChartComponent implements AfterViewInit { public svg: any = null; constructor() { } ngAfterViewInit(): void { this.svg = d3 .select('#canvasarea') .append('svg') .attr('width', 400) .attr('height', 100); this.svg .append('circle') .attr('cx', 50) .attr('cy', 50) .attr('r', 20) .style('fill', 'blue'); } }
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!