@@ -390,4 +475,4 @@ function BiosamplesResults (props) {
)
}
-export default BiosamplesResults
+export default BiosamplesResults
\ No newline at end of file
diff --git a/frontend/src/components/Cohorts/Cohorts.css b/frontend/src/components/Cohorts/Cohorts.css
index 16d6a59..75fde08 100644
--- a/frontend/src/components/Cohorts/Cohorts.css
+++ b/frontend/src/components/Cohorts/Cohorts.css
@@ -8,7 +8,7 @@
}
#chartEthnicity {
- width: 90vw;
+ width: 90%;
margin-top: 29px;
}
@@ -107,6 +107,115 @@
align-items: center;
}
+.tab-content {
+ display: none;
+}
+
+.tab:target .tab-content,
+.tab:last-of-type .tab-content {
+ display: block;
+}
+
+.tab:target ~ .tab:last-of-type .tab-content {
+ display: none;
+}
+
+.tabs * {
+ box-sizing: border-box;
+}
+
+.tab-container {
+ position: relative;
+ padding-top: var(--tabs-height); /* en esta zona colocaremos las pestañas */
+ margin-left: 40px;
+ margin-right: 40px;
+ margin-top: 0px;
+}
+#tab1 > a {
+ --tabs-position: 0;
+}
+#tab2 > a {
+ --tabs-position: 1;
+}
+#tab3 > a {
+ --tabs-position: 2;
+}
+#tab4 > a {
+ --tabs-position: 3;
+}
+#tab5 > a {
+ --tabs-position: 4;
+}
+#tab6 > a {
+ --tabs-position: 5;
+}
+#tab7 > a {
+ --tabs-position: 6;
+}
+#tab8 > a {
+ --tabs-position: 7;
+}
+#tab9 > a {
+ --tabs-position: 8;
+}
+.tab > a {
+ text-align: center;
+ position: absolute;
+ width: calc(var(--tabs-width));
+ height: calc(var(--tabs-height) + var(--tabs-border-size));
+ top: 0;
+ left: calc(
+ var(--tabs-width) * var(--tabs-position)
+ ); /* posición de cada pestaña */
+}
+:root {
+ --tabs-border-color: #abcdef;
+ --tabs-border-size: 3px;
+ --tabs-text-color: white;
+ --tabs-dark-color: #2768aa;
+ --tabs-lite-color: #adafc2;
+ --tabs-width: 150px;
+ --tabs-height: 60px;
+ font-size: 14px;
+ margin: 10px;
+}
+.tabs {
+ width: 100vw;
+ color: var(--tabs-text-color);
+}
+.tab-content {
+ background-color: var(--tabs-lite-color);
+ padding: 20px;
+ border: var(--tabs-border-size) solid var(--tabs-border-color);
+ border-radius: 0 0 10px 10px;
+ position: relative;
+ z-index: 100;
+}
+.tab > a {
+ background-color: var(--tabs-dark-color);
+ padding: 10px;
+ border: var(--tabs-border-size) solid var(--tabs-border-color);
+ border-radius: 10px 10px 0 0;
+ border-bottom: 0;
+}
+.tab:target > a,
+.tab:last-of-type > a {
+ background-color: var(--tabs-lite-color);
+ z-index: 200;
+}
+.tab:target ~ .tab:last-of-type > a {
+ background-color: var(--tabs-dark-color);
+ z-index: 0;
+}
+
+h2,
+p {
+ margin: 0;
+}
+a {
+ color: inherit;
+ text-decoration: none;
+}
.ethFilters {
display: flex;
margin-top: 31px;
@@ -213,11 +322,19 @@
}
#chartDiseases {
- width: 100vw;
+ width: 100%;
min-height: 300px !important;
margin-top: 29px;
}
+.diseases{
+ width: 100%;
+}
+
+.ethnicity{
+ width: 100%;
+}
+
h12 {
color: #7fb68c;
font-weight: 500;
@@ -316,7 +433,7 @@ h12 {
}
50% {
transform: scaleY(1);
- background: #8fed0b;
+ background: #34ce7e;
}
100% {
transform: scaleY(0.1);
diff --git a/frontend/src/components/Cohorts/Cohorts.js b/frontend/src/components/Cohorts/Cohorts.js
index 89fb0ba..8f27fbc 100644
--- a/frontend/src/components/Cohorts/Cohorts.js
+++ b/frontend/src/components/Cohorts/Cohorts.js
@@ -60,9 +60,9 @@ function Cohorts (props) {
const [noCollectionEvents, setNoCollectionEvents] = useState(false)
- const handleSelectedFilter = e => {
- setSelectedFilter(e.target.value)
- }
+ //const handleSelectedFilter = e => {
+ //setSelectedFilter(e.target.value)
+ //}
const handleSelectedValue = e => {
setSelectedValue(e.target.value)
@@ -186,351 +186,346 @@ function Cohorts (props) {
}
}, [response])
- const submitFilters = e => {
- if (selectedFilter === 'dis_eth') {
- setShowDis2(false)
- setShowEth2(false)
- setShowEth(false)
- setShowDis(true)
- if (
- dis_eth[valueToFilter] !== null &&
- dis_eth[valueToFilter] !== undefined
- ) {
- setResponse(dis_eth[`${valueToFilter}`])
- } else {
- setError('Not found')
- }
- } else if (selectedFilter === 'dis_sex') {
- setShowDis(false)
- setShowEth2(false)
- setShowEth(false)
- setShowDis2(true)
- if (
- dis_sex[valueToFilter] !== null &&
- dis_sex[valueToFilter] !== undefined
- ) {
- setResponse(dis_sex[`${valueToFilter}`])
- } else {
- setError('Not found')
- }
- } else if (selectedFilter === 'eth_sex') {
- setShowDis2(false)
- setShowDis(false)
- setShowEth(false)
- setShowEth2(true)
- if (
- eth_sex[valueToFilter] !== null &&
- eth_sex[valueToFilter] !== undefined
- ) {
- setResponse(eth_sex[`${valueToFilter}`])
- } else {
- setError('Not found')
- }
- } else if (selectedFilter === 'eth_dis') {
- setShowDis2(false)
- setShowDis(false)
- setShowEth2(false)
- setShowEth(true)
- if (
- eth_dis[valueToFilter] !== null &&
- eth_dis[valueToFilter] !== undefined
- ) {
- setResponse(eth_dis[`${valueToFilter}`])
- } else {
- setError('Not found')
- }
- }
- }
+ // const submitFilters = e => {
+ // if (selectedFilter === 'dis_eth') {
+ // setShowDis2(false)
+ // setShowEth2(false)
+ // setShowEth(false)
+ // setShowDis(true)
+ // if (
+ // dis_eth[valueToFilter] !== null &&
+ // dis_eth[valueToFilter] !== undefined
+ // ) {
+ // setResponse(dis_eth[`${valueToFilter}`])
+ // } else {
+ // setError('Not found')
+ // }
+ // } else if (selectedFilter === 'dis_sex') {
+ // setShowDis(false)
+ // setShowEth2(false)
+ // setShowEth(false)
+ // setShowDis2(true)
+ // if (
+ // dis_sex[valueToFilter] !== null &&
+ // dis_sex[valueToFilter] !== undefined
+ // ) {
+ // setResponse(dis_sex[`${valueToFilter}`])
+ // } else {
+ // setError('Not found')
+ // }
+ // } else if (selectedFilter === 'eth_sex') {
+ // setShowDis2(false)
+ // setShowDis(false)
+ // setShowEth(false)
+ // setShowEth2(true)
+ // if (
+ // eth_sex[valueToFilter] !== null &&
+ // eth_sex[valueToFilter] !== undefined
+ // ) {
+ // setResponse(eth_sex[`${valueToFilter}`])
+ // } else {
+ // setError('Not found')
+ // }
+ // } else if (selectedFilter === 'eth_dis') {
+ // setShowDis2(false)
+ // setShowDis(false)
+ // setShowEth2(false)
+ // setShowEth(true)
+ // if (
+ // eth_dis[valueToFilter] !== null &&
+ // eth_dis[valueToFilter] !== undefined
+ // ) {
+ // setResponse(eth_dis[`${valueToFilter}`])
+ // } else {
+ // setError('Not found')
+ // }
+ // }
+ // }
useEffect(() => {
console.log(selectedCohorts)
console.log(arrayCohorts)
const apiCall = () => {
arrayCohorts.forEach(element => {
- console.log(element)
- selectedCohorts.forEach(element2 => {
- if (element.id === element2[0].value) {
-
- if (element.collectionEvents) {
- console.log("holi")
- element.collectionEvents.forEach(element2 => {
- if (Object.keys(element2).length !== 0) {
- let sexs = ''
- let ethnicities = ''
- let geoData = ''
- let diseasesData = ''
- let diseases_eth = ''
- let diseases_sex = ''
- let ethnicities_dis = ''
- let ethnicities_sex = ''
- let valuesSex = ''
- let labelsSex = ''
- let valuesEthnicities = ''
- let labelsEthnicities = ''
- let valuesGeo = ''
- let labelsGeo = ''
- let entriesGeo = ''
- let valuesDiseases = ''
- let labelsDiseases = ''
-
- // for (var i = 0; i < res.data.response.collections.length; i++) {
- if (element2.eventGenders !== undefined) {
- sexs = element2.eventGenders.distribution.genders
-
- setDataAvailable(true)
- }
- if (element2.eventEthnicities !== undefined) {
- ethnicities =
- element2.eventEthnicities.distribution.ethnicities
- }
- if (element2.eventLocations !== undefined) {
- geoData = element2.eventLocations.distribution.locations
- }
- if (element2.eventDiseases !== undefined) {
- diseasesData = element2.eventDiseases.distribution.diseases
- diseases_eth =
- element2.eventDiseases.distribution.diseases_ethnicity
- diseases_sex =
- element2.eventDiseases.distribution.diseases_sex
- }
+ console.log(element)
+
+ if (element.id === selectedCohorts.value) {
+ if (element.collectionEvents) {
+ element.collectionEvents.forEach(element2 => {
+ if (Object.keys(element2).length !== 0) {
+ let sexs = ''
+ let ethnicities = ''
+ let geoData = ''
+ let diseasesData = ''
+ let diseases_eth = ''
+ let diseases_sex = ''
+ let ethnicities_dis = ''
+ let ethnicities_sex = ''
+ let valuesSex = ''
+ let labelsSex = ''
+ let valuesEthnicities = ''
+ let labelsEthnicities = ''
+ let valuesGeo = ''
+ let labelsGeo = ''
+ let entriesGeo = ''
+ let valuesDiseases = ''
+ let labelsDiseases = ''
+
+ // for (var i = 0; i < res.data.response.collections.length; i++) {
+ if (element2.eventGenders !== undefined) {
+ sexs = element2.eventGenders.distribution.genders
+
+ setDataAvailable(true)
+ }
+ if (element2.eventEthnicities !== undefined) {
+ ethnicities =
+ element2.eventEthnicities.distribution.ethnicities
+ }
+ if (element2.eventLocations !== undefined) {
+ geoData = element2.eventLocations.distribution.locations
+ }
+ if (element2.eventDiseases !== undefined) {
+ diseasesData = element2.eventDiseases.distribution.diseases
+ diseases_eth =
+ element2.eventDiseases.distribution.diseases_ethnicity
+ diseases_sex =
+ element2.eventDiseases.distribution.diseases_sex
+ }
- if (diseases_eth !== '') {
- setDisEth(diseases_eth)
- setFilterDisEth(true)
- }
- if (diseases_sex !== '') {
- setDisSex(diseases_sex)
- setFilterDisSex(true)
- }
+ if (diseases_eth !== '') {
+ setDisEth(diseases_eth)
+ setFilterDisEth(true)
+ }
+ if (diseases_sex !== '') {
+ setDisSex(diseases_sex)
+ setFilterDisSex(true)
+ }
- if (element2.eventEthnicities !== undefined) {
- ethnicities_dis =
- element2.eventEthnicities.distribution.ethnicities_disease
- ethnicities_sex =
- element2.eventEthnicities.distribution.ethnicities_sex
- }
+ if (element2.eventEthnicities !== undefined) {
+ ethnicities_dis =
+ element2.eventEthnicities.distribution.ethnicities_disease
+ ethnicities_sex =
+ element2.eventEthnicities.distribution.ethnicities_sex
+ }
- if (ethnicities_dis !== '') {
- setEthDis(ethnicities_dis)
- setFilterEthDis(true)
- }
- if (ethnicities_sex !== '') {
- setEthSex(ethnicities_sex)
- setFilterEthSex(true)
- }
+ if (ethnicities_dis !== '') {
+ setEthDis(ethnicities_dis)
+ setFilterEthDis(true)
+ }
+ if (ethnicities_sex !== '') {
+ setEthSex(ethnicities_sex)
+ setFilterEthSex(true)
+ }
- setNameCohort(element.name)
+ setNameCohort(element.name)
- if (sexs !== '') {
- valuesSex = Object.values(sexs)
- labelsSex = Object.keys(sexs)
- }
+ if (sexs !== '') {
+ valuesSex = Object.values(sexs)
+ labelsSex = Object.keys(sexs)
+ }
- if (ethnicities !== '') {
- valuesEthnicities = Object.values(ethnicities)
- labelsEthnicities = Object.keys(ethnicities)
- }
+ if (ethnicities !== '') {
+ valuesEthnicities = Object.values(ethnicities)
+ labelsEthnicities = Object.keys(ethnicities)
+ }
- if (labelsEthnicities !== '') {
- setLabelsEthnicities(labelsEthnicities)
- }
- console.log(geoData)
- if (geoData !== '') {
- valuesGeo = Object.values(geoData)
- labelsGeo = Object.keys(geoData)
- entriesGeo = Object.entries(geoData)
- }
+ if (labelsEthnicities !== '') {
+ setLabelsEthnicities(labelsEthnicities)
+ }
+ console.log(geoData)
+ if (geoData !== '') {
+ valuesGeo = Object.values(geoData)
+ labelsGeo = Object.keys(geoData)
+ entriesGeo = Object.entries(geoData)
+ }
- if (diseasesData !== '') {
- valuesDiseases = Object.values(diseasesData)
- labelsDiseases = Object.keys(diseasesData)
- }
+ if (diseasesData !== '') {
+ valuesDiseases = Object.values(diseasesData)
+ labelsDiseases = Object.keys(diseasesData)
+ }
- if (labelsDiseases !== '') {
- setLabelsDiseases(labelsDiseases)
- }
+ if (labelsDiseases !== '') {
+ setLabelsDiseases(labelsDiseases)
+ }
- if (valuesSex !== '' && labelsSex !== '') {
- var optionsSex = {
- chart: {
- type: 'donut'
- },
- title: {
- text: 'Sex'
- },
- series: valuesSex,
- labels: labelsSex
- }
+ if (valuesSex !== '' && labelsSex !== '') {
+ var optionsSex = {
+ chart: {
+ type: 'donut'
+ },
+ title: {
+ text: 'Sex'
+ },
+ series: valuesSex,
+ labels: labelsSex
+ }
- var chartSex = new ApexCharts(
- document.querySelector('#chartSex'),
- optionsSex
- )
+ var chartSex = new ApexCharts(
+ document.querySelector('#chartSex'),
+ optionsSex
+ )
- chartSex.render()
- }
+ chartSex.render()
+ }
- if (valuesEthnicities !== '' && labelsEthnicities !== '') {
- var optionsEthnicity = {
- chart: {
- type: 'bar'
- },
- title: {
- text: 'Ethnicity',
- align: 'center',
- floating: true
- },
- series: [
- {
- name: 'Number of individuals',
- data: valuesEthnicities
- }
- ],
- xaxis: {
- categories: labelsEthnicities
+ if (valuesEthnicities !== '' && labelsEthnicities !== '') {
+ var optionsEthnicity = {
+ chart: {
+ type: 'bar'
+ },
+ title: {
+ text: 'Ethnicity',
+ align: 'center',
+ floating: true
+ },
+ series: [
+ {
+ name: 'Number of individuals',
+ data: valuesEthnicities
}
+ ],
+ xaxis: {
+ categories: labelsEthnicities
}
-
- var chartEthnicity = new ApexCharts(
- document.querySelector('#chartEthnicity'),
- optionsEthnicity
- )
- chartEthnicity.render()
}
- if (valuesGeo !== '' && labelsGeo !== '') {
- var optionsGeo = {
- chart: {
- type: 'pie'
- },
- title: {
- text: 'Geographical origin'
- },
- series: valuesGeo,
- labels: labelsGeo
- }
+ var chartEthnicity = new ApexCharts(
+ document.querySelector('#chartEthnicity'),
+ optionsEthnicity
+ )
+ chartEthnicity.render()
+ }
- var chartGeo = new ApexCharts(
- document.querySelector('#chartGeo'),
- optionsGeo
- )
- chartGeo.render()
+ if (valuesGeo !== '' && labelsGeo !== '') {
+ var optionsGeo = {
+ chart: {
+ type: 'pie'
+ },
+ title: {
+ text: 'Geographical origin'
+ },
+ series: valuesGeo,
+ labels: labelsGeo
}
- if (valuesDiseases !== '' && labelsDiseases !== '') {
- var optionsDiseases = {
- series: [
- {
- data: valuesDiseases
- }
- ],
- chart: {
- type: 'bar',
- height: 630
- },
- plotOptions: {
- bar: {
- barHeight: '100%',
- distributed: true,
- horizontal: true,
- dataLabels: {
- position: 'bottom'
- }
- }
- },
- colors: [
- '#33b2df',
- '#546E7A',
- '#FFD700',
- '#2b908f',
- '#DC143C',
- '#f48024',
- '#69d2e7',
- '#13d8aa',
- '#A5978B',
- '#f9a3a4',
- '#FF4500',
- '#51f08e',
- '#b051f0',
- '#CCFF33',
- '#FF66CC',
- '#FF3333',
- '#6633CC',
- '#CD853F',
- '#3333FF',
- '#FF3333'
- ],
- dataLabels: {
- enabled: true,
- textAnchor: 'start',
- style: {
- colors: ['#fff']
- },
- formatter: function (val, opt) {
- return (
- opt.w.globals.labels[opt.dataPointIndex] +
- ': ' +
- val
- )
- },
- offsetX: 0,
- dropShadow: {
- enabled: true
+ var chartGeo = new ApexCharts(
+ document.querySelector('#chartGeo'),
+ optionsGeo
+ )
+ chartGeo.render()
+ }
+
+ if (valuesDiseases !== '' && labelsDiseases !== '') {
+ var optionsDiseases = {
+ series: [
+ {
+ data: valuesDiseases
+ }
+ ],
+ chart: {
+ type: 'bar',
+ height: 630
+ },
+ plotOptions: {
+ bar: {
+ barHeight: '100%',
+ distributed: true,
+ horizontal: true,
+ dataLabels: {
+ position: 'bottom'
}
- },
- stroke: {
- width: 1,
+ }
+ },
+ colors: [
+ '#33b2df',
+ '#546E7A',
+ '#FFD700',
+ '#2b908f',
+ '#DC143C',
+ '#f48024',
+ '#69d2e7',
+ '#13d8aa',
+ '#A5978B',
+ '#f9a3a4',
+ '#FF4500',
+ '#51f08e',
+ '#b051f0',
+ '#CCFF33',
+ '#FF66CC',
+ '#FF3333',
+ '#6633CC',
+ '#CD853F',
+ '#3333FF',
+ '#FF3333'
+ ],
+ dataLabels: {
+ enabled: true,
+ textAnchor: 'start',
+ style: {
colors: ['#fff']
},
- xaxis: {
- categories: labelsDiseases
+ formatter: function (val, opt) {
+ return (
+ opt.w.globals.labels[opt.dataPointIndex] + ': ' + val
+ )
},
- yaxis: {
- labels: {
- show: false
- }
- },
- title: {
- text: 'Diseases',
- align: 'center',
- floating: true
+ offsetX: 0,
+ dropShadow: {
+ enabled: true
+ }
+ },
+ stroke: {
+ width: 1,
+ colors: ['#fff']
+ },
+ xaxis: {
+ categories: labelsDiseases
+ },
+ yaxis: {
+ labels: {
+ show: false
+ }
+ },
+ title: {
+ text: 'Diseases',
+ align: 'center',
+ floating: true
+ },
+ tooltip: {
+ theme: 'dark',
+ x: {
+ show: false
},
- tooltip: {
- theme: 'dark',
- x: {
- show: false
- },
- y: {
- title: {
- formatter: function () {
- return ''
- }
+ y: {
+ title: {
+ formatter: function () {
+ return ''
}
}
}
}
-
- var chartDiseases = new ApexCharts(
- document.querySelector('#chartDiseases'),
- optionsDiseases
- )
- chartDiseases.render()
}
- setTimeOut(true)
- } else {
- setTimeOut(true)
- setDataAvailable(false)
+
+ var chartDiseases = new ApexCharts(
+ document.querySelector('#chartDiseases'),
+ optionsDiseases
+ )
+ chartDiseases.render()
}
- })
- } else {
- setNoCollectionEvents(true)
- }
+ setTimeOut(true)
+ } else {
+ setTimeOut(true)
+ setDataAvailable(false)
+ }
+ })
+ } else {
+ setNoCollectionEvents(true)
}
- })
+ }
})
}
setTrigger(true)
- if (selectedCohorts.length > 0) {
+ if (selectedCohorts) {
apiCall()
}
}, [showGraphs, trigger])
@@ -674,7 +669,9 @@ function Cohorts (props) {
>
)}
- {trigger && noCollectionEvents &&
NO GRAPHICS AVAILABLE FOR THE SELECTED COHORTS}
+ {trigger && noCollectionEvents && (
+
NO GRAPHICS AVAILABLE FOR THE SELECTED COHORTS
+ )}
{showGraphs === true && dataAvailable === false && timeOut === true && (
diff --git a/frontend/src/components/Cohorts/CohortsModule.js b/frontend/src/components/Cohorts/CohortsModule.js
index 5ad4c8e..2dbe074 100644
--- a/frontend/src/components/Cohorts/CohortsModule.js
+++ b/frontend/src/components/Cohorts/CohortsModule.js
@@ -6,30 +6,27 @@ import makeAnimated from 'react-select/animated'
function CohortsModule (props) {
const [results, setResults] = useState(null)
- const [selectedCohortsAux, setSelectedCohortsAux] = useState([])
+
const animatedComponents = makeAnimated()
+ const [selected, setSelected] = useState(null)
const onSubmitCohorts = () => {
setResults('Cohorts')
props.setShowGraphs(true)
}
const handleChangeCohorts = selectedOption => {
- setSelectedCohortsAux([])
- selectedCohortsAux.push(selectedOption)
- props.setSelectedCohorts(selectedCohortsAux)
+ console.log(selectedOption)
+ setSelected(selectedOption)
+
+ props.setSelectedCohorts(selectedOption)
}
return (