Create a new project called, "wind" with separate files for
- html
- css
- js
link the html file to your css and js files, similar to the previous lesson.
Use d3.select to select the body and then append svg.
Add attributes for width and height.
Use the convention `svg.append("text") to add text to the svg viewport
Your code should look like this:
svg.append("text")
.text("Hello")
.attr("dx", "100")
.attr("dy", "100")
Put the styles in your wind.css file
In your HTML file, you need to link to the css file.
<link rel="stylesheet" href="css/wind.css">
Use Google Fonts to add the fonts.
Example of link to fonts in HTML. You can find the <link> string on Google Fonts.
<link href="https://fonts.googleapis.com/css?family=Cabin|Inconsolata|Nunito|Nunito+Sans|Pacifico|Quicksand|Rubik|VT323" rel="stylesheet">
Example of css
font-family: 'Pacifico', cursive;
var dataset = [
"No", "one", "can", "tell", "me,",
"Nobody", "knows,",
"Where", "the", "wind", "comes", "from,",
"Where", "the", "wind", "goes."];
- The data is a simple array
- To change position, angle, size, color, we are using the index value of each element
- a normal data set would use the number value of each element
svg.selectAll("text")
.data(dataset)
.enter()
.append("text")
.attr("transform", function(d, i){
var angle = i * 30
return "rotate(" + angle + ", 200, 200)";
.text(function(d){
return d;
})



