Is there a way to dynamically generate an array of colors for our chart?
If I initialize my colors array with hex colors, it works fine. But if I use the result of my "getRandomColor" function, it doesn't work at all.
Any ideas on this issue?
$scope.theChart.colours = ["#78CBBC", "#CF207A", "#5DBA1A", "#3AEB06", "#CA5923", "#3C34E0", "#E14FCC"]; // works fine
--
$scope.theChart.colours = getcolors(); //doesn't work
function getcolors(array){
var colors = [];
for (var i = 0; i < 7; i++) {
colors[i] = getRandomColor();
}
return colors;
}
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
Appreciate any help provided