与here相同的问题,但我得到以下错误:Type 'keyof ChartTypeRegistry' is not assignable to type '"doughnut"'.
当我尝试实现它。
查看图表配置文档并发现
interface ChartTypeRegistry {
...
pie: {
chartOptions: PieControllerChartOptions;
datasetOptions: PieControllerDatasetOptions;
defaultDataPoint: PieDataPoint;
metaExtensions: PieMetaExtensions;
parsedDataType: number;
scales: keyof CartesianScaleTypeRegistry;
};
doughnut: {
chartOptions: DoughnutControllerChartOptions;
datasetOptions: DoughnutControllerDatasetOptions;
defaultDataPoint: DoughnutDataPoint;
metaExtensions: DoughnutMetaExtensions;
parsedDataType: number;
scales: keyof CartesianScaleTypeRegistry;
};
图中有一个切口,但是
public doughnutChartOptions: ChartConfiguration['options'] = {
doughnut: {
datasets: {
/can't access cutout here /
}
}
...
};
但不知道如何访问chartOptions。我使用的是最新版本的ng 2-charts和chart.js chart.js@4.0.1 ng 2-charts@4.1.1任何帮助都将不胜感激!
1条答案
按热度按时间qeeaahzv1#
将图表类型添加到选项以正确Map: