Created
September 28, 2013 22:07
-
-
Save lpand/6747215 to your computer and use it in GitHub Desktop.
graph configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodes = [ | |
{ name: 0, value: 0 }, | |
{ name: 1, value: 1 }, | |
{ name: 2, value: 2 }, | |
{ name: 3, value: 3 } | |
] | |
var edges = [ | |
{ source: nodes[0], target: nodes[1] }, | |
{ source: nodes[3], target: nodes[2] }, | |
{ source: nodes[3], target: nodes[0] }, | |
{ source: nodes[2], target: nodes[3] } | |
] | |
var graphConfig = { | |
nodeClassName: function(d) { return 'gene' }, | |
edgeClassName: 'graph-chart-edge', | |
width: width, | |
height: height, | |
radius: 20, | |
color: function(d) { return '#bcbd22' }, | |
id: function (d, i) { return 'node' + i } | |
} | |
var forceConfig = { | |
size: [width, height], | |
linkDistance: function(link) { | |
// return link.source.weight + link.target.weight > 8 ? 200 : 100 | |
if (link.source.weight > 4 ^ link.target.weight > 4) | |
return 150 | |
if (link.source.weight > 4 && link.target.weight > 4) | |
return 350 | |
return 100 | |
}, | |
charge: -500, | |
gravity: 0.06, // default 0.1 | |
} | |
var textConfig = { | |
'font-family': 'serif', | |
'font-size': '1em', | |
'stroke': '#ff0000', | |
'text-anchor': 'start', | |
'text': function (d, i) { | |
return 'node'+ i } | |
} | |
var config = { | |
graph: graphConfig, | |
force: forceConfig, | |
text: textConfig | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment