我不能在我的ChartsModule 12项目的app.module.ts
中导入app.module.ts
。我试图导入它,但它只显示了NgChartsModule,因为它使图表中的一些功能无法工作。以下是我收到的一些错误。
./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';
~~~~~~~~~~~~~~~~~~~~~~~~~
我试着从文档中搜索,但是它没有提到这种错误。以下是我为此复制的文档的链接
https://stackblitz.com/edit/ng2-charts-pie-template?file=src%2Fapp%2Fapp.component.ts
和
https://www.npmjs.com/package/ng2-charts
我做了这里提到的所有步骤
发布于 2022-05-06 09:21:48
请检查您的"ChartsModule“版本的package.json文件,并检查它是否支持这一点。它可能会更新。
如果您想使用该代码,那么您可能需要降级或升级您的版本。
要更新版本,可以将版本号复制并粘贴到您的package.json文件中,并运行"npm i“来更新它。
发布于 2022-05-06 09:53:41
尝试使用使用的相同版本的chart.js,将下面的版本放在package.json中并运行npm i,可能会有所帮助。
"chart.js": "^2.9.3"
https://stackoverflow.com/questions/72137524
复制相似问题