From 9e2fc8d9f1ed78c7854453ac5ffbd9d4a80e8c6d Mon Sep 17 00:00:00 2001 From: frajuar <franciscojavier.juarez@estudiantes.uva.es> Date: Sun, 15 Dec 2024 18:10:40 +0100 Subject: [PATCH] sin prints de debug --- Js/script.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Js/script.js b/Js/script.js index 984522b..37c237c 100644 --- a/Js/script.js +++ b/Js/script.js @@ -13,7 +13,7 @@ document.addEventListener('DOMContentLoaded', function () { // Convert the value to a number if it's a valid number, otherwise keep it as a string const value = isNaN(fila[key]) ? fila[key] : parseFloat(fila[key]); countryData.push(value); - /*console.log(value);*/ + } }); paises.push(countryData); @@ -39,7 +39,7 @@ function dibujaSelector(){ // Escuchar cambios en el selector select.addEventListener("change", function () { seleccionAnno = select.value; // Actualizar la variable seleccionAnno - /* console.log(seleccionAnno);*/ + dibujaMapa(seleccionAnno); }); } @@ -47,7 +47,7 @@ function dibujaSelector(){ function dibujaMapa(seleccionAnno) { - /*console.log(paises);*/ + anno=parseInt(seleccionAnno); let datosAnno=[]; @@ -55,7 +55,7 @@ function dibujaMapa(seleccionAnno) { datosAnno.push(paises[i][anno-1959]); }/**aqui seleccionamos los valores para los paises y el anno seleccionado para poder tener el maximo y el minimo*/ - //console.log(datosAnno); + let min=Math.min(...datosAnno.filter(value => value !== 0)); /* minimo y maximo para poder hacer la escala de colores */ let max=Math.max(...datosAnno); @@ -92,7 +92,7 @@ function dibujaMapa(seleccionAnno) { geojson.features.forEach(function (feature) { const countryName = feature.properties.name; const index = paises.findIndex(p => p[0] === countryName); - //console.log(`Buscando: ${countryName}, Encontrado en Ãndice: ${index}`); + if (index !== -1) { // Agregar un valor de datosAnno al GeoJSON feature.properties.value = datosAnno[index]; @@ -107,7 +107,7 @@ function dibujaMapa(seleccionAnno) { .attr("d", path) .style("fill", function (d) { const value = d.properties.value; - // console.log(value); + return value === 0 ? "#cce5df" : colores(Math.log(value)); // Colores para paÃses con datos }) .style("stroke-width", 0.55) @@ -218,14 +218,10 @@ function dibujaGrafico(country,paises){ let index; for(i=0;i<paises.length;i++){ if(paises[i][0]===country){ - // console.log(paises[i][0]); index=i; - //datosPais.push(paises[i]); - } } datosPais=paises[index]; - console.log(datosPais); const datos = nombresDeVariables.map((year, i) => ({ Year: parseInt(year), Valor: typeof datosPais[i + 1] === "number" ? datosPais[i + 1] : null -- GitLab