-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.html
42 lines (37 loc) · 1.31 KB
/
draw.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
42
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Drawing Basic Shapes" />
<meta charset="utf-8">
<title>Drawing SVG Shapes with D3</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
</head>
<body>
<!-- how about a rectangle -->
<h3>SVG Bar</h3>
<svg>
<rect width="50" height="200" style="fill: blue;"/>
</svg>
<!-- trying a rectangle with D3 -->
<h3>D3 Bar</h3>
<script>
d3.select("body") //select the <body> html tag
.append("svg") //add a new <svg> html element
.append("rect") //add a new <rect> html element which will be our bar
.attr("width", 50) //set the width of our bar
.attr("height", 200) //set the height of our bar
.style("fill", "blue"); //fill the bar w/ the color blue
</script>
<!-- trying a circle with D3 -->
<h3>D3 Circle</h3>
<script>
d3.select("body") //select the <body> html tag
.append("svg") //add a new <svg> html element
.append("circle") //add a new <circle> html element which will be our circle
.attr("cx", 25) //set the x-axis of our circle
.attr("cy", 25) //set the y-axis of our circle
.attr("r", 25) //set the radius of the circle
.style("fill", "blue"); //fill the bar w/ the color blue
</script>
</body>
</html>