forcegraph: remove labels

This commit is contained in:
Nils Schneider 2015-04-01 03:57:10 +02:00
parent a8bb1b40a2
commit eb315ab60a

View File

@ -2,7 +2,7 @@ define(["d3"], function (d3) {
return function (linkScale, sidebar, router) { return function (linkScale, sidebar, router) {
var self = this var self = this
var nodes, links var nodes, links
var svg, vis, link, node, label var svg, vis, link, node
var nodesDict, linksDict var nodesDict, linksDict
var zoomBehavior var zoomBehavior
var force var force
@ -100,10 +100,6 @@ define(["d3"], function (d3) {
node node
.attr("cx", function(d) { return d.x }) .attr("cx", function(d) { return d.x })
.attr("cy", function(d) { return d.y }) .attr("cy", function(d) { return d.y })
label.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")"
})
} }
el = document.createElement("div") el = document.createElement("div")
@ -123,7 +119,6 @@ define(["d3"], function (d3) {
vis.append("g").attr("class", "links") vis.append("g").attr("class", "links")
vis.append("g").attr("class", "nodes") vis.append("g").attr("class", "nodes")
vis.append("g").attr("class", "labels").attr("pointer-events", "none")
force = d3.layout.force() force = d3.layout.force()
.charge(-70) .charge(-70)
@ -216,36 +211,6 @@ define(["d3"], function (d3) {
nodesDict[d.node.nodeinfo.node_id] = d nodesDict[d.node.nodeinfo.node_id] = d
}) })
label = vis.select("g.labels")
.selectAll("g.label")
.data(data.graph.nodes, function (d) {
return d.id
})
var labelEnter = label.enter()
.append("g")
.attr("class", "label")
labelEnter.append("path").attr("class", "clients")
labelEnter.append("text")
.attr("class", "name")
.attr("text-anchor", "middle")
.attr("y", "21px")
.attr("x", "0px")
label.selectAll("text.name").text(nodeName)
var labelTextWidth = function (e) {
return e.parentNode.querySelector("text").getBBox().width + 3
}
labelEnter.insert("rect", "text")
.attr("y", "10px")
.attr("x", function() { return labelTextWidth(this) / (-2)})
.attr("width", function() { return labelTextWidth(this)})
.attr("height", "15px")
nodeEnter.append("title") nodeEnter.append("title")
nodeEnter.each( function (d) { nodeEnter.each( function (d) {
if (nodePositions[d.id]) { if (nodePositions[d.id]) {
@ -321,7 +286,6 @@ define(["d3"], function (d3) {
vis = null vis = null
link = null link = null
node = null node = null
label = null
} }
return self return self