fix link quality display
This commit is contained in:
parent
42f73dfb8c
commit
492dec92c1
|
@ -12,7 +12,8 @@ class D3MapBuilder:
|
||||||
} for x in self._db.get_nodes() if x.online]
|
} for x in self._db.get_nodes() if x.online]
|
||||||
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||||
'distance': x.distance,
|
'distance': x.distance,
|
||||||
'strength': x.strength
|
'strength': x.strength,
|
||||||
|
'quality': x.quality
|
||||||
} for x in self._db.get_links()]
|
} for x in self._db.get_links()]
|
||||||
|
|
||||||
return json.dumps(output)
|
return json.dumps(output)
|
||||||
|
|
|
@ -122,18 +122,21 @@ function render_graph(type) {
|
||||||
d.source.group != 3 && d.target.group != 3;
|
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")
|
.attr("class", "link")
|
||||||
.style("stroke-width", function(d) { return Math.min(1, d.strength * 2); });
|
.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("text-anchor", "middle")
|
||||||
.attr("color", "#000")
|
.attr("color", "#000")
|
||||||
.attr("class", "strength")
|
.attr("class", "strength")
|
||||||
.text(function (d) { return d.strength; });
|
.text(function (d) { return d.quality; });
|
||||||
|
|
||||||
function isConnected(a, b) {
|
function isConnected(a, b) {
|
||||||
return linkedByIndex[a.index + "," + b.index] || linkedByIndex[b.index + "," + a.index] || a.index == b.index;
|
return linkedByIndex[a.index + "," + b.index] || linkedByIndex[b.index + "," + a.index] || a.index == b.index;
|
||||||
|
|
1
link.py
1
link.py
|
@ -3,4 +3,5 @@ class Link():
|
||||||
self.pair = None
|
self.pair = None
|
||||||
self.distance = None
|
self.distance = None
|
||||||
self.strength = None
|
self.strength = None
|
||||||
|
self.quality = None
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class NodeDB:
|
||||||
a = self._nodes.index(router)
|
a = self._nodes.index(router)
|
||||||
b = self._nodes.index(neighbor)
|
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:
|
for line in lines:
|
||||||
x = json.loads(line)
|
x = json.loads(line)
|
||||||
|
@ -135,14 +135,15 @@ class NodeDB:
|
||||||
def map_link(self, pair):
|
def map_link(self, pair):
|
||||||
distance = 80
|
distance = 80
|
||||||
strength = 0.2
|
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
|
distance = 10
|
||||||
strength = 1
|
strength = 1
|
||||||
|
|
||||||
link = Link()
|
link = Link()
|
||||||
link.pair = pair
|
link.pair = pair[0]
|
||||||
link.distance = distance
|
link.distance = distance
|
||||||
link.strength = strength
|
link.strength = strength
|
||||||
|
link.quality = pair[1]
|
||||||
return link
|
return link
|
||||||
|
|
||||||
def import_wikigps(self, url):
|
def import_wikigps(self, url):
|
||||||
|
@ -213,7 +214,7 @@ class NodeDB:
|
||||||
|
|
||||||
def find_link(self, i):
|
def find_link(self, i):
|
||||||
for link in self._links:
|
for link in self._links:
|
||||||
if i in link:
|
if i in link[0]:
|
||||||
return link
|
return link
|
||||||
|
|
||||||
def wilder_scheiss(self):
|
def wilder_scheiss(self):
|
||||||
|
|
Loading…
Reference in a new issue