Skip to content

Instantly share code, notes, and snippets.

@lpand
Last active December 24, 2015 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpand/6752419 to your computer and use it in GitHub Desktop.
Save lpand/6752419 to your computer and use it in GitHub Desktop.
Keeps the bubbles inside the force bounds and draws text if so configured
config.force.tick = function() {
graphChart.links.attr({
x1: function(d) { return d.source.x },
y1: function(d) { return d.source.y },
x2: function(d) { return d.target.x },
y2: function(d) { return d.target.y } })
graphChart.bubbles
.selectAll('circle')
.attr({
cx: function(d) {
return d.x = Math.max(r, Math.min(w - r, d.x)) },
cy: function(d) {
return d.y = Math.max(r, Math.min(h - r, d.y)) } })
text && text.attr({
x: function(d) { return d.x },
y: function(d) { return d.y } })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment