14๐
โ
FYI, ChartTypeRegistry
was introduced by chart.js in version 3.0 and later.
Hence, I conclude that you installed chart.js that is incompatible with the latest ng2-chart (version 2.4.2).
To reproduce the same issue, I have installed chart.js version 3.4 as the link below:
Sample project (chart.js v 3.4)
Solution (chart.js version before 3.0)
According to ng2-charts โ npm,
You need to install chart.js with:
npm install chart.js@2.9.4
OR
npm install @types/chart.js@2.9.33
Sample solution (chart.js v 2.9.4)
Solution (chart.js version 3.0 and later)
Specify lineChartType
with ChartType
type.
import { ChartType } from 'chart.js';
public lineChartType: ChartType = "line";
0๐
There is example Chart.js from 4.0.1 + version, like I resolved
import { Chart, ChartType } from 'chart.js/auto';
chartTypes: {[key: string]: ChartType} = {
line: 'line',
bar: 'bar'
};
//...code
lineChartType = this.lineChartType['line'];
Source:stackexchange.com