Skip to content

Instantly share code, notes, and snippets.

@jasondavies
Created July 27, 2011 16:54
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 jasondavies/1109813 to your computer and use it in GitHub Desktop.
Save jasondavies/1109813 to your computer and use it in GitHub Desktop.
Paths Example for r43ch
<!DOCTYPE html>
<html>
<head>
<title>Paths</title>
<script src="http://mbostock.github.com/d3/d3.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
path {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
</head>
<body>
<script>
var w = 450,
h = 275,
p = 20;
var vis = d3.select("body")
.append("svg:svg")
.attr("width", w + p * 2)
.attr("height", h + p * 2)
.append("svg:g")
.attr("transform", "translate(" + p + "," + p + ")");
// Array of paths, each path is an array of coordinates
var data = [
[[0, 0], [100, 50]],
[[0, 50], [100, 0]]
];
var g = vis.selectAll("g.chartLines")
.data(data)
.enter().append("svg:g")
.attr("class", "chartLines")
.append("svg:path")
.attr("class", "chartLine")
.attr("d", d3.svg.line());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment