-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-8.html
83 lines (83 loc) · 3.11 KB
/
page-8.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
<!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>
<style>
rect {
fill: steelblue;
}
rect:hover {
fill: orange;
}
</style>
</head>
<body>
<div class="container py-3">
<div class="row">
<div class="col-md-12 py-3">
<h1>D3.js</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"><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 active"><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, factorEscala = 10, altoBarra = 25;
//variables datos
var data = [
5, 10, 12,40,20,30,35,40,70,40,29
];
//toma el svg
var graph = d3.select("svg")
.attr("width", width)
//la altura se ajusta
.attr("height", altoBarra * data.length)
.style("background","#EEEEEE");
//crea un gráfico
var bar = graph.selectAll("g")
.data(data)
.enter()
.append("g")
.attr("transform", function(d, i) {
return "translate(38," + i * altoBarra + ")";
});
bar.append("rect")
.attr("width", function(d) {
return d * factorEscala;
})
.attr("height", altoBarra - 5);
bar.append("text")
.attr("x", -5)
.attr("y", altoBarra / 2)
.attr("dy", ".25em")
.attr("text-anchor","end")
.text(function(d) { return d; });
</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>