I follow the tutorial from http://bl.ocks.org/mbostock/4062045 and questions Introducing Arrow(directed), in Force Directed Graph d3 , and could customize edges color by
var svg_edges = svg.append("svg:g").selectAll("path")
.data(force.links())
.enter()
.append("line")
.style("stroke",function(d,i){
return color(i); // customize edges colors
})
and then add arrow by the below code:
svg.append("svg:defs").selectAll("marker")
.data(['end']) // Different link/path types can be defined here
.enter().append("svg:marker") // This section adds in the arrows
.attr("id", function(d,i) {
return d;
})
.attr("viewBox", "0 -5 10 10")
.attr("refX", 15)
.attr("refY", 0)
.attr("markerWidth", 6)
.attr("markerHeight", 6)
.attr("orient", "auto")
.append("svg:path")
.attr("d", "M0,-5L10,0L0,5")
.style("fill", "#ccc") // how to customize each arrow color here
and then add below in edges
.attr("marker-end", "url(#end)");
I want know how to specify each arrow's color just like what we did on edges. http://bl.ocks.org/mbostock/1153292 show how to specify different types of edges and arrows, but I did not find ways to change both(arrow and edges) by coding.