-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_empty_page_template.html
More file actions
222 lines (181 loc) · 6.47 KB
/
01_empty_page_template.html
File metadata and controls
222 lines (181 loc) · 6.47 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A Page Template for Our Session!</title>
<!-- d3 reference snippet -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style type="text/css">
/* Any CSS style rules can go here */
.metisText{
font-family: "Garamond";
}
</style>
</head>
<body>
<div class='section'>
Hello, METIS!
</div>
<div class='section'>
Hello again, METIS!
</div>
<div id="container">
</div>
<script type="text/javascript">
//COMMENT IN AND THEN OUT, SECTION BY SECTION
// SELECTIONS: MIXING D3, HTML AND CSS
// d3.select('.section')
// .text('D3 was here');
// SELECT ALL
// d3.selectAll('.section')
// .text('D3 was here');
//FIRST creating svg elements
// var myFirstWord = "hello";
// var width=500;
// var height=700;
// var circleRadius=200;
// var aNumber = 6;
// // Your beautiful D3 code will go here
// // Create SVG element
// var svg = d3.select("body") //CAN ALSO DO "SELECT("#CONTAINER")
// .append("svg")
// .attr("width", width)
// .attr("height", height);
// svg
// .append("circle")
// .attr("cx", width/2)
// .attr("cy", height/2)
// .attr("r", circleRadius/2)
// .attr("fill", "purple")
// .attr("opacity", .1);
// svg
// .append("circle")
// .attr("cx", 50)
// .attr("cy", 50)
// .attr("r", 60)
// .attr("fill", "purple")
// .attr("opacity", .1);
// svg
// .append("circle")
// .attr("cx", 60)
// .attr("cy", 50)
// .attr("r", 10)
// .attr("fill", "purple")
// .attr("opacity", .1);
// svg
// .append("circle")
// .attr("cx", 70)
// .attr("cy", 50)
// .attr("r", 5)
// .attr("fill", "purple")
// .attr("opacity", .1);
//SECOND: data and svg elements
// var width=500;
// var height=700;
// var leftMargin = 50;
// var circleRadius=[30,20,10,10,5,1,30,20,10,10,5,1,30,20,10,10,5,1,30,20,10,10,5,1,30,20,10,10,5,1,30,20,10,10,5,1,30,20,10,10,5,1];
// //Create SVG element
// var svg = d3.select("body")
// .append("svg")
// .attr("width", width)
// .attr("height", height);
// svg
// .selectAll("circle")
// .data(circleRadius)
// .enter()
// .append("circle")
// .attr("cx", function(d,i){
// return leftMargin+i*40;
// })
// .attr("cy", 50)
// .attr("r", function(d){return d; })
// .attr("fill", "purple")
// .attr("opacity", .1);
//THIRD: selecting by css classes
// var width=500;
// var height=700;
// var leftMargin = 50;
// var circleRadius=[30,20,10,1,5,1];
// // Your beautiful D3 code will go here
// //Create SVG element
// var svg = d3.select("body")
// .append("svg")
// .attr("width", width)
// .attr("height", height);
// svg
// .selectAll("circle")
// .data(circleRadius)
// .enter()
// .append("circle")
// .attr("cx", function(d,i){ return leftMargin+i*40; })
// .attr("cy", 50)
// .attr("r", function(d){return d; })
// .attr("fill", "purple")
// .attr("opacity", .1);
// svg
// .selectAll(".metisText")
// .data(circleRadius)
// .enter()
// .append("text")
// .attr("class","metisText")//GOTCHA
// .attr("x", function(d,i){ return leftMargin+i*40; })
// .attr("y",50)
// .text(function(d){ return d; })
//FOURTH: scales + dynamic placement!
// var width=500;
// var height=700;
// var leftMargin = 50;
// var circleRadius=[30,70,50,35,50,45,10,80,40,30,20,65];
// var mapCircleX = d3.scale.linear()
// .domain([0, circleRadius.length])
// .range([leftMargin, width-leftMargin]);
// var maxRadius = d3.max(circleRadius, function(d,i) {
// return d;
// });
// var mapCircleY = d3.scale.linear()
// .domain([0, maxRadius])
// .range([0, height/2]);
// // Your beautiful D3 code will go here
// //Create SVG element
// var svg = d3.select("body")
// .append("svg")
// .attr("width", width)
// .attr("height", height);
// svg
// .selectAll("circle")
// .data(circleRadius)
// .enter()
// .append("circle")
// .attr("cx", function(d,i){
// return width/2;
// // return mapCircleX(i);
// // return leftMargin+i*40;
// })
// .attr("cy", function(d){
// return height/4;
// // return mapCircleY(d);
// })
// .attr("r", function(d){return d; })
// .attr("fill", "blue")
// .attr("opacity", .1);
// .attr("dataId","population");
// svg
// .selectAll("text")
// // .data(circleRadius)
// // .enter()
// .append("text")
// .attr("x",
// // function(d,i){
// width/2+maxRadius)
// //
// // return mapCircleX(i);
// // return leftMargin+i*40;
// // })
// .attr("y", function(d){
// return height/4;
// // return mapCircleY(d);
// })
// .text(maxRadius)
</script>
</body>
</html>