How to use the chroma-js.random 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 phac-nml / irida / src / main / webapp / resources / js / pages / visualizations / phylogenetics / components / metadata / metadata.service.js View on Github external
const result = {};
  const colourMap = {};
  const sampleNames = Object.keys(metadata);

  for (const sampleName of sampleNames) {
    const sampleMetadata = metadata[sampleName];
    result[sampleName] = {};
    for (const field of metadataFieldLabels) {
      const metadataLabel = sampleMetadata[field].value;

      if (metadataLabel) {
        // Find out if the field has already been assigned a colour
        // If not, get it a new one.
        colourMap[field] = colourMap[field] || {};
        colourMap[field][metadataLabel] =
          colourMap[field][metadataLabel] || chroma.random();
        result[sampleName][field] = {
          label: metadataLabel,
          colour: colourMap[field][metadataLabel]
        };
      } else {
        // If the label is empty, then do not give it a colour.
        result[sampleName][field] = {
          label: metadataLabel,
          colour: EMPTY_COLOUR
        };
      }
    }
  }

  // Add the reference blanks, without this, Phylocanvas will througha fit!
  const reference = {};
github ali1k / ld-r / components / dataset / viewer / ScatterChartView.js View on Github external
yLabel = xyz.yLabel;
                }
                if(xyz.z && !zType){
                    if (isNaN(xyz.z)){
                        zType = 'category';
                    }else{
                        zType = 'number';
                    }
                    zLabel = xyz.zLabel;
                }
                //collect all other attributes
                if(Object.keys(xyz.others).length){
                    instances.push({uri: node.v, title: title , x: Number(xyz.x), y: Number(xyz.y), z: xyz.z, others: xyz.others});
                    //define
                    if(!colorGroup[xyz.z]){
                        colorGroup[xyz.z] = chroma.random().hex();
                    }
                }else{
                    if(zLabel){
                        //3D
                        instances.push({uri: node.v, title: title , x: Number(xyz.x), y: Number(xyz.y), z: xyz.z});
                        //define
                        if(!colorGroup[xyz.z]){
                            colorGroup[xyz.z] = chroma.random().hex();
                        }
                    }else{
                        //2D
                        instances.push({uri: node.v, title: title , x: Number(xyz.x), y: Number(xyz.y)});
                    }
                }
            });
            //console.log(instances);
github phac-nml / irida / src / main / webapp / resources / js / pages / projects / samples / project-samples.js View on Github external
$(".associated-cb input").each((i, elm) => {
    const input = $(elm);
    const colour = chroma.random();
    /*
    Add some colour to the checkbox so it can easily be
    associated with the name in the table
     */
    $(
      `<div style="margin: 0; background-color: ${colour}" class="label-bar-color">&nbsp;</div>`
    ).insertAfter(input);

    colours.set(Number(input.val()), colour);
  });
  return colours;
github winkerVSbecks / sketchbook / projection.js View on Github external
edges.forEach(([a, b]) => {
      line(context, projected[a], projected[b], {
        lineWidth: 1,
        stroke: chroma.random(),
      });
    });
github jacomyal / sigma.js / examples / events.js View on Github external
graph.nodes().forEach(node => {

  graph.mergeNodeAttributes(node, {
    label: faker.name.findName(),
    size: Math.max(4, Math.random() * 10),
    color: chroma.random().hex(),
    zIndex: 0
  });
});
github jacomyal / sigma.js / examples / basic.js View on Github external
graph.nodes().forEach(node => {
  graph.mergeNodeAttributes(node, {
    label: faker.name.findName(),
    size: Math.max(4, Math.random() * 10),
    color: chroma.random().hex()
  });
});
github mezzario / color-math / src / evaluators / CoreEvaluator.js View on Github external
evalRandomColor(/*node*/) {
    const value = Chroma.random()

    return value
  }
github mezzario / color-math / src / eval-scope.js View on Github external
CoreEvaluator.prototype.evalRandomColor = function (node) {
        var value = chroma.random();
        return value;
    };
    CoreEvaluator.prototype.evalScale = function (node) {
github Automattic / color-studio / docs-source / javascripts / page-custom.js View on Github external
function handleRandomColor() {
  const color = chroma.random().hex()
  input.value = color
  handleColor(color)
}
github Automattic / color-studio / docs / javascripts / main.js View on Github external
function handleRandomColor() {
  const color = chroma.random().hex()
  input.value = color
  handleColor(color)
}