forked from pages-themes/minimal
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathanimatetest.html
More file actions
38 lines (31 loc) · 938 Bytes
/
animatetest.html
File metadata and controls
38 lines (31 loc) · 938 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content=
"width=device-width, initial-scale=1.0">
<svg width='500' height='500'>
</svg>
</head>
<body>
<!-- Fetching from CDN of D3.js -->
<script type="text/javascript"
src="https://d3js.org/d3.v4.min.js">
</script>
<script>
const svg = d3.select('svg')
var legend_keys = ["Austin", "New York", "San Francisco"]
var lineLegend = svg.selectAll(".lineLegend").data(legend_keys)
.enter().append("g")
.attr("class","lineLegend")
.attr("transform", function (d,i) {
return "translate(" + width + "," + (i*20)+")";
});
lineLegend.append("text").text(function (d) {return d;})
.attr("transform", "translate(15,9)"); //align texts with boxes
lineLegend.append("rect")
.attr("fill", function (d, i) {return color_scale(d); })
.attr("width", 10).attr("height", 10);
</script>
</body>
</html>