Skip to content

Instantly share code, notes, and snippets.

@codetricity
Created August 31, 2018 13:10
Show Gist options
  • Select an option

  • Save codetricity/19635385ebf457bec9b7bf5cac0c7000 to your computer and use it in GitHub Desktop.

Select an option

Save codetricity/19635385ebf457bec9b7bf5cac0c7000 to your computer and use it in GitHub Desktop.
d3 example
var dataset = [
"No", "one", "can", "tell", "me,",
"Nobody", "knows,",
"Where", "the", "wind", "comes", "from,",
"Where", "the", "wind", "goes."];
var width = 900;
var height = 900;
var margin = 100;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.text(function(d){
return d;
})
.attr("x", function(d, i){
return i * 30 + margin;
})
.attr("y", function(d, i){
return i * 30 + margin;
})
.attr("class", "words")
.attr("transform", function(d, i){
var angle = i * 30;
var x = i * 30 + margin;
var y = i * 30 + margin;
return "rotate(" + angle + "," +
x + "," + y + ")" +
"scale(0.5, 0.5) ";
})
.style('fill', function(d, i){
var b = i * 13;
return 'rgb(211,' + b + ' ,255)';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment