From d932cb1496e42591d85a64d285e0450a939eaef8 Mon Sep 17 00:00:00 2001 From: Cee <cnell@usgs.gov> Date: Mon, 2 Sep 2024 10:39:45 -0700 Subject: [PATCH] modify data import to use json instead of csv --- public/determinant_uncertainty.csv | 112 ++++++++++++++--------------- src/components/Authorship.vue | 1 - src/components/BeeswarmChart.vue | 41 ++++------- 3 files changed, 70 insertions(+), 84 deletions(-) diff --git a/public/determinant_uncertainty.csv b/public/determinant_uncertainty.csv index 6164358..9480977 100644 --- a/public/determinant_uncertainty.csv +++ b/public/determinant_uncertainty.csv @@ -1,56 +1,56 @@ -dimension,determinant,determinant_wrapped,pos_related_total,neg_related_total,unrelated_total,unk_direction_total,evidence_val,sig_value,level_agreement,evidence_bin,agreement_bin -Demographic characteristics,Age,Age,28,5,0,3,36,28,77.77777777777779,Large,High -Demographic characteristics,Citizenship,Citizenship,1,2,0,0,3,2,66.66666666666666,Small,Medium -Demographic characteristics,Ethnicity and race,Ethnicity and race,44,11,0,3,58,44,75.86206896551724,Large,High -Demographic characteristics,Family structure,Family structure,9,2,0,1,12,9,75,Large,High -Demographic characteristics,Gender,Gender,9,1,0,0,10,9,90,Large,High -Demographic characteristics,Group facilities,Group facilities,1,0,0,0,1,1,100,Small,High -Demographic characteristics,Language proficiency,Language proficiency,8,2,0,0,10,8,80,Large,High -Demographic characteristics,Migration,Migration,5,3,0,0,8,5,62.5,Medium,Medium -Demographic characteristics,Political inclination,Political inclination,1,1,0,0,2,1,50,Small,NA -Demographic characteristics,Social dependence,Social dependence,5,0,0,0,5,5,100,Medium,High -Demographic characteristics,Special needs/ disabilities,Special needs/disabilities,2,0,0,0,2,2,100,Small,High -Exposure,# Of events,# of events,3,0,0,0,3,3,100,Small,High -Exposure,Exposed areas / facilities,Exposed areas/facilities,13,3,0,6,22,13,59.09090909090909,Large,Medium -Exposure,Exposed population,Exposed population,7,0,0,0,7,7,100,Medium,High -Exposure,Hazard extent,Hazard extent,11,2,0,0,13,11,84.61538461538461,Large,High -Exposure,Losses suffered,Losses suffered,7,2,0,0,9,7,77.77777777777779,Medium,High -Exposure,Mitigation,Mitigation,4,9,0,2,15,9,60,Large,Medium -Exposure,Other - physical considerations,Other - physical factors,24,11,0,8,43,24,55.81395348837209,Large,Medium -Exposure,Preparedness,Preparedness,2,3,0,0,5,3,60,Medium,Medium -Health,Access,Access,4,1,0,0,5,4,80,Medium,High -Health,Caloric intake/ food insecurity,Calories/food Insecurity,0,1,0,0,1,1,100,Small,High -Health,Disease burden / morbidity,Disease/morbidity,2,1,0,0,3,2,66.66666666666666,Small,Medium -Health,Life expectancy,Life expectancy,0,1,0,0,1,1,100,Small,High -Health,Mortality,Mortality,1,0,0,0,1,1,100,Small,High -Health,Potable water access,Potable water access,2,2,1,0,5,2,40,Medium,Low -Health,Sanitation,Sanitation,1,0,0,0,1,1,100,Small,High -Land tenure,Owners,Owners,5,1,0,3,9,5,55.55555555555556,Medium,Medium -Land tenure,Private property,Private property,0,0,0,1,1,1,100,Small,High -Land tenure,Renters,Renters,7,5,0,0,12,7,58.333333333333336,Large,Medium -Land tenure,Tenure length,Tenure length,2,1,0,0,3,2,66.66666666666666,Small,Medium -Living conditions,Housing quality,Housing quality,2,0,0,0,2,2,100,Small,High -Living conditions,Housing type,Housing type,2,0,0,0,2,2,100,Small,High -Living conditions,Land use,Land use,8,4,0,1,13,8,61.53846153846154,Large,Medium -Living conditions,Lifelines & infrastructure,Infrastructure,8,2,0,3,13,8,61.53846153846154,Large,Medium -Living conditions,Population,Population,13,2,0,4,19,13,68.42105263157895,Large,Medium -Living conditions,Resource dependence,Resource dependence,9,1,0,1,11,9,81.81818181818183,Large,High -Living conditions,Rurality,Rurality,3,5,0,0,8,5,62.5,Medium,Medium -Living conditions,Socially isolated populations,Isolated populations,1,0,0,0,1,1,100,Small,High -Living conditions,Urbanization,Urbanization,4,3,0,0,7,4,57.14285714285714,Medium,Medium -Living conditions,Vacant housing units,Vacant housing units,3,0,0,0,3,3,100,Small,High -Living conditions,Vehicular access,Vehicular access,6,0,0,1,7,6,85.71428571428571,Medium,High -Risk perception,Awareness,Awareness,4,3,0,1,8,4,50,Medium,NA -Risk perception,Prior experience,Prior experience,6,3,0,0,9,6,66.66666666666666,Medium,Medium -Risk perception,Risk denial/ acceptance,Risk denial/acceptance,3,3,0,0,6,3,50,Medium,NA -Risk perception,Social capital,Social capital,1,4,0,0,5,4,80,Medium,High -Risk perception,Trust in officials,Trust in officials,1,1,0,2,4,2,50,Small,NA -Socioeconomic status,Access to basic needs,Access to basic needs,1,0,0,0,1,1,100,Small,High -Socioeconomic status,Education,Education,15,6,0,0,21,15,71.42857142857143,Large,Medium -Socioeconomic status,Employment,Employment,8,1,0,0,9,8,88.88888888888889,Medium,High -Socioeconomic status,House value,House value,1,4,0,0,5,4,80,Medium,High -Socioeconomic status,Income,Income,14,18,0,1,33,18,54.54545454545454,Large,Medium -Socioeconomic status,Literacy,Literacy,0,2,0,0,2,2,100,Small,High -Socioeconomic status,Median rent,Median rent,1,4,0,0,5,4,80,Medium,High -Socioeconomic status,Occupation,Occupation,7,1,0,1,9,7,77.77777777777779,Medium,High -Socioeconomic status,Wealth,Wealth,17,1,0,0,18,17,94.44444444444444,Large,High \ No newline at end of file +dimension,determinant,determinant_wrapped,pos_related_total,neg_related_total,unrelated_total,unk_direction_total,evidence_val,sig_value,level_agreement,evidence_bin,agreement_bin,determinant_es +Demographic characteristics,Age,Age,28,5,0,3,36,28,77.77777777777779,Large,High,Edad +Demographic characteristics,Citizenship,Citizenship,1,2,0,0,3,2,66.66666666666666,Small,Medium,Ciudadan’a +Demographic characteristics,Ethnicity and race,Ethnicity and race,44,11,0,3,58,44,75.86206896551724,Large,High,Etnia/razaÊ +Demographic characteristics,Family structure,Family structure,9,2,0,1,12,9,75,Large,High,Estructura familiarÊ +Demographic characteristics,Gender,Gender,9,1,0,0,10,9,90,Large,High,GŽneroÊ +Demographic characteristics,Group facilities,Group facilities,1,0,0,0,1,1,100,Small,High,Instalaciones de grupoÊ +Demographic characteristics,Language proficiency,Language proficiency,8,2,0,0,10,8,80,Large,High,Dominio del idiomaÊ +Demographic characteristics,Migration,Migration,5,3,0,0,8,5,62.5,Medium,Medium,Migraci—nÊ +Demographic characteristics,Political inclination,Political inclination,1,1,0,0,2,1,50,Small,NA,Inclinaci—n pol’ticaÊ +Demographic characteristics,Social dependence,Social dependence,5,0,0,0,5,5,100,Medium,High,Dependencia socialÊ +Demographic characteristics,Special needs/ disabilities,Special needs/disabilities,2,0,0,0,2,2,100,Small,High,Necesidades especiales/discapacidadesÊ +Exposure,# Of events,# of events,3,0,0,0,3,3,100,Small,High,N.¼ de ocurrenciasÊ +Exposure,Exposed areas / facilities,Exposed areas/facilities,13,3,0,6,22,13,59.09090909090909,Large,Medium,çreas/instalaciones expuestasÊ +Exposure,Exposed population,Exposed population,7,0,0,0,7,7,100,Medium,High,Poblaci—n expuestaÊ +Exposure,Hazard extent,Hazard extent,11,2,0,0,13,11,84.61538461538461,Large,High,çrea de riesgoÊ +Exposure,Losses suffered,Losses suffered,7,2,0,0,9,7,77.77777777777779,Medium,High,PŽrdidas sufridasÊ +Exposure,Mitigation,Mitigation,4,9,0,2,15,9,60,Large,Medium,Mitigaci—nÊ +Exposure,Other - physical considerations,Other - physical factors,24,11,0,8,43,24,55.81395348837209,Large,Medium,Otros -- factores f’sicosÊ +Exposure,Preparedness,Preparedness,2,3,0,0,5,3,60,Medium,Medium,Prevenci—nÊ +Health,Access,Access,4,1,0,0,5,4,80,Medium,High,AccesoÊ +Health,Caloric intake/ food insecurity,Calories/food Insecurity,0,1,0,0,1,1,100,Small,High,Calor’as/Inseguridad alimentariaÊ +Health,Disease burden / morbidity,Disease/morbidity,2,1,0,0,3,2,66.66666666666666,Small,Medium,Enfermedad/morbilidadÊ +Health,Life expectancy,Life expectancy,0,1,0,0,1,1,100,Small,High,Esperanza de vidaÊ +Health,Mortality,Mortality,1,0,0,0,1,1,100,Small,High,MortalidadÊ +Health,Potable water access,Potable water access,2,2,1,0,5,2,40,Medium,Low,Acceso a agua potableÊ +Health,Sanitation,Sanitation,1,0,0,0,1,1,100,Small,High,SaneamientoÊ +Land tenure,Owners,Owners,5,1,0,3,9,5,55.55555555555556,Medium,Medium,PropietariosÊ +Land tenure,Private property,Private property,0,0,0,1,1,1,100,Small,High,Propiedad privadaÊ +Land tenure,Renters,Renters,7,5,0,0,12,7,58.333333333333336,Large,Medium,Personas que alquilanÊ +Land tenure,Tenure length,Tenure length,2,1,0,0,3,2,66.66666666666666,Small,Medium,Duraci—n de la tenenciaÊ +Living conditions,Housing quality,Housing quality,2,0,0,0,2,2,100,Small,High,Calidad de la viviendaÊ +Living conditions,Housing type,Housing type,2,0,0,0,2,2,100,Small,High,Tipo de viviendaÊ +Living conditions,Land use,Land use,8,4,0,1,13,8,61.53846153846154,Large,Medium,Uso del terrenoÊ +Living conditions,Lifelines & infrastructure,Infrastructure,8,2,0,3,13,8,61.53846153846154,Large,Medium,InfraestructuraÊ +Living conditions,Population,Population,13,2,0,4,19,13,68.42105263157895,Large,Medium,Poblaci—nÊ +Living conditions,Resource dependence,Resource dependence,9,1,0,1,11,9,81.81818181818183,Large,High,Dependencia de los recursosÊ +Living conditions,Rurality,Rurality,3,5,0,0,8,5,62.5,Medium,Medium,RuralidadÊ +Living conditions,Socially isolated populations,Isolated populations,1,0,0,0,1,1,100,Small,High,Poblaciones aisladasÊ +Living conditions,Urbanization,Urbanization,4,3,0,0,7,4,57.14285714285714,Medium,Medium,Urbanizaci—nÊ +Living conditions,Vacant housing units,Vacant housing units,3,0,0,0,3,3,100,Small,High,Viviendas vac’asÊ +Living conditions,Vehicular access,Vehicular access,6,0,0,1,7,6,85.71428571428571,Medium,High,Acceso con veh’culoÊ +Risk perception,Awareness,Awareness,4,3,0,1,8,4,50,Medium,NA,ConcienciaÊ +Risk perception,Prior experience,Prior experience,6,3,0,0,9,6,66.66666666666666,Medium,Medium,Experiencia previaÊ +Risk perception,Risk denial/ acceptance,Risk denial/acceptance,3,3,0,0,6,3,50,Medium,NA,Negaci—n/aceptaci—n del riesgoÊ +Risk perception,Social capital,Social capital,1,4,0,0,5,4,80,Medium,High,Capital socialÊ +Risk perception,Trust in officials,Trust in officials,1,1,0,2,4,2,50,Small,NA,Confianza en los funcionariosÊ +Socioeconomic status,Access to basic needs,Access to basic needs,1,0,0,0,1,1,100,Small,High,Acceso a necesidades b‡sicasÊ +Socioeconomic status,Education,Education,15,6,0,0,21,15,71.42857142857143,Large,Medium,Educaci—nÊ +Socioeconomic status,Employment,Employment,8,1,0,0,9,8,88.88888888888889,Medium,High,EmpleoÊ +Socioeconomic status,House value,House value,1,4,0,0,5,4,80,Medium,High,Valor de la viviendaÊ +Socioeconomic status,Income,Income,14,18,0,1,33,18,54.54545454545454,Large,Medium,IngresosÊ +Socioeconomic status,Literacy,Literacy,0,2,0,0,2,2,100,Small,High,AlfabetismoÊ +Socioeconomic status,Median rent,Median rent,1,4,0,0,5,4,80,Medium,High,Media de alquilerÊ +Socioeconomic status,Occupation,Occupation,7,1,0,1,9,7,77.77777777777779,Medium,High,Profesi—nÊ +Socioeconomic status,Wealth,Wealth,17,1,0,0,18,17,94.44444444444444,Large,High,RiquezaÊ \ No newline at end of file diff --git a/src/components/Authorship.vue b/src/components/Authorship.vue index 1281307..59c940d 100644 --- a/src/components/Authorship.vue +++ b/src/components/Authorship.vue @@ -95,7 +95,6 @@ } }, mounted() { - console.log(this.appTitle) this.showAuthors = this.primaryAuthors.length > 0 ? true : false // Show author statements for any authors this.showAdditionalAuthors = this.additionalAuthors.length > 0 ? true : false // Show author statements for additional authors if any are listed this.showAditionalContributionStatement = this.additionalAuthors.length > 0 ? true : false // Show contributions statements for additional authors if any are listed AND showContributionStatements is true diff --git a/src/components/BeeswarmChart.vue b/src/components/BeeswarmChart.vue index ece4875..2dfc6ca 100644 --- a/src/components/BeeswarmChart.vue +++ b/src/components/BeeswarmChart.vue @@ -73,14 +73,11 @@ import * as d3 from 'd3'; import { useI18n } from 'vue-i18n'; const { t } = useI18n(); - -console.log(t('text.components.chartText.bubbleCheckbox')); // Check if this logs the correct text +const userLang = navigator.language || navigator.userLanguage; +const isSpanish = userLang.startsWith('es'); // Global variables const publicPath = import.meta.env.BASE_URL; -const dataSet1 = ref([]); -const dataSet2 = ref([]); -const selectedDataSet = ref('dataSet1'); const data = ref([]); // Set up SVG @@ -142,7 +139,7 @@ function createPattern() { .attr('stroke-width', 3); } function createLegend() { - const keyW = 30; + const keyW = 35; const keyH = 12; createPattern(); @@ -167,8 +164,7 @@ function createLegend() { // Load data and then make chart onMounted(async () => { try { - await loadDatasets(); - data.value = selectedDataSet.value === 'dataSet1' ? dataSet1.value : dataSet2.value; + data.value = await loadJsonData('determinant_uncertainty.json'); if (data.value.length > 0) { createBeeswarmChart(); createLegend(); @@ -180,25 +176,10 @@ onMounted(async () => { } }); -async function loadDatasets() { - try { - dataSet1.value = await loadData('determinant_uncertainty.csv'); - dataSet2.value = await loadData('indicator_uncertainty.csv'); - console.log('data in'); - } catch (error) { - console.error('Error loading datasets', error); - } -} - -async function loadData(fileName) { +async function loadJsonData(fileName) { try { - const data = await d3.csv(publicPath + fileName, d => { - d.level_agreement = +(+d.level_agreement).toFixed(2); - d.evidence_val = +d.evidence_val; - d.sig_value = +d.sig_value; - return d; - }); - return data; + const loadedData = await d3.json(publicPath + fileName); + return loadedData; } catch (error) { console.error(`Error loading data from ${fileName}`, error); return []; @@ -360,8 +341,14 @@ function handleMouseOver(event, d) { const tooltip = d3.select('#tooltip'); const tooltipTemplate = "{determinant} {appeared} {count} {studyLabel}" // construct tempalte of tooltip sentence + function getTranslatedDeterminant(d) { + return isSpanish ? d.determinant_es : d.determinant_wrapped; + } + const translatedDeterminant = getTranslatedDeterminant(d); + console.log(translatedDeterminant) + // Dynamic values - const determinant = `<strong>${d.determinant_wrapped}</strong>`; + const determinant = `<strong>${translatedDeterminant}</strong>`; const count = d.evidence_val; const studyLabel = d.evidence_val === 1 ? t('text.components.chartText.singleStudy') : t('text.components.chartText.multipleStudies'); const appeared = t('text.components.chartText.appeared'); -- GitLab