Hello there … am still relatively new so bear with me if this has a simple solution. I have data from a python program that feeds the forcelayout and my challenges are -
- How can position the text around this graph in such a way that it is most visible and reduces the ovelrap. I have cut down the count to a manage-able number around the central point but it would be great if i can position the text on say the left side of this word cloud to further left so that they’re more visible.
- Secondly - how can i “send back” these lines and bring the text forward? like we have in powerpoint am looking for a way to send these lines “back” … i can get better colors closer to the background i guess but this would also help improve read-ability.
Standard code that i use from one of the examples is pasted below. Kindly advise.
var force = d3.layout.force()
.nodes(d3.values(nodes))
.links(links)
.size([width, height])
.linkDistance(100)
.charge(-300)
.on("tick", tick)
.start();
// Set the range
var v = d3.scale.linear().range([0, 100]);
// Scale the range of the data
v.domain([0, d3.max(links, function(d) { return d.value; })]);
// build the arrow.
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", String)
.attr("viewBox", "0 -5 10 10")
.attr("refX", 15)
.attr("refY", -1.5)
.attr("markerWidth", 4)
.attr("markerHeight", 4)
.attr("orient", "auto")
.append("svg:path")
.attr('fill','grey')
.attr("d", "M0,-5L10,0L0,5");
// add the links and the arrows
var path = svg.append("svg:g").selectAll("path")
.data(force.links())
.enter().append("svg:path")
.attr("class", function(d) { return "link " + d.type; })
.attr("marker-end", "url(#end)");
// define the nodes
var node = svg.selectAll(".node")
.data(force.nodes())
.enter().append("g")
.attr("class", "node")
.on("click", click)
//.on("dblclick", dblclick)
.call(force.drag);
node.append("circle")
.attr("r", function(d)
{
if ((d.type).localeCompare("searchresult")==0)
{ return 6; }
else return 12 ;
})
.style("fill", function(d)
{
var d3c = "red";
//console.log('d.type is now:',d.type);
if ((d.type).localeCompare("searchresult")==0)
{ d3c = "red";
//console.log("yes we came here ...");
}
else
{d3c = "green" ; }
//return color(d.type);
//console.log("sending this color now:", d3c);
return d3c;
});