0👍
Each data point needs a background color:
e.g.
{data: [0, 0, 1, 0, 0, 1, 0], label: 'Email Clicks', backgroundColor:[rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0), rgb(0, 0, 0)]'}
If you intend to use the same color for each data point, you can just create the array dynamically instead of all that copy and paste.
0👍
Is this ng2-charts?
add this to the canvas tag:
[colors]="barChartColors"
Each element in the barChartColors maps to the same index as an entry in barChartData
You don’t need to put backgroundColor in each barChartData then.
- Chartjs-How to displays item names from the database using a monthly or yearly chart PHP MySQL
- Chartjs-Why am I getting the wrong Background Color when applying multiple colors to data points?
Source:stackexchange.com