VivaGraphJS
VivaGraphJS copied to clipboard
adding transparency to nodes which are not selected
trafficstars
Hi, I am trying to add transparency to nodes which are not selected , is any VivaGraphJS API available to get this done ? I tried to do using JS and CSS but it's ending up crashing the browser. let me know is any way to get this done.
Thanks Srikanth
You probably have to do it manually. I have system in my application for toggling on and of selected tree in graph. It's based on color change.
function toggleTree(id: string, hide: boolean) {
const node = graphics.getNodeUI(id);
if (node) {
node.color = changeColorNode(node.color, hide);
node.node.links.forEach(({ id }) => {
const link = graphics.getLinkUI(id);
link.color = changeColorLink(link.color, hide);
});
node.node.data.children.forEach(n => toggleTree(n.id, hide));
}
}
function changeColorNode(color: number, hide: boolean): number {
// set last two to 00 - transparent
// set last two to ff - solid
return parseInt(color.toString(16).slice(0, 6) + (hide ? '00' : 'ff'), 16);
}
function changeColorLink(color: number, hide: boolean): number {
if (hide) {
return parseInt(color.toString(16).slice(0, 6) + '00', 16);
} else {
return parseInt('808080ff', 16);
}
}