-
Notifications
You must be signed in to change notification settings - Fork 0
/
linePathExample.html
29 lines (28 loc) · 1.14 KB
/
linePathExample.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="d3.min.js"></script>
</head>
<body>
<script type="text/javascript">
var data = [{"x": 100, "y":100}, {"x": 300, "y": 300}, {"x": 100, "y": 200}, {"x": 500, "y": 500}, {"x": 100, "y": 400}, {"x": 600, "y": 600}],
width = 600,
height = 600,
svgContainer = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height),
lineFunction = d3.svg.line()
.x(function (d) { return d.x;})
.y(function (d) { return d.y;}),
line = svgContainer.selectAll('path')
.data([data])
.enter()
.append('path')
.attr('d', lineFunction)
.attr('fill', 'none')
.attr('stroke', 'purple')
.attr('stroke-width', 5);
</script>
</body>
</html>