remove link.distance/strength, tweak parameters
This commit is contained in:
parent
523384d64c
commit
80c2cd394b
|
@ -15,9 +15,8 @@ class D3MapBuilder:
|
|||
'flags': x.flags
|
||||
} for x in nodes if x.flags['online']]
|
||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||
'distance': x.distance,
|
||||
'strength': x.strength,
|
||||
'quality': x.quality,
|
||||
'type': x.type,
|
||||
'id': "-".join(nodes[i].id for i in x.pair)
|
||||
} for x in self._db.get_links()]
|
||||
|
||||
|
|
|
@ -160,8 +160,20 @@ var force = d3.layout.force()
|
|||
.friction(0.75)
|
||||
.theta(0.1)
|
||||
.size([w, h])
|
||||
.linkDistance(function (d) { return d.distance; })
|
||||
.linkStrength(function (d) { return d.strength; })
|
||||
.linkDistance(function (d) {
|
||||
switch (d.type) {
|
||||
case "vpn": return 150
|
||||
case "client": return 20
|
||||
default: return 70
|
||||
}
|
||||
})
|
||||
.linkStrength(function (d) {
|
||||
switch (d.type) {
|
||||
case "vpn": return 0.15
|
||||
case "client": return 1
|
||||
default: return 0.5
|
||||
}
|
||||
})
|
||||
|
||||
force.on("tick", function() {
|
||||
var size = force.size()
|
||||
|
|
3
link.py
3
link.py
|
@ -1,7 +1,6 @@
|
|||
class Link():
|
||||
def __init__(self):
|
||||
self.pair = None
|
||||
self.distance = None
|
||||
self.strength = None
|
||||
self.quality = None
|
||||
self.type = None
|
||||
|
||||
|
|
12
nodedb.py
12
nodedb.py
|
@ -157,16 +157,16 @@ class NodeDB:
|
|||
node.flags['vpn'] = True
|
||||
|
||||
def map_link(self, pair):
|
||||
distance = 80
|
||||
strength = 0.2
|
||||
type = None
|
||||
if any(filter(lambda x: self._nodes[x].flags['vpn'], pair[0])):
|
||||
type = "vpn"
|
||||
|
||||
if any(filter(lambda x: self._nodes[x].flags['client'], pair[0])):
|
||||
distance = 10
|
||||
strength = 1
|
||||
type = "client"
|
||||
|
||||
link = Link()
|
||||
link.pair = pair[0]
|
||||
link.distance = distance
|
||||
link.strength = strength
|
||||
link.type = type
|
||||
link.quality = pair[1]
|
||||
return link
|
||||
|
||||
|
|
Loading…
Reference in a new issue