Angular Diagramm JS Graph Legend Farben
angular.forEach($scope.data , function (dataItem, index) {
var colorCode = getColorHex(index);
$scope.colours.push(colorCode);
});
var getColorHex = function (i) {
//skip black & white
i+=2;
var colorDecimal = getRGB(i);
var colorHex = decimalColorToHTMLcolor(colorDecimal);
return colorHex;
}
function decimalColorToHTMLcolor(colorDecimal) {
var intnumber = colorDecimal - 0;
var red, green, blue;
var template = "#000000";
red = (intnumber & 0x0000ff) << 16;
green = intnumber & 0x00ff00;
blue = (intnumber & 0xff0000) >>> 16;
intnumber = red | green | blue;
var HTMLcolor = intnumber.toString(16);
HTMLcolor = template.substring(0, 7 - HTMLcolor.length) + HTMLcolor;
return HTMLcolor;
}
function getRGB(index) {
var p = getPattern(index);
return getElement(p[0]) << 16 | getElement(p[1]) << 8 | getElement(p[2]);
}
SAMER SAEID