[Chartjs]-Core.js:4197 ERROR TypeError: chart_js__WEBPACK_IMPORTED_MODULE_2__ is not a constructor

40๐Ÿ‘

โœ…

High probability primeng still only works with v2 of chart.js since v3 just released this month and had some breaking changes.

Downgrading chart.js to version 2.9.4 should resolve your issue

0๐Ÿ‘

Change:

    import chart from 'chart.js' 
    

To:

    import {chart} from 'chart.js'

0๐Ÿ‘

I solved the issue by updating chart.js to 4.4.0 with latest version of ng2-charts

-1๐Ÿ‘

Cahnge

import Chart from 'chart.js'

into

import { Chart, registerables } from 'chart.js'; 
import 'chartjs-adapter-moment'; // or another adapter to avoid moment
Chart.register(...registerables);

from here.

Leave a comment