From d4538e3dc7761d4122817e5845690b64dff0c0b5 Mon Sep 17 00:00:00 2001 From: lucassoni <lucassonit@gmail.com> Date: Fri, 29 Jul 2022 12:00:37 -0300 Subject: [PATCH] fix some bugs --- src/components/BottomTableComponent.js | 2 +- src/components/Charts/BarChartComponent.js | 21 +++++++++++++++------ src/components/Map/LegendComponent.js | 1 + src/components/Map/MapComponent.js | 4 +++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/components/BottomTableComponent.js b/src/components/BottomTableComponent.js index 3622f8c..783c0ee 100644 --- a/src/components/BottomTableComponent.js +++ b/src/components/BottomTableComponent.js @@ -108,7 +108,7 @@ function BottomTableComponent(props) { const evadido = tableData.reduce((sum, item) => sum + item.evadido, 0) const trancado = tableData.reduce((sum, item) => sum + item.trancado, 0) const concluinte = tableData.reduce((sum, item) => sum + item.concluinte, 0) - const taxaEvasao = ((evadido/(cursando+concluinte+evadido+trancado))*100).toFixed(2) + const taxaEvasao = ((cursando + concluinte + evadido + trancado) > 0) ? ((evadido/(cursando+concluinte+evadido+trancado))*100).toFixed(2) : 0 const totalObjectSituation = { cursando: cursando, diff --git a/src/components/Charts/BarChartComponent.js b/src/components/Charts/BarChartComponent.js index c950eec..3cd292b 100644 --- a/src/components/Charts/BarChartComponent.js +++ b/src/components/Charts/BarChartComponent.js @@ -35,7 +35,7 @@ function BarChartComponent(props) { // const { title, data, education } = props; const { title, years, chartLocation, dimension_data, dims, loading, filtersLocation, filtersEducation, disciplines, contrastSet, horizontalChart } = props; - + // const [yearsString, setYearsString] = useState(""); const [selectedFilters, setSelectedFilters] = useState([]); const [isOpen, setIsOpen] = useState(false); const [noDataComponentToggle, setNoDataComponentToggle] = useState(false); @@ -207,7 +207,6 @@ function BarChartComponent(props) { formattedFilters + ', ' + mappedFilters[idx][jdx] } } - setSelectedFilters(formattedFilters) }, [filtersEducation]) @@ -430,7 +429,7 @@ function BarChartComponent(props) { } for (i = 0; i < size; i++) { if (location.pathname === routes.adequacao_disciplina) { - newSeries[i].data[i] = ((suitable[i] / total[i]) * 100).toFixed(1) + newSeries[i].data[i] = total[i] !== 0 ? ((suitable[i] / total[i]) * 100).toFixed(1) : 0 } else { newSeries[i].data[i] = total[i] - suitable[i] } @@ -463,6 +462,15 @@ function BarChartComponent(props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [loading, filtersLocation, contrastSet]); + function generateSubtitle() { + let data = props.data; + let tempString = `${chartLocation} - ` + tempString = tempString.concat(`${data[0].year} a ${data[data.length - 1].year}`) + + return tempString; + } + + return ( <> { loading ? @@ -476,9 +484,10 @@ function BarChartComponent(props) { : <div className={`bar-chart-container ${contrastSet ? "high-contrast-bar-chart" : ""}`}> { - years[0] === years[1] ? - <h4 className="bar-chart-subtitle">{`${chartLocation} - ${years[0]}`}</h4> : - <h4 className="bar-chart-subtitle">{`${chartLocation} - ${years[0]} a ${years[1]}`}</h4> + // years[0] === years[1] ? + // <h4 className="bar-chart-subtitle">{`${chartLocation} - ${years[0]}`}</h4> : + // <h4 className="bar-chart-subtitle">{`${chartLocation} - ${years[0]} a ${years[1]}`}</h4> + <h4 className="bar-chart-subtitle">{ generateSubtitle() }</h4> } { selectedFilters !== '' && diff --git a/src/components/Map/LegendComponent.js b/src/components/Map/LegendComponent.js index 831ab2d..548c320 100644 --- a/src/components/Map/LegendComponent.js +++ b/src/components/Map/LegendComponent.js @@ -51,6 +51,7 @@ class LegendComponent extends MapControl { componentDidMount() { this.legend = L.control({ position: "bottomright" }); + this.legend.update = () => { let title = '<h4 class="legend-title">' if (this.props.title) diff --git a/src/components/Map/MapComponent.js b/src/components/Map/MapComponent.js index b857032..091f35e 100644 --- a/src/components/Map/MapComponent.js +++ b/src/components/Map/MapComponent.js @@ -421,7 +421,7 @@ function MapComponent(props) { titleValue = finishedDataObj.length !== 0 ? finishedDataObj[0].total.toLocaleString('pt-BR') : '0' } else if (path[4] === 'situacao_ingressantes') { const maxYearDataObj = mapTitleData.filter(item => item.year === titleYear) - percentEvaded = maxYearDataObj.length !== 0 ? maxYearDataObj[0].taxa_evasao.toFixed(1) : 0 + percentEvaded = maxYearDataObj.length !== 0 ? maxYearDataObj[0]?.taxa_evasao?.toFixed(1) : 0 if (percentEvaded === '0.0') percentEvaded = 0 } else if (path[4] === 'situacao_matriculas') { const maxYearDataObj = mapTitleData.filter(item => item.year === titleYear) @@ -462,6 +462,8 @@ function MapComponent(props) { case 'concluintes_licenciatura': return titleLocation + ' tem ' + titleValue + ' concluintes em cursos de licenciatura, ' + titleYear case 'situacao_ingressantes': + if (percentEvaded === undefined) + percentEvaded = 0; return titleLocation + ' tem ' + percentEvaded + '% de evasão em cursos de licenciatura, ' + titleYear case 'situacao_matriculas': return titleLocation + ' tem ' + maxYearCoursing + ' matrÃculas cursando, ' + maxYearEvaded + ' evadidos, ' + -- GitLab