-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path线段.html
41 lines (41 loc) · 884 Bytes
/
线段.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
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<script>
var data = [
{x:10,y:10},
{x:50,y:100},
{x:60,y:50},
{x:100,y:30}
];
var svg = d3.select('body')
.append('svg')
.attr({
'width': 800,
'height': 800
});
var line = d3.svg.line()
.x(function(d){
return d.x;
})
.y(function(d){
return d.y;
}).interpolate('step-after');
svg.append('path')
.attr({
'd': line(data),
'y': 0,
'stroke': '#000',
'stroke-width': '5px',
'fill': 'none'
});
</script>
</body>
</html>