I'm using ChartJS in a project I'm working on and I need a different color for each bar in a Bar Chart.
Here's an example of the bar chart data set:
var barChartData = {
labels: ["001", "002", "003", "004", "005", "006", "007"],
datasets: [{
label: "My First dataset",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [20, 59, 80, 81, 56, 55, 40]
}]
};
Is there any way to paint each bar differently?
fillColor
of a dataset to be an array, and chart.js will iterate through the array picking the next color for each bar drawn. – Hartley Brody