Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular chart js graph legend colors

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]);
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: How can I save a option from multi select in Angular 
Javascript :: Angular.js : recursive call to an $mdDialog controller 
Javascript :: Understanding higher order JavaScript functions 
Javascript :: how to use recursive function to select the parent in a tree array using angulat ui tree 
Javascript :: HTTP Get with looping password validation not working 
Javascript :: Changing Component File location in React native does not show in main App 
Javascript :: React Native Swift Escaping closure 
Javascript :: Use of typescript generics for extended parametres 
Javascript :: What is the best way to download mulitple images using jquery 
Javascript :: arrow function - one line and no parameters 
Javascript :: track call recording in facebook using elements 
Javascript :: How to limit properties of a JSON object given array of property names using JQ 
Javascript :: send data from a file to frontend nodejs 
Javascript :: lerp two values 
Javascript :: show code in console very good 
Javascript :: javascript patterns 
Javascript :: get value from createReadStream 
Javascript :: Using <template in Javascript to create a form 
Javascript :: puppeteer create folder 
Javascript :: module imports renaming 
Javascript :: empty or remove div span class 
Javascript :: NodeJS Database initialisation 
Javascript :: Nodejs change host on npm run dev 
Javascript :: var logNums = function(num) {}; 
Javascript :: check token balance of an address in js 
Javascript :: How to Loop Through an Array with a for…of Loop in JavaScript 
Javascript :: backbone view initialize 
Javascript :: React Gotchas 
Javascript :: remove parent element jquery 
Javascript :: clear console javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =