score:2

please upgrade npm package, its worked for me

npm i chart.js@2.9.4

score:17

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
}

score:53

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);
    

Related Query

More Query from same tag