Documentation at Data Visualization with D3.js - Week 1
Built with blockbuilder.org
license: mit |
Documentation at Data Visualization with D3.js - Week 1
Built with blockbuilder.org
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { | |
margin:0; | |
position:fixed; | |
top:0; | |
right:0; | |
bottom:0; | |
left:0; | |
} | |
svg { | |
background-color: pink; | |
border: solid 1px gray; | |
/* width: 80%; */ | |
/* height: 70%; */ | |
} | |
rect { | |
fill: white; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
// Feel free to change or delete any of the code you see in this editor! | |
var width = 960; | |
var height = 500; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.attr("viewbox", "0 0 960 500") // x y w h | |
svg.append("text") | |
.text("hello world") | |
.attr("y", height / 2) | |
.attr("x", width / 2) | |
.style("font-family", "georgia") | |
.style("font-size", "50px") | |
.style("font-style", "italic") | |
svg.append("rect") | |
.attr("y", height / 10) | |
.attr("x", width / 10) | |
.attr("width", 100) | |
.attr("height", 100) | |
</script> | |
</body> |