我无法在angular 12项目的app.module.ts
中导入ChartsModule。我试图导入它,但它只显示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
我做了所有的步骤提到这里顺便说一句
2条答案
按热度按时间ffdz8vbo1#
请检查package.json文件中的“ChartsModule”版本,并检查它是否支持该版本。它可能会更新。
如果你想使用这些代码,那么你可能需要降级或升级你的版本。
要更新版本,您可以将版本号复制并粘贴到package.json文件中,然后运行“npm i”进行更新。
ttisahbt2#
尝试使用与使用的chart.js相同的版本,将下面的版本放在package.json中并运行npm i,可能会有所帮助
"chart.js": "^2.9.3"