Home > other >  I can't import ChartsModule
I can't import ChartsModule

Time:05-06

I can't import ChartsModule in my app.module.ts in my angular 12 project. I tried to import it but it only shows NgChartsModule, because of it some functions of the chart are not working. Here are some error that I recived.

./src/app/reports/reports.component.ts:42:8-33 - Error: export 'monkeyPatchChartJsTooltip' (imported as 'monkeyPatchChartJsTooltip') was not found in 'ng2-charts' (possible exports: BaseChartDirective, NgChartsConfiguration, NgChartsModule, ThemeService, baseColors)

./src/app/reports/reports.component.ts:43:8-32 - Error: export 'monkeyPatchChartJsLegend' (imported as 'monkeyPatchChartJsLegend') was not found in 'ng2-charts' (possible exports: BaseChartDirective, NgChartsConfiguration, NgChartsModule, ThemeService, baseColors)

Error: src/app/reports/reports.component.ts:4:10 - error TS2305: Module '"ng2-charts"' has no exported member 'SingleDataSet'.

4 import { SingleDataSet, Label, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from 'ng2-charts';
           ~~~~~~~~~~~~~


Error: src/app/reports/reports.component.ts:4:25 - error TS2305: Module '"ng2-charts"' has no exported member 'Label'.

4 import { SingleDataSet, Label, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from 'ng2-charts';
                          ~~~~~


Error: src/app/reports/reports.component.ts:4:32 - error TS2305: Module '"ng2-charts"' has no exported member 'monkeyPatchChartJsLegend'.

4 import { SingleDataSet, Label, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from 'ng2-charts';
                                 ~~~~~~~~~~~~~~~~~~~~~~~~


Error: src/app/reports/reports.component.ts:4:58 - error TS2305: Module '"ng2-charts"' has no exported member 'monkeyPatchChartJsTooltip'.

4 import { SingleDataSet, Label, monkeyPatchChartJsLegend, monkeyPatchChartJsTooltip } from 'ng2-charts';
                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~

I tried to search from the documentation but it mentions nothing about this kind of error. Here is the link of the documentation that I copied for this

https://stackblitz.com/edit/ng2-charts-pie-template?file=src/app/app.component.ts

and

https://www.npmjs.com/package/ng2-charts

I did all the steps mention here btw

CodePudding user response:

Please check your "ChartsModule" Version in the package.json file and check whether it is supporting that or not. It might get updated.

If you wanted to use that code then you might need to downgrade or upgrade your version.

To update the version you can copy and paste the version number to your package.json file and run "npm i" to update it.

CodePudding user response:

Try using the same version of chart.js that was used, Put the below version in the package.json and run npm i , might help

"chart.js": "^2.9.3"

  • Related