我正在使用Angular 6,并尝试更改我刚刚用chart.js创建的甜甜圈图表的背景色。
https://www.js-tutorials.com/angularjs-tutorial/angular-6-chart-tutorial-using-chart-js/
但是,无论我如何尝试更改背景颜色,无论是以该示例中所示的方式还是其他方式,这些颜色始终是库提供的相同默认颜色。
组件.html:
<canvas baseChart
[data]="doughnutChartData"
[labels]="doughnutChartLabels"
[chartType]="doughnutChartType"
[options]="doughnutChartOptions"
(chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
public doughnutChartLabels: string[] = ['Running', 'Paused', 'Stopped'];
public doughnutChartData: number[] = [this.activeProducers, this.pausedProducers, this.invalidProducers];
public doughnutChartType = 'doughnut';
public doughnutChartOptions: any = {
backgroundColor: [
'Red',
'Yellow',
'Blue',
],
responsive: false,
};
我想要的颜色是:
https://stackblitz.com/edit/angular-ctydcu