JPLTedCas commited on
Commit
3cada53
·
verified ·
1 Parent(s): c7404c6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +82 -32
index.html CHANGED
@@ -1,18 +1,41 @@
1
  <!DOCTYPE html>
2
- <!DOCTYPE html>
3
  <html lang="es">
4
  <head>
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <title>Mapa Interactivo con Gráfico</title>
8
  <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css"/>
9
  <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
10
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
11
  <style>
12
  #map { height: 500px; width: 100%; }
13
  #controls { margin: 10px; }
14
- #chart-container { width: 80%; margin: 20px auto; }
15
- canvas { width: 100%; height: 300px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  </style>
17
  </head>
18
  <body>
@@ -32,28 +55,27 @@
32
 
33
  <div id="map"></div>
34
 
35
- <div id="chart-container">
36
  <canvas id="connectionsChart"></canvas>
 
37
  </div>
38
 
39
  <script>
40
 
41
  var locations = [
42
- { name: "Ragusa", coords: [36.9257, 14.7244], category: "operative", connections: 24 }, // Ragusa, Italia
43
- { name: "Seville", coords: [37.3886, -5.9823], category: "operative", connections: 9 }, // Sevilla, España
44
- { name: "Groningen", coords: [53.2194, 6.5665], category: "operative", connections: 13 }, // Groningen, Países Bajos
45
- { name: "Cape Town", coords: [-33.9249, 18.4241], category: "operative", connections: 1 }, // Ciudad del Cabo, Sudáfrica
46
- { name: "Bern", coords: [46.9481, 7.4474], category: "operative", connections: 0 }, // Berna, Suiza
47
- { name: "Kiel", coords: [54.3233, 10.1228], category: "removed", connections: 0 }, // Kiel, Alemania
48
- { name: "Le Mans", coords: [17.0151, 54.0924], category: "assessment", connections: 0 }, // Salalah, Omán
49
- { name: "Le Mans", coords: [48.0077, 0.1996], category: "assessment", connections: 0 }, // Le Mans, Francia
50
- { name: "Gdansk", coords: [54.3520, 18.6466], category: "assessment", connections: 0 }, // Gdansk, Polonia
51
- { name: "Prague", coords: [50.0755, 14.4378], category: "assessment", connections: 0 }, // Praga, República Checa
52
- { name: "Kuwait", coords: [29.3759, 47.9774], category: "assessment", connections: 0 } // Kuwait, Kuwait
53
  ];
54
 
55
-
56
-
57
  var map = L.map('map').setView([50.0755, 14.4378], 3); // Mapa centrado en Europa
58
 
59
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
@@ -70,7 +92,8 @@
70
  };
71
 
72
  var markers = [];
73
- var chart = null; // Variable para almacenar el gráfico
 
74
 
75
  function updateMarkers() {
76
  var selectedCategory = document.getElementById("category").value;
@@ -105,24 +128,24 @@
105
  map.setView([45, 10], 3); // Vista inicial si no hay puntos
106
  }
107
 
108
- // Actualizar el gráfico
109
- updateChart(filteredLocations);
110
  }
111
 
112
- function updateChart(filteredLocations) {
113
- // Obtener los datos para el gráfico
114
  var cityNames = filteredLocations.map(location => location.name);
115
  var connectionsData = filteredLocations.map(location => location.connections);
 
116
  var categoryColorsData = filteredLocations.map(location => categoryColors[location.category]);
117
 
118
- // Si el gráfico ya existe, destruirlo y crear uno nuevo
119
- if (chart) {
120
- chart.destroy();
121
- }
122
 
123
- // Crear el gráfico
124
- var ctx = document.getElementById('connectionsChart').getContext('2d');
125
- chart = new Chart(ctx, {
126
  type: 'bar',
127
  data: {
128
  labels: cityNames,
@@ -146,11 +169,38 @@
146
  }
147
  }
148
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
 
151
- // Mostrar todos los marcadores y gráfico al inicio
152
  updateMarkers();
153
  </script>
154
 
155
  </body>
156
- </html>
 
1
  <!DOCTYPE html>
 
2
  <html lang="es">
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Mapa Interactivo con Gráficos</title>
7
  <link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css"/>
8
  <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
9
  <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10
  <style>
11
  #map { height: 500px; width: 100%; }
12
  #controls { margin: 10px; }
13
+ /* Contenedor de los dos gráficos */
14
+ .chart-container {
15
+ width: 30%; /* Ancho total del contenedor */
16
+ margin: 20px auto; /* Centrado */
17
+ display: flex; /* Flexbox para alinear los gráficos en fila */
18
+ justify-content: space-between; /* Espacio entre los gráficos */
19
+ flex-wrap: wrap; /* Permite que los gráficos se acomoden si no caben */
20
+ }
21
+
22
+ /* Cada gráfico ocupa el 40% del ancho */
23
+ .chart-container canvas {
24
+ width: 48%; /* Cada gráfico ocupa un 48% del contenedor */
25
+ height: 300px;
26
+ }
27
+
28
+ /* Media Query para pantallas pequeñas */
29
+ @media (max-width: 768px) {
30
+ .chart-container {
31
+ width: 90%; /* Aumentar el ancho del contenedor a 90% en pantallas más pequeñas */
32
+ }
33
+
34
+ .chart-container canvas {
35
+ width: 100%; /* Los gráficos ocuparán todo el ancho disponible */
36
+ height: 250px; /* Ajustar la altura si es necesario */
37
+ }
38
+ }
39
  </style>
40
  </head>
41
  <body>
 
55
 
56
  <div id="map"></div>
57
 
58
+ <div class="chart-container">
59
  <canvas id="connectionsChart"></canvas>
60
+ <canvas id="supportTimeChart"></canvas>
61
  </div>
62
 
63
  <script>
64
 
65
  var locations = [
66
+ { name: "Ragusa", coords: [36.9257, 14.7244], category: "operative", connections: 24, avgSupportTime: 12 }, // Ragusa, Italia
67
+ { name: "Seville", coords: [37.3886, -5.9823], category: "operative", connections: 9, avgSupportTime: 1 }, // Sevilla, España
68
+ { name: "Groningen", coords: [53.2194, 6.5665], category: "operative", connections: 13, avgSupportTime: 3 }, // Groningen, Países Bajos
69
+ { name: "Cape Town", coords: [-33.9249, 18.4241], category: "operative", connections: 1, avgSupportTime: 0 }, // Ciudad del Cabo, Sudáfrica
70
+ { name: "Bern", coords: [46.9481, 7.4474], category: "operative", connections: 0, avgSupportTime: 0 }, // Berna, Suiza
71
+ { name: "Kiel", coords: [54.3233, 10.1228], category: "removed", connections: 0, avgSupportTime: 0 }, // Kiel, Alemania
72
+ { name: "Le Mans", coords: [17.0151, 54.0924], category: "assessment", connections: 0, avgSupportTime: 0 }, // Salalah, Omán
73
+ { name: "Le Mans", coords: [48.0077, 0.1996], category: "assessment", connections: 0, avgSupportTime: 0 }, // Le Mans, Francia
74
+ { name: "Gdansk", coords: [54.3520, 18.6466], category: "assessment", connections: 0, avgSupportTime: 0 }, // Gdansk, Polonia
75
+ { name: "Prague", coords: [50.0755, 14.4378], category: "assessment", connections: 0, avgSupportTime: 0 }, // Praga, República Checa
76
+ { name: "Kuwait", coords: [29.3759, 47.9774], category: "assessment", connections: 0, avgSupportTime: 0 } // Kuwait, Kuwait
77
  ];
78
 
 
 
79
  var map = L.map('map').setView([50.0755, 14.4378], 3); // Mapa centrado en Europa
80
 
81
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
 
92
  };
93
 
94
  var markers = [];
95
+ var chart1 = null; // Gráfico de conexiones
96
+ var chart2 = null; // Gráfico de soporte
97
 
98
  function updateMarkers() {
99
  var selectedCategory = document.getElementById("category").value;
 
128
  map.setView([45, 10], 3); // Vista inicial si no hay puntos
129
  }
130
 
131
+ // Actualizar los gráficos
132
+ updateCharts(filteredLocations);
133
  }
134
 
135
+ function updateCharts(filteredLocations) {
136
+ // Obtener los datos para los gráficos
137
  var cityNames = filteredLocations.map(location => location.name);
138
  var connectionsData = filteredLocations.map(location => location.connections);
139
+ var avgSupportTimeData = filteredLocations.map(location => location.avgSupportTime);
140
  var categoryColorsData = filteredLocations.map(location => categoryColors[location.category]);
141
 
142
+ // Si los gráficos ya existen, destruirlos y crear nuevos
143
+ if (chart1) chart1.destroy();
144
+ if (chart2) chart2.destroy();
 
145
 
146
+ // Crear el gráfico de conexiones
147
+ var ctx1 = document.getElementById('connectionsChart').getContext('2d');
148
+ chart1 = new Chart(ctx1, {
149
  type: 'bar',
150
  data: {
151
  labels: cityNames,
 
169
  }
170
  }
171
  });
172
+
173
+ // Crear el gráfico de tiempo de soporte
174
+ var ctx2 = document.getElementById('supportTimeChart').getContext('2d');
175
+ chart2 = new Chart(ctx2, {
176
+ type: 'bar',
177
+ data: {
178
+ labels: cityNames,
179
+ datasets: [{
180
+ label: 'Average Monthly Support Time (hrs)',
181
+ data: avgSupportTimeData,
182
+ backgroundColor: categoryColorsData, // Asignar color según categoría
183
+ borderColor: categoryColorsData, // Asignar color según categoría
184
+ borderWidth: 1
185
+ }]
186
+ },
187
+ options: {
188
+ responsive: true,
189
+ scales: {
190
+ y: {
191
+ beginAtZero: true,
192
+ ticks: {
193
+ stepSize: 1
194
+ }
195
+ }
196
+ }
197
+ }
198
+ });
199
  }
200
 
201
+ // Mostrar todos los marcadores y gráficos al inicio
202
  updateMarkers();
203
  </script>
204
 
205
  </body>
206
+ </html>