Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
cff596d4
Commit
cff596d4
authored
Jan 16, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diag/net: more powerfil d3 vis
parent
5f81d963
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
diagnostics/d3/chord.html
diagnostics/d3/chord.html
+9
-3
diagnostics/vis.go
diagnostics/vis.go
+7
-1
No files found.
diagnostics/d3/chord.html
View file @
cff596d4
...
...
@@ -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
;
})
...
...
diagnostics/vis.go
View file @
cff596d4
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment