From 258a634f954e048d6cb5fbf89677e04f3cfe7002 Mon Sep 17 00:00:00 2001 From: Rafael S Castliho <rscastilho@inf.ufpr.br> Date: Mon, 7 Dec 2020 10:09:47 -0300 Subject: [PATCH] =?UTF-8?q?issues=20resolvidas=20at=C3=A9=2011/12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Comunidades_Quilombolas_Certificadas.csv | 2 +- src/Components/CsvBuildLineNotFixed.js | 94 +++++++++++++++++++ src/SubPages/Eixo4.js | 21 +++-- 3 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 src/Components/CsvBuildLineNotFixed.js diff --git a/src/CSV/Comunidades_Quilombolas_Certificadas.csv b/src/CSV/Comunidades_Quilombolas_Certificadas.csv index 40755a78..3531ad71 100644 --- a/src/CSV/Comunidades_Quilombolas_Certificadas.csv +++ b/src/CSV/Comunidades_Quilombolas_Certificadas.csv @@ -1,4 +1,4 @@ -"ID QUILOMBOLA","REGIÃO","UF","MUNICÃPIO ","COMUNIDADE","ETAPA PROCESSO FCP","DATA DA PORTARIA NO DOU","RETIFICAÇÃO NO DOU","Nº DE CRQs" +"ID_QUILOMBOLA","REGIÃO","UF","MUNICÃPIO ","COMUNIDADE","ETAPA_PROCESSO_FCP","DATA_DA_PORTARIA_NO_DOU","RETIFICAÇÃO_NO_DOU","Nº_DE_CRQs" 27,"SUL","RS","MAQUINÉ | OSÓRIO","MORRO ALTO","Certificada",6/4/2004,,1 140,"NORDESTE","PI","QUEIMADA NOVA","TAPUIO","Certificada",6/4/2004,,1 "1,409","NORDESTE","PI","QUEIMADA NOVA","SUMIDOURO","Certificada",6/4/2004,,1 diff --git a/src/Components/CsvBuildLineNotFixed.js b/src/Components/CsvBuildLineNotFixed.js new file mode 100644 index 00000000..1c703d1b --- /dev/null +++ b/src/Components/CsvBuildLineNotFixed.js @@ -0,0 +1,94 @@ +import React, { useState, useEffect } from 'react'; +import BuildLineNotFixed from '../Charts/BuildLineNotFixed' +import * as d3 from 'd3'; + +function CsvBuildLineNotFixed(props){ + + const [ customKeys, setCustomKeys] = useState(props.customKeys) + const [ dataKey, setdataKey] = useState(props.dataKey) + const [ csvTable, setTable ] = useState([]) + + const [ dataPlot, setDataPlot ] = useState([]) + const [ uf, setUF] = useState(props.uf) + const [ chartUpdated, setChartUpdated] = useState(false) + + var len = 0 + useEffect(() => { + var dataCSV = props.data + + d3.csv(dataCSV).then( function(read_csv) { + len = read_csv.length + if (len > 0) { + setTable(read_csv) + } + else{ + setChartUpdated(false) + } + + }); + },[]); + + useEffect(() => { + var newUF = props.uf + if (newUF != uf){ + setUF(newUF) + updateTable(newUF) + } + }); + useEffect(() => { + var newUF = props.uf + if (newUF == uf && csvTable.length > 0 && !chartUpdated){ + updateTable(newUF) + setChartUpdated(true) + } + },[csvTable]); + + + const updateTable = ((uf) =>{ + let aux = {} + let aux2 = [] + let len = csvTable.length + if (uf == ""){ + for (let i = 0; i < len; i = i + 1){ + if (csvTable[i]["ETAPA_PROCESSO_FCP"] == "Certificada"){ + let year = csvTable[i]["DATA_DA_PORTARIA_NO_DOU"].split("/")[2] + if (aux[year] != undefined){ + aux[year] += 1 + } + else{ + aux[year] = 1 + } + } + } + } else { + for (let i = 0; i < len; i = i + 1){ + if (csvTable[i]["ETAPA_PROCESSO_FCP"] == "Certificada" && csvTable[i]["UF"] == uf){ + let year = csvTable[i]["DATA_DA_PORTARIA_NO_DOU"].split("/")[2] + if (aux[year] != undefined){ + aux[year] += 1 + } + else{ + aux[year] = 1 + } + } + } + } + + let keys = Object.keys(aux) + for(let i = 0; i < keys.length; i = i + 1){ + if (keys[i] == "undefined"){ + continue + } + let temp_hash = {} + temp_hash["Ano"] = keys[i] + temp_hash["Total"] = aux[keys[i]] + aux2.push(temp_hash) + } + setDataPlot(aux2) + }) + return( + <BuildLineNotFixed data={(dataPlot)} customKeys={customKeys} dataKey={dataKey} /> + ) +} + +export default CsvBuildLineNotFixed; \ No newline at end of file diff --git a/src/SubPages/Eixo4.js b/src/SubPages/Eixo4.js index 5852bf2c..b915bc69 100644 --- a/src/SubPages/Eixo4.js +++ b/src/SubPages/Eixo4.js @@ -54,6 +54,7 @@ import { mapNotExists } from '../Components/Communities'; import * as data from '../JsonsAntigos/brasil-quilombola/bqe1' import DataFrame from 'dataframe-js'; import CsvTable from '../Components/CsvTable' +import CsvBuildLineNotFixed from '../Components/CsvBuildLineNotFixed' const serverURL = getServerURL(); @@ -68,12 +69,17 @@ const nullKeys = { "valor": "valor" } +// const customNames = { +// "Ano": "Ano", +// "Comunidades Tituladas": "Comunidades Tituladas", +// "Comunidades Certificadas": "Comunidades Certificadas" +// } const customNames = { "Ano": "Ano", - "Comunidades Tituladas": "Comunidades Tituladas", - "Comunidades Certificadas": "Comunidades Certificadas" + "Total": "Comunidades Certificadas" } + const queries = { 'Número de pessoas': 'eixo_4?dims=year', 'Escolaridade Segundo CadÚnico': 'eixo_4?dims=education_families,year', @@ -259,15 +265,16 @@ class Eixo4 extends Component { reveal={<div>{"Esta tabela apresenta o total de certificações emitidas (pela Fundação Cultural Palmares) e de territórios titulados (pelo INCRA ou pelos Institutos de Terra) em todo o Brasil e nos Estados, a cada ano. Cada certificação se refere a uma comunidade, enquanto a titulação de um território pode englobar diversas comunidades que compartilham o mesmo território."}</div>} > <GrayBar text="Comunidades Certificadas por Ano" /> - - {data.gete1p2()[getStateExtendedName(this.state.clickedInMap).currentState] ? ( +{/* AQUI */} + <CsvBuildLineNotFixed data={csv4} customKeys={customNames} dataKey="Ano" keys={["Ano","Total"]} uf={getStateAcronym(this.state.clickedInMap)}/> + {/* data.gete1p2()[getStateExtendedName(this.state.clickedInMap).currentState] ? ( <BuildLineNotFixed data={data.gete1p2()[getStateExtendedName(this.state.clickedInMap).currentState]} customKeys={customNames} dataKey="Ano" /> ) : ( <BuildLineNotFixed data={nullInfo} customKeys={nullKeys} dataKey="Ano" /> - )} + ) */} <CardFooter - data={csv2} + data={csv4} source=" Comitê Gestor do Programa Brasil Quilombola, Fundação Cultural Palmares e INCRA (Jan/2016)" /> </Card> @@ -287,7 +294,7 @@ class Eixo4 extends Component { )} <CsvTable - columns={["ID QUILOMBOLA","REGIÃO","UF","MUNICÃPIO ","COMUNIDADE","ETAPA /PROCESSO FCP","DATA DA PORTARIA NO DOU","RETIFICAÇÃO NO DOU","Nº DE CRQs"]} + columns={["ID_QUILOMBOLA","REGIÃO","UF","MUNICÃPIO ","COMUNIDADE","ETAPA_PROCESSO_FCP","DATA_DA_PORTARIA_NO_DOU","RETIFICAÇÃO_NO_DOU","Nº_DE_CRQs"]} // columns={['ID', 'Comunidade', 'Etapa FCP', 'Território','Status INCRA', 'UF', 'Mapa']} data={csv4} -- GitLab