VivaGraphJS icon indicating copy to clipboard operation
VivaGraphJS copied to clipboard

Change image of all nodes using json data in Vivagraph

Open richa2008 opened this issue 8 years ago • 0 comments
trafficstars

Hi,

I am using vivagraph for displaying my JSON data in the form of a diagram. However,when I am trying to change the image of all nodes according to the JSON data the image of only the last node is changing. I have created one svg element which I am appending to the node element.The svg element is as follows:- var img = Viva.Graph.svg('image') .attr('width', 24) .attr('height', 24) .link('images/black.png'); var ui = Viva.Graph.svg('g') .attr('id',node.data.id); After the JSON data is called I am storing the data and assigning colors to distinct value from the JSON data in an object named objNodeData.Then I am using graph.foreachnode to iterate the nodes but at the last color of only the last iterated node is changing.I am stuck with this issue.Please help.Thank You.

graph.forEachNode(function (node){ var nodeUI = graphics.getNodeUI(node); if(nodeUI){ if(objNodeData[node.data.id]){ colornodesbl = objNodeData[node.data.id].colour; } img.link(colornodesbl); ui.append(img); } });

richa2008 avatar Mar 05 '17 14:03 richa2008