f51*_*d89 4 chart.js ng2-charts angular
TypeError: Cannot read property 'legend' of undefined当我尝试以角度显示 ChartJS 图表的示例数据时,我遇到了问题。
我尝试使用不同的示例或图表类型,但它不断抛出此错误。
HTML:
<div class="chartwrapper">
<canvas baseChart class="chart"
[datasets]="arbarChartData"
[labels]="arbarChartLabels"
[options]="arbarChartOptions"
[legend]="arbarChartLegend"
[chartType]="arbarChartType">
</canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
TS:
public arbarChartLabels: Label[] = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
public arbarChartType = 'bar';
public arbarChartLegend = true;
public arbarChartData: ChartDataSets[] = [
{data: [65, 59, 80, 81, 56, 55, 40], label: 'Series A'},
{data: [28, 48, 40, 19, 86, 27, 90], label: 'Series B'}
];
Run Code Online (Sandbox Code Playgroud)
[legend]="arbarChartLegend"从你的 html 中删除。
在TS中,arbarChartOptions: any = { legend: { display: true, labels: { fontColor: 'black' } }
| 归档时间: |
|
| 查看次数: |
8217 次 |
| 最近记录: |