2👍
✅
You can pass an array of strings (colours) to backgroundColor
:
backgroundColor: ['red', 'green', 'blue']
Example:
new Chart(document.getElementById("chart"), {
type: "pie",
data: {
datasets: [{
data: [1, 2, 3],
backgroundColor: ['red', 'green', 'blue']
}]
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<canvas id="chart"></canvas>
Source:stackexchange.com