show link strength
This commit is contained in:
parent
2174c57b8b
commit
42f73dfb8c
|
@ -13,6 +13,11 @@ line.link {
|
||||||
stroke-opacity: 1;
|
stroke-opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.strength {
|
||||||
|
font-size: 10px;
|
||||||
|
fill: #C83771;
|
||||||
|
}
|
||||||
|
|
||||||
#chart, #chart svg {
|
#chart, #chart svg {
|
||||||
display: block;
|
display: block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
|
@ -122,16 +122,18 @@ 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")
|
||||||
var link = vis.selectAll("line.link")
|
|
||||||
.data(linkdata)
|
.data(linkdata)
|
||||||
.enter().append("line")
|
|
||||||
|
var link = 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); });
|
||||||
.attr("x1", function(d) { return d.source.x; })
|
|
||||||
.attr("y1", function(d) { return d.source.y; })
|
var linklabel = linkdata.enter().append("text")
|
||||||
.attr("x2", function(d) { return d.target.x; })
|
.attr("text-anchor", "middle")
|
||||||
.attr("y2", function(d) { return d.target.y; });
|
.attr("color", "#000")
|
||||||
|
.attr("class", "strength")
|
||||||
|
.text(function (d) { return d.strength; });
|
||||||
|
|
||||||
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;
|
||||||
|
@ -233,6 +235,11 @@ function render_graph(type) {
|
||||||
.attr("x2", function(d) { return d.target.x; })
|
.attr("x2", function(d) { return d.target.x; })
|
||||||
.attr("y2", function(d) { return d.target.y; });
|
.attr("y2", function(d) { return d.target.y; });
|
||||||
|
|
||||||
|
linklabel
|
||||||
|
.attr("x", function(d) { return Math.min(d.source.x, d.target.x) + Math.abs(d.source.x - d.target.x) / 2; })
|
||||||
|
.attr("y", function(d) { return Math.min(d.source.y, d.target.y) + Math.abs(d.source.y - d.target.y) / 2; });
|
||||||
|
|
||||||
|
|
||||||
node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
|
node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue