How to use the chroma-js.brewer function in chroma-js

To help you get started, we’ve selected a few chroma-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mezzario / color-math / src / evaluators / CoreEvaluator.js View on Github external
static _getBrewerConstsDict() {
    let dict = this._brewerConstsDict

    if (!dict) {
      dict = Object.create(null)

      for (const key in Chroma.brewer) {
        if (key in Chroma.brewer) {
          dict[key.toLowerCase()] = Chroma.brewer[key]
        }
      }

      this._brewerConstsDict = dict
    }

    return dict
  }
github jdfekete / progressivis / widgets / progressivis_nb_widgets / js / src / colormaps.js View on Github external
"use strict";

/**
 * Color function transfer management.
 * Requires chroma.js
 */
//var colormaps = function(){
var chroma = require("chroma-js");
  const svgNS = "http://www.w3.org/2000/svg";
  
  var tables = {
    Default: [[0,1],[0,1],[0,1]], //[[1,1,1],[0.93,0.001,0],[0.63,0.001,0]],
    OrRd: tableFromChroma(chroma.brewer.OrRd),
    PuBu: tableFromChroma(chroma.brewer.PuBu),
    Oranges: tableFromChroma(chroma.brewer.Oranges),
    Greens:  tableFromChroma(chroma.brewer.Greens),
    CubeHelix: tableFromChroma(chroma.cubehelix().scale().correctLightness().colors(9)),
    InvertedGrayscale: [[1,0.01,0],[1,0.01,0],[1,0.01,0]],
    Identity: [[0,1],[0,1],[0,1]]
  };

  function tableFromChroma(chromaTable){
    var rtab = [];
    var gtab = [];
    var btab = [];
    
    chromaTable.forEach(function(chromaElt){
      var rgb = chroma(chromaElt).get('rgb');
      rtab.push(rgb[0]/255);
github mezzario / color-math / src / eval-scope.js View on Github external
CoreEvaluator.getBrewerConstsDict = function () {
        var dict = this._brewerConstsDict;
        if (!dict) {
            dict = {};
            for (var key in chroma.brewer)
                if (chroma.brewer.hasOwnProperty(key))
                    dict[key.toLowerCase()] = chroma.brewer[key];
            this._brewerConstsDict = dict;
        }
        return dict;
    };
    CoreEvaluator.prototype.numbersArithmeticOp = function (node) {
github jdfekete / progressivis / widgets / progressivis_nb_widgets / js / src / colormaps.js View on Github external
"use strict";

/**
 * Color function transfer management.
 * Requires chroma.js
 */
//var colormaps = function(){
var chroma = require("chroma-js");
  const svgNS = "http://www.w3.org/2000/svg";
  
  var tables = {
    Default: [[0,1],[0,1],[0,1]], //[[1,1,1],[0.93,0.001,0],[0.63,0.001,0]],
    OrRd: tableFromChroma(chroma.brewer.OrRd),
    PuBu: tableFromChroma(chroma.brewer.PuBu),
    Oranges: tableFromChroma(chroma.brewer.Oranges),
    Greens:  tableFromChroma(chroma.brewer.Greens),
    CubeHelix: tableFromChroma(chroma.cubehelix().scale().correctLightness().colors(9)),
    InvertedGrayscale: [[1,0.01,0],[1,0.01,0],[1,0.01,0]],
    Identity: [[0,1],[0,1],[0,1]]
  };

  function tableFromChroma(chromaTable){
    var rtab = [];
    var gtab = [];
    var btab = [];
    
    chromaTable.forEach(function(chromaElt){
      var rgb = chroma(chromaElt).get('rgb');
      rtab.push(rgb[0]/255);
      gtab.push(rgb[1]/255);
      btab.push(rgb[2]/255);
github mezzario / color-math / src / eval-scope.js View on Github external
CoreEvaluator.getBrewerConstsDict = function () {
        var dict = this._brewerConstsDict;
        if (!dict) {
            dict = {};
            for (var key in chroma.brewer)
                if (chroma.brewer.hasOwnProperty(key))
                    dict[key.toLowerCase()] = chroma.brewer[key];
            this._brewerConstsDict = dict;
        }
        return dict;
    };
    CoreEvaluator.prototype.numbersArithmeticOp = function (node) {
github mezzario / color-math / src / evaluators / CoreEvaluator.js View on Github external
static _getBrewerConstsDict() {
    let dict = this._brewerConstsDict

    if (!dict) {
      dict = Object.create(null)

      for (const key in Chroma.brewer) {
        if (key in Chroma.brewer) {
          dict[key.toLowerCase()] = Chroma.brewer[key]
        }
      }

      this._brewerConstsDict = dict
    }

    return dict
  }