I've looked at How to change colours for Angular-Chart.js, but it relates to colours for an entire (dataset), not a specific bar.
What I'm looking for is a way to apply Different color for each bar in a bar chart; ChartJS to Angular.
So, I've got a bar chart:
<canvas id="locationBar" class="chart chart-bar" data="chartParams.votes" labels="chartParams.listOfLocations" series="chartParams.series" colours="chartParams.colours" options="chartParams.options"></canvas>
With the following angular code (in a controller of course)
$scope.chartParams = {
listOfLocations: ['Trenzalore','Earth','Caprica','Sol','Tau Ceti'],
votes: [[5,10,6,7,2]],
series: ["Nice Places"],
colours: [{fillColor:getRandomColour()}],
options: {barShowStroke : false}
};
where getRandomColour()
would return a random colour.
Right now, the colours
field applies this colour to all the bars:
when I actually want a different colour for each bar: