Skip to content

Instantly share code, notes, and snippets.

@shprink
Created November 11, 2015 15:00
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 shprink/15009b5eb82a97055257 to your computer and use it in GitHub Desktop.
Save shprink/15009b5eb82a97055257 to your computer and use it in GitHub Desktop.
var this.options = {
count: 3,
from: -60,
to: 60
};
var from = Math.max(-90, Math.min(90, +this.options.from));
var to = Math.max(-90, Math.min(90, +this.options.to));
var rotateScale = d3.scale.linear().domain([0, this.options.count - 1]).range([from, to]);
this.layout = d3.layout.cloud()
.timeInterval(Infinity)
.size([this.getWidth(), this.getHeight()])
.padding(5)
.fontSize(function(d) {
return self.fontSize(+d.value);
})
.rotate(function() {
return rotateScale(~~(Math.random() * self.options.count));
})
.text(function(d) {
return d.text;
})
.on("end", draw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment