我试图在我的2条折线图中(在同一张图表上)放置颜色,但是无论我选择哪种颜色,颜色都保持灰色。我正在这些图表中动态获取数据。
HTML:
<div class="lineChart4">
<h4 class="heading" style="text-align:center">Line Chart For Number of Clicks
</h4>
<div style="display: block" >
<canvas baseChart
[datasets]="lineChartData4"
[labels]="lineChartLabels4"
[colors]="lineChartColors"
[chartType]="lineChartType4"
[legend]="lineChartLegend4"
[options]="lineChartOptions4">
<!-- (chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)" -->
</canvas>
</div>
</div>
.ts:
public lineChartLabels4=['','','','',''];
public lineChartData4=[{ data: [0,0,0,0,0], label: '' , lineTension:0, fill: false},
{ data: [0,0,0,0,0], label: '' ,lineTension:0, fill: false}];
public lineChartType4:string='line';
public lineChartLegend4 = true;
public lineChartColors: Color[] = [
{ // grey
backgroundColor: 'rgba(148,159,177,0.2)',
borderColor: 'rgba(148,159,177,1)',
pointBackgroundColor: 'rgba(148,159,177,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(148,159,177,0.8)'
},
{ // red
backgroundColor: 'rgba(255,0,0,0.3)',
borderColor: 'red',
pointBackgroundColor: 'rgba(148,159,177,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(148,159,177,0.8)'
}
];
即将到来的数据(图表的形状)是正确的,但是我没有得到任何颜色。有人可以在这里帮我吗。 TIA。