How to display nodes as different characters in a d3.js-forced library? I wanted to implement something similar to what I wrote below:
var node = svg.selectAll(".node")
.data(graph.nodes)
.enter().append(function(d){return d.shape;})
.attr("class", "node")
.attr("r", 5)
.style("fill", function(d) { return color(d.group); })
.call(force.drag);
Each node will have an encoded shape ("rect", "circle", etc.). However, I get an error message:
Uncaught TypeError: Object function (d){return "circle";} has no method 'indexOf'
Another question I related to this is this: how would I switch between applying different attributes for each shape? Circles need the r attribute, but rectangles require height and width. Thank!
source
share