Skip to content

Instantly share code, notes, and snippets.

@quizzicol
Created June 21, 2014 08:25
Show Gist options
  • Save quizzicol/2eb2439c2da655d458e2 to your computer and use it in GitHub Desktop.
Save quizzicol/2eb2439c2da655d458e2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="D3 intro #1" />
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>Drawing SVG Shapes</title>
</head>
<body>
<h3>SVG Bar </h3>
<svg height="300">
<Rect width="50" height="200" style="fill:blue" ></Rect>
</svg>
<script>
d3.select("body") // selects body tag
.append("svg") // add svg element
.append("rect") // add rectangle
.attr("width", 50) // set attribute of width
.attr("height", 100) // set attribute of height
.style("fill", "red");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment