git ssb

2+

dinoworm 🐛 / ssb-graphviz



Commit 0acc3cf490d4cdb39255ca110e2975c7c7d40768

add node-data & link hover behaviour

mix irving committed on 12/6/2016, 10:53:22 PM
Parent: 981ed08561e580c3f6f34242a8388c7614bdcb69

Files changed

graph.jschanged
index.jschanged
graph.jsView
@@ -15,9 +15,12 @@
1515 .filter(id => friends[friend][id] === true)
1616 const edges = friendOfFriends.map(friendOfFriend => {
1717 return {
1818 fromId: friend,
19- toId: friendOfFriend
19 + toId: friendOfFriend,
20 + data: {
21 + hidden: true
22 + }
2023 }
2124 })
2225 return [
2326 ...sofar,
index.jsView
@@ -11,9 +11,12 @@
1111 gravity: -0.4,
1212 theta : 0.4,
1313 dragCoeff : 0.04
1414 },
15- link: () => {
15 + link: (link) => {
16 + // if (link.data.hidden) return
17 + // makes linkUI element not exist ? => display.getLink doesn't work
18 +
1619 return {
1720 fromColor: 0x000066,
1821 toColor: 0x000066
1922 }
@@ -23,9 +26,25 @@
2326 module.exports = function (sbot, cb) {
2427 Graph(sbot, (err, data) => {
2528 if (err) return cb(err)
2629 const str = JSON.stringify(data)
27- const graph = fromJson(str)
28- const display = Renderer(graph, config)
30 + var graph = fromJson(str)
31 + var display = Renderer(graph, config)
32 +
33 + display.on('nodehover', handleNodeHover)
2934 cb(null, display)
35 +
36 +
37 + function handleNodeHover (node) {
38 + if (node === undefined) return
39 +
40 + node.links
41 + .map(link => display.getLink(link.id))
42 + .forEach(linkUI => {
43 + let color = 0x80ffffff
44 + linkUI.fromColor = color
45 + linkUI.toColor = color
46 + })
47 + }
3048 })
3149 }
50 +

Built with git-ssb-web