fix link quality display

alfred-data
Nils Schneider 2012-06-04 20:47:05 +02:00
parent 42f73dfb8c
commit 492dec92c1
4 changed files with 16 additions and 10 deletions

View File

@ -12,7 +12,8 @@ class D3MapBuilder:
} for x in self._db.get_nodes() if x.online]
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
'distance': x.distance,
'strength': x.strength
'strength': x.strength,
'quality': x.quality
} for x in self._db.get_links()]
return json.dumps(output)

View File

@ -122,18 +122,21 @@ function render_graph(type) {
d.source.group != 3 && d.target.group != 3;
});
var linkdata = vis.selectAll("line.link")
.data(linkdata)
var link = linkdata.enter().append("line")
var link = vis.selectAll("line.link")
.data(linkdata)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return Math.min(1, d.strength * 2); });
var linklabel = linkdata.enter().append("text")
var linklabel = vis.selectAll("text")
.data(linkdata.filter(function (d) {return d.quality != "TT"}))
.enter()
.append("text")
.attr("text-anchor", "middle")
.attr("color", "#000")
.attr("class", "strength")
.text(function (d) { return d.strength; });
.text(function (d) { return d.quality; });
    function isConnected(a, b) {
        return linkedByIndex[a.index + "," + b.index] || linkedByIndex[b.index + "," + a.index] || a.index == b.index;

View File

@ -3,4 +3,5 @@ class Link():
self.pair = None
self.distance = None
self.strength = None
self.quality = None

View File

@ -96,7 +96,7 @@ class NodeDB:
a = self._nodes.index(router)
b = self._nodes.index(neighbor)
self._links.add(tuple(sorted((a,b))))
self._links.add(tuple((tuple(sorted((a,b))), x['label'])))
for line in lines:
x = json.loads(line)
@ -135,14 +135,15 @@ class NodeDB:
def map_link(self, pair):
distance = 80
strength = 0.2
if any(filter(lambda x: self._nodes[x].group == 3, pair)):
if any(filter(lambda x: self._nodes[x].group == 3, pair[0])):
distance = 10
strength = 1
link = Link()
link.pair = pair
link.pair = pair[0]
link.distance = distance
link.strength = strength
link.quality = pair[1]
return link
def import_wikigps(self, url):
@ -213,7 +214,7 @@ class NodeDB:
def find_link(self, i):
for link in self._links:
if i in link:
if i in link[0]:
return link
def wilder_scheiss(self):