We can do this in three ways
- By importing:
import { Chart, registerables } from 'chart.js';
and then register all the coponents
Chart.register(...registerables);
- finally there is an separate path to do just the above for you, in one line:
import Chart from 'chart.js/auto';
- 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);