-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-6.html
91 lines (90 loc) · 3.76 KB
/
page-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
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
<!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>Idiomas del mundo</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"><a class="page-link" href="page-5.html">5</a></li>
<li class="page-item active"><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 = 900;
var height = 360;
//los datos
var data = [
{pais : "Chino Mandarín", superficie : 1092000000},
{pais : "Inglés", superficie : 984000000},
{pais : "Español", superficie : 528000000},
{pais : "Hindi", superficie : 381000000},
{pais : "Árabe", superficie : 292000000},
{pais : "Ruso", superficie : 267000000}
];
//selecciona el svg
var svg = d3.select("svg")
.attr("width", width)
.attr("height", height)
.style("background-image","url(http://sumamente.com.mx/wp-content/uploads/2014/04/el-mundo-iii.jpg)")
.style("background-size","cover")
.style ("background-position", "center center");
//selecciona el grupo
var g = svg.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform", "translate(75,0)")
//mete un "circle"
g.append("circle")
.attr("cx", function(d, i) { return i * (width/(data.length+1)) + 50; })
.attr("cy", function(d, i) { return height/2; })
.attr("r", function(d) { return d.superficie/20000000; })
.attr("fill","#db3e0a")
//mete un "text"
g.append("text")
.attr("x", function(d, i) { return i * (width/(data.length+1)) + 50; })
.attr("y", height/1.4)
.attr("text-anchor","middle")
.attr("fill","#ffffff")
.text(function(d) { return d.pais; })
//mete otro "text"
g.append("text")
.attr("x", function(d, i) { return i * (width/(data.length+1)) + 50; })
.attr("y", height-80)
.attr("font-size","10")
.attr("text-anchor","middle")
.attr("fill","#ffffff")
.text(function(d) { return d.superficie; })
</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>