Reputation: 133
I have a trouble importing chart.js into my application, while in version 2+ it was simple as:
import Chartjs from 'chart.js';
Now this doesn't work anymore.
Attempted import error: 'chart.js' does not contain a default export (imported as 'Chartjs').
Upvotes: 2
Views: 4245
Reputation: 133
Ok, I found the answer. You have to import everything by parts and then register it.
import { Chart, PieController, ArcElement, Legend, Tooltip, Title } from 'chart.js';
Chart.register(PieController, ArcElement, Title, Legend, Tooltip);
Upvotes: -1
Reputation: 188
I guess you have to import it like this:
import { Chart } from 'chart.js';
More information are available on: https://www.chartjs.org/docs/latest/getting-started/integration.html
Upvotes: 2