-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-5.html
90 lines (88 loc) · 3.74 KB
/
page-5.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
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
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Hola D3.js!</title>
</head>
<body>
<div class="container py-3">
<div class="row">
<div class="col-md-12 py-3">
<h1>STAR WARS PLANETS</h1>
</div>
<div class="col-md-12 pt-2">
<svg></svg>
</div>
<div class="col-md-12 pt-3">
<nav aria-label="navegacion">
<ul class="pagination">
<li class="page-item"><a class="page-link" href="index.html">Portada</a></li>
<li class="page-item"><a class="page-link" href="page-1.html">1</a></li>
<li class="page-item"><a class="page-link" href="page-2.html">2</a></li>
<li class="page-item"><a class="page-link" href="page-3.html">3</a></li>
<li class="page-item"><a class="page-link" href="page-4.html">4</a></li>
<li class="page-item active"><a class="page-link" href="page-5.html">5</a></li>
<li class="page-item"><a class="page-link" href="page-6.html">6</a></li>
<li class="page-item"><a class="page-link" href="page-7.html">7</a></li>
<li class="page-item"><a class="page-link" href="page-8.html">8</a></li>
</ul>
</nav>
</div>
</div>
</div>
<!--D3.js-->
<script src="https://d3js.org/d3.v5.min.js"></script>
<script>
//variables globales
var width = 1000;
var height = 450;
//los datos
var data = [
{ name: 'Tatooine', population: 200000},
{ name: 'Alderaan', population: 2000000000},
{ name: 'Yavin IV', population: 824006},
{ name: 'Bespin', population: 6000000},
{name: 'Naboo', population:4500000000}
];
//selecciona el svg
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height)
.style("background-image","url(https://blog.oup.com/wp-content/uploads/2015/12/stars-sky-night-party-lights.jpg)")
.style("background-size","cover")
.style ("background-position", "center center");
;
//seleccionar el grupo
var g = svg.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform", "translate(100,0)")
//dentro del grupo, crear círculos
g.append("circle")
.attr("cx", function(d, i) { return i * (width/(data.length+1)) + 50; })
.attr("cy", function(d) { return height/2; })
.attr("r", function(d) { return d.population/60000000; })
.attr("fill","#ffd621")
//dentro del mismo grupo, agregar un texto
g.append("text")
.attr("x", function(d, i) { return i * (width/(data.length+1)) + 48; })
.attr("y", (height/2)+1)
.attr("fill","#ffffff")
.text(function(d) { return ". " + d.name; })
//dentro del mismo grupo, agregar otr texto
g.append("text")
.attr("x", function(d, i) { return i * (width/(data.length+1)) + 56; })
.attr("y", (height/2)+16)
.attr("fill","#db840a")
.text(function(d) { return "("+d.population+")"; })
.style("font-size","10px")
</script>
<!-- jQuery primero, luego Popper.js, y finalmente Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>