Skip to content

Instantly share code, notes, and snippets.

@danaoira
Last active June 7, 2017 07:33
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 danaoira/4a5d95a597eae4d15a90d6e56ebf048e to your computer and use it in GitHub Desktop.
Save danaoira/4a5d95a597eae4d15a90d6e56ebf048e to your computer and use it in GitHub Desktop.
hello-world
license: mit
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment