Commit cff596d4 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

diag/net: more powerfil d3 vis

parent 5f81d963
......@@ -109,9 +109,12 @@ d3.json(hash, function(error, data) {
.attr("dy", 3)
// .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
// .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; })
.text(function(d) { return d.conns + " - " + d.name; })
.text(function(d) { return d.conns + " - " + (d.rtkey || d.name); })
.attr("transform", function(d) { return "rotate(" + (d.x - 90 + rotate) + ")translate(" + d.y + ")"; })
node.append("svg:title")
.text(function(d) { return d.name; });
// var mid = svg.selectAll(".node-mid")
// .data(graph.mids)
// .enter().append("g")
......@@ -135,8 +138,11 @@ function parseGraph(graph2) {
graph.mids = []
graph2.nodes.sort(function(a, b) {
if (a.name > b.name) return 1;
if (a.name < b.name) return -1;
var aname = a.rtkey || a.name
var bname = b.rtkey || b.name
if (aname > bname) return 1;
if (aname < bname) return -1;
return 0;
})
......
......@@ -4,11 +4,15 @@ import (
"encoding/json"
"fmt"
"io"
peer "github.com/jbenet/go-ipfs/p2p/peer"
rtable "github.com/jbenet/go-ipfs/routing/kbucket"
)
type node struct {
Name string `json:"name"`
Value uint64 `json:"value"`
RtKey string `json:"rtkey"`
}
type link struct {
......@@ -24,7 +28,9 @@ func GetGraphJson(dinfo []*DiagInfo) []byte {
for _, di := range dinfo {
names[di.ID] = len(nodes)
val := di.BwIn + di.BwOut + 10
nodes = append(nodes, &node{Name: di.ID, Value: val})
// include the routing table key, for proper routing table display
rtk := peer.ID(rtable.ConvertPeerID(peer.ID(di.ID))).Pretty()
nodes = append(nodes, &node{Name: di.ID, Value: val, RtKey: rtk})
}
var links []*link
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment