remove group foo and replace it with flags

This commit is contained in:
Nils Schneider 2012-06-07 22:21:50 +02:00
commit 523384d64c
8 changed files with 41 additions and 38 deletions

View file

@ -17,16 +17,16 @@
stroke-width: 5px !important;
}
.node ellipse.group-0 {
.node ellipse {
fill: #fff;
stroke: #04f;
}
.node ellipse.group-2 {
.node ellipse.gateway {
stroke: #FF7F0E;
}
.node ellipse.group-3 {
.node ellipse.client {
stroke: #ff0;
fill: #ff0;
stroke-width: 5px;

View file

@ -17,15 +17,15 @@
stroke-opacity: 1;
}
.node ellipse.group-0 {
.node ellipse {
stroke: #AEC7E8;
}
.node ellipse.group-2 {
.node ellipse.gateway {
stroke: #FF7F0E;
}
.node ellipse.group-3 {
.node ellipse.client {
stroke: #1F77B4;
fill: #1F77B4;
}

View file

@ -251,12 +251,12 @@ function reload() {
json.links.forEach(function(d) {
var node, other
if (d.source.group == 2) {
if (d.source.flags.vpn) {
node = d.target;
other = d.source;
}
if (d.target.group == 2) {
if (d.target.flags.vpn) {
node = d.source;
other = d.target;
}
@ -280,10 +280,10 @@ function reload() {
function update() {
var links = data.links
.filter(function (d) {
if (!visible.clients && (d.source.group == 3 || d.target.group == 3))
if (!visible.clients && (d.source.flags.client || d.target.flags.client))
return false
if (!visible.vpn && (d.source.group == 2 || d.target.group == 2))
if (!visible.vpn && (d.source.flags.vpn || d.target.flags.vpn))
return false
return true
@ -324,13 +324,13 @@ function update() {
link.exit().remove()
var nodes = data.nodes.filter(function (d) {
if (!visible.vpn && d.group == 2)
if (!visible.vpn && d.flags.vpn)
return false
if (!visible.vpn && d.group == 3 && d.uplinks)
if (!visible.vpn && d.flags.client && d.uplinks)
return false
if (!visible.clients && d.group == 3)
if (!visible.clients && d.flags.client)
return false
return true
@ -353,21 +353,26 @@ function update() {
nodeEnter.append("ellipse")
.attr("class", function(d) {
return "group-" + d.group
var s = []
for (var key in d.flags)
if (d.flags.hasOwnProperty(key) && d.flags[key])
s.push(key)
return s.join(" ")
})
node.selectAll("ellipse")
.attr("rx", function(d) {
if (d.group == 3) return 4
if (d.flags.client) return 4
else return Math.max(10, d.name.length * 5)
})
.attr("ry", function(d) {
if (d.group == 3) return 4
if (d.flags.client) return 4
else return 10
})
nodeEnter.filter(function(d) {
return d.group != 3
return !d.flags.client
})
.append("text")
.attr("class", "name")