下面是我的圖表樣本
https://stackblitz.com/edit/angular-barchart-example-jodddf?file=src/app/barchart/barchart.ts
單擊change data按鈕時 - 我正在向圖表添加新條形圖,只想更改新添加的條形圖顏色。
有沒有可能做到這一點?
uj5u.com熱心網友回復:
public randomize(): void {
let clone = JSON.parse(JSON.stringify(this.barChartData));
clone[0].data = [55, 60, 75, 100];
clone[1].data = [58, 55, 60, 100];
this.barChartColors[0].backgroundColor = [
'rgba(105,159,177,0.2)',
'rgba(105,159,177,0.2)',
'rgba(105,159,177,0.2)',
'rgba(255,0,0,0.2)',
];
this.barChartColors[1].backgroundColor = [
'rgba(77,20,96,0.3)',
'rgba(77,20,96,0.3)',
'rgba(77,20,96,0.3)',
'rgba(0,255,0,0.3)',
];
this.barChartColors = [...this.barChartColors];
setTimeout(() => {
this.barChartData = clone;
}, 100);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/360630.html
