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

145
Views
No se pueden leer las propiedades de nulo (leyendo 'getContext') en el nuevo EchartsDropdownComponent
import { Component, Input, OnChanges } from "@angular/core"; import { Chart } from 'chart.js' @Component({ selector: "ngx-echarts-dropdown", template: `<canvas id="myChart" width="400" height="400"></canvas>` }) export class EchartsDropdownComponent implements OnChanges { canvas = <HTMLCanvasElement> document.getElementById('myChart'); ctx = this.canvas.getContext('2d'); myChart = new Chart(this.ctx, { data: { datasets: [{ label: 'Scatter Dataset', data: [{ x: -10, y: 0 }, { x: 0, y: 10 }, { x: 10, y: 5 }]] }] }, options: { scales: { xAxes: [{ type: 'linear', position: 'bottom' }] } } });

Estoy tratando de trazar un gráfico de dispersión en Angular 12. Obtengo el siguiente error.

ingrese la descripción de la imagen aquí

Por favor ayúdenme con la solución para el mismo

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

0

Debe colocar el código de creación del gráfico dentro del método ngAfterViewInit y no olvide especificar el type de gráfico.

 export class EchartsDropdownComponent implements AfterViewInit, OnChanges { ngAfterViewInit() { myChart = new Chart('myChart', { type: 'scatter', // <- define the chart type data: { datasets: [{ label: 'Scatter Dataset', ... }
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!