dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.85k stars 587 forks source link

Change style of edges of graph #138

Open gaitat opened 9 years ago

gaitat commented 9 years ago

After I render a graph in dagre-d3, I would like to change the color of the outEdges of a clicked node. So far I have tried:

var outEdges = graph.outEdges(v); /* v is the vertex I clicked on */

Object.keys( outEdges ).forEach (function (edge) {
    graph.edge( outEdges[edge] ).style("stroke", "yellow"); /* returns: Uncaught TypeError: string is not a function */
    graph.edge( outEdges[edge] ).attr("style", "stroke: yellow"); /* returns: Uncaught TypeError: undefined is not a function */
});
jk171505 commented 9 years ago

This is svg, I'd try to set attributes of the element (not the style attribute).

Try this: .attr('stroke', '#ff0000')

You can also set other things: .attr('stroke-width', 1) .attr('stroke-dasharray', 1)