git ssb

2+

dinoworm 🐛 / ssb-graphviz



Commit 915c479a5dddab0aacc02f7e0f910c9154e48806

minor cleanup

Michael Williams committed on 12/7/2016, 7:03:01 AM
Parent: 0acc3cf490d4cdb39255ca110e2975c7c7d40768

Files changed

index.jschanged
renderer.jsadded
index.jsView
@@ -1,8 +1,8 @@
11 const fs = require('fs')
22 const Path = require('path')
33 const fromJson = require('ngraph.fromjson')
4-const Renderer = require('ngraph.pixel')
4 +const Renderer = require('./renderer')
55 const Graph = require('./graph')
66
77 const config = {
88 physics: {
@@ -28,23 +28,8 @@
2828 if (err) return cb(err)
2929 const str = JSON.stringify(data)
3030 var graph = fromJson(str)
3131 var display = Renderer(graph, config)
32-
33- display.on('nodehover', handleNodeHover)
3432 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- }
4833 })
4934 }
5035
renderer.jsView
@@ -1,0 +1,23 @@
1 +const Renderer = require('ngraph.pixel')
2 +
3 +module.exports = createRenderer
4 +
5 +function createRenderer (graph, config) {
6 + var display = Renderer(graph, config)
7 +
8 + display.on('nodehover', handleNodeHover)
9 +
10 + return display
11 +
12 + function handleNodeHover (node) {
13 + if (node === undefined) return
14 +
15 + node.links
16 + .map(link => display.getLink(link.id))
17 + .forEach(linkUI => {
18 + const color = 0x80ffffff
19 + linkUI.fromColor = color
20 + linkUI.toColor = color
21 + })
22 + }
23 +}

Built with git-ssb-web