【发布时间】:2019-04-29 20:49:30
【问题描述】:
【问题讨论】:
标签: angular chart.js ng2-charts
【问题讨论】:
标签: angular chart.js ng2-charts
在我看来,colors 属性可以选择这样做。
只需传递一组颜色对象 (refer here to see the object)
像这样在 HTML 中添加输入:
<div style="display: block;">
<canvas baseChart
[datasets]="barChartData"
[labels]="barChartLabels"
[options]="barChartOptions"
[plugins]="barChartPlugins"
[legend]="barChartLegend"
[chartType]="barChartType"
[colors]="colors">//<---------------the colors input property
</canvas>
</div>
然后在你的 ts 文件中添加下一个对象:
public colors = [
{ backgroundColor:"red" },
{ backgroundColor:"green" },
{ backgroundColor:"blue" },
{ backgroundColor:"yellow" }
];
【讨论】: