Commit 688da4a8 authored by Mike Bostock's avatar Mike Bostock
Browse files

Remove line examples.

parent 1926a889
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path, .axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
.dot {
fill: white;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="../../d3.js"></script>
<script>
var data = d3.range(40).map(function(i) {
return {x: i / 39, y: i % 5 ? (Math.sin(i / 3) + 2) / 4 : null};
});
var margin = {top: 10, right: 10, bottom: 20, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.linear()
.domain([0, 1])
.range([0, width]);
var y = d3.scale.linear()
.domain([0, 1])
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var line = d3.svg.line()
.defined(function(d) { return d.y != null; })
.x(function(d) { return x(d.x); })
.y(function(d) { return y(d.y); });
var svg = d3.select("body").append("svg")
.datum(data)
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
svg.append("path")
.attr("class", "line")
.attr("d", line);
svg.selectAll(".dot")
.data(data.filter(function(d) { return d.y; }))
.enter().append("circle")
.attr("class", "dot")
.attr("cx", line.x())
.attr("cy", line.y())
.attr("r", 3.5);
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="../../d3.js"></script>
<script>
var data = d3.range(120).map(function(i) {
return i % 10
? .8 + Math.sin(i / 3 * Math.PI) / 6
: null;
});
var width = 960,
height = 500;
var radius = d3.scale.linear()
.domain([0, 1])
.range([height / 3, height / 2]);
var angle = d3.scale.linear()
.domain([0, data.length])
.range([0, 2 * Math.PI]);
var line = d3.svg.line.radial()
.defined(function(d) { return d != null; })
.interpolate("basis")
.radius(radius)
.angle(function(d, i) { return angle(i); });
var svg = d3.select("body").append("svg")
.datum(data)
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
svg.append("path")
.attr("class", "line")
.attr("d", line);
</script>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
</style>
<body>
<script src="../../d3.js"></script>
<script>
var data = d3.range(120).map(function(i) {
return .8 + Math.sin(i / 3 * Math.PI) / 6;
});
var width = 960,
height = 500;
var radius = d3.scale.linear()
.domain([0, 1])
.range([height / 3, height / 2]);
var angle = d3.scale.linear()
.domain([0, data.length])
.range([0, 2 * Math.PI]);
var line = d3.svg.line.radial()
.interpolate("basis-closed")
.radius(radius)
.angle(function(d, i) { return angle(i); });
var svg = d3.select("body").append("svg")
.datum(data)
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
svg.append("path")
.attr("class", "line")
.attr("d", line);
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment