Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = {};
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);
$(".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"> </div>`
).insertAfter(input);
colours.set(Number(input.val()), colour);
});
return colours;
edges.forEach(([a, b]) => {
line(context, projected[a], projected[b], {
lineWidth: 1,
stroke: chroma.random(),
});
});
graph.nodes().forEach(node => {
graph.mergeNodeAttributes(node, {
label: faker.name.findName(),
size: Math.max(4, Math.random() * 10),
color: chroma.random().hex(),
zIndex: 0
});
});
graph.nodes().forEach(node => {
graph.mergeNodeAttributes(node, {
label: faker.name.findName(),
size: Math.max(4, Math.random() * 10),
color: chroma.random().hex()
});
});
evalRandomColor(/*node*/) {
const value = Chroma.random()
return value
}
CoreEvaluator.prototype.evalRandomColor = function (node) {
var value = chroma.random();
return value;
};
CoreEvaluator.prototype.evalScale = function (node) {
function handleRandomColor() {
const color = chroma.random().hex()
input.value = color
handleColor(color)
}
function handleRandomColor() {
const color = chroma.random().hex()
input.value = color
handleColor(color)
}