model-navigator-standalone
Version:
Standalone MDF graph model visualizer
57 lines (55 loc) • 1.24 kB
JavaScript
export const nodeColor = node => {
switch (node.category) {
case 'administrative':
return '#9B2D20';
case 'study':
return '#9875FF';
case 'case':
return '#FF7F15';
case 'clinical_trial':
return '#00A1BB';
case 'biospecimen':
return '#00785A';
case 'analysis':
return '#B533A9';
case 'data_file':
return '#00AD0E';
case 'clinical':
return '#1C75BC';
default:
return '#ff0072';
}
};
/**
* Active Search Mode
* set node title for matching query
*/
export const setMatchingNodeTitle = function setMatchingNodeTitle() {
let searchResult = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
let matchedNodeNameIndices = {};
if (!searchResult) {
return null;
}
searchResult.matchedNodes.forEach(item => {
item.matches.forEach(matchItem => {
const {
value,
key
} = matchItem;
if (key === 'title') {
matchedNodeNameIndices[value] = matchItem.indices;
}
});
});
return matchedNodeNameIndices;
};
/**
* set zoom based on width
*/
export const getMinZoom = _ref => {
let {
width,
minZoom
} = _ref;
return width > 1450 ? 0.75 : minZoom;
};