Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Chart.js core.js:6162 ERROR Error: "line" is not a registered controller

 const gainContext = this.gainRef.nativeElement.getContext('2d')
  gainContext.canvas.height = '300px'

  new Chart(gainContext, createChartConfig(gainConfig))


function createChartConfig({type, labels, data, label, color}: ChartConfig): ChartConfiguration<"line">{

  console.log('3 Chart.defaults', Chart.defaults)

  return {
type: "line",
data: {
  labels,
  datasets: [
    {
      label,
      data,
      borderColor: color,
      stepped: false,
      fill: false
    }
  ]
}
  }

This is not working: It not recognize the type property as it must in official documentation.

let myChart = new Chart(gainContext, { type: 'line',

What I do wrong?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

We can do this in three ways

  1. By importing:

    import { Chart, registerables } from 'chart.js';
    

    and then register all the coponents

    Chart.register(...registerables);
    
  2. finally there is an separate path to do just the above for you, in one line:

    import Chart from 'chart.js/auto';
    
  3. By importing and registering the required part as commented by @Tatyana Molchanova

    import { Chart, ChartConfiguration, LineController, LineElement, PointElement, LinearScale, Title} from 'chart.js' 
    

    and then register it in component before instantiating new Chart

    Chart.register(LineController, LineElement, PointElement, LinearScale, Title);
    
over 4 years ago · Santiago Trujillo Relatório

0

Angular 12 here. Gaurev's answer worked for me. I had to use:

import { Chart, registerables } from 'chart.js';
export class ChartTest {

  constructor() {
    Chart.register(...registerables);
  }

  // methods to actually make the chart per documentation
}
over 4 years ago · Santiago Trujillo Relatório

0

please upgrade npm package, its worked for me

npm i chart.js@2.9.4
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda