-
Notifications
You must be signed in to change notification settings - Fork 0
/
D3_6.html
31 lines (26 loc) · 964 Bytes
/
D3_6.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="./D3.js" charset="utf-8"></script>
</head>
<body>
</body>
<script charset="utf-8">
var width = 500;
var height = 500;
var svg = d3.select('body').append('svg').attr('width',width).attr('height',height);
var data = [80,120,130,70,60,90];
var areaPaths = d3.area().x(function(d,i){//绘制区域的点的x坐标
return 50 + i*80;
}).y0(function(d,i){//绘制区域的点的y坐标的下限坐标
return height/2;
}).y1(function(d){//绘制区域的点的y坐标的上限坐标
return height/2 - d;
}).curve(d3.curveBasis);
svg.append('path').attr('d',areaPaths(data)).attr('stroke','black').attr('stroke-width','3px').attr('fill','orange');
</script>
</html>