Reputation: 11
I'm working from the example of the force directed graph.
krispo/angular-nvd3/blob/gh-pages/js/forceDirectedGraph.js
How would I modify this code, so that I can add arrow heads to each of the links to indicate direction?
$scope.options = {
chart: {
type: 'forceDirectedGraph',
height: 450,
width: (function(){ return nv.utils.windowSize().width })(),
margin:{top: 20, right: 20, bottom: 20, left: 20},
color: function(d){
return color(d.group)
},
nodeExtras: function(node) {
node && node
.append("text")
.attr("dx", 8)
.attr("dy", ".35em")
.text(function(d) { return d.name })
.style('font-size', '10px');
}
}
};
So that the output looks something more like this:
http://bl.ocks.org/tomgp/d59de83f771ca2b6f1d4
which append markers as the arrowhead to the FDG.
defs.append("marker")
.attr({
"id":"arrow",
"viewBox":"0 -5 10 10",
"refX":5,
"refY":0,
"markerWidth":4,
"markerHeight":4,
"orient":"auto"
})
.append("path")
.attr("d", "M0,-5L10,0L0,5")
.attr("class","arrowHead");
Here is my plunker example
http://plnkr.co/edit/rEOMRRnHx1UUj4Lu5Jui?p=preview
Upvotes: 1
Views: 255
Reputation: 31
It looks like this is a issue with Angular-nvd3. Hopefully it will be resolved. https://github.com/krispo/angular-nvd3/issues/677
Upvotes: 0