Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integração Componente gráfico do Indicador #20

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions src/componets/IndicadorCardGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
import Api from "../Api";
import LineGraph from "./LineGraph";
import { useEffect, useState } from 'react';

type IndicadorCardGraphProps = {
indicador: {
id: string,
nome: string,
meses: string[],
meta: number[],
supermeta: number[],
desafio: number[]
//eh recebido todas informacoes de indicador
//mas so essas sao usada
}
}

//o tipo recebido é esse:
/*
export interface indicatorType {
id: string
nome: string
unidade_medida: string
descricao: string
data_deadline: Date
idGestor: string
}
*/

export default function IndicadorCardGraph({ indicador }: IndicadorCardGraphProps) {

const [cat, setCat] = useState<[][]>([]);

useEffect(() => {

try{
Api.get('metas-mes-indicador/'+indicador.id).then(res =>{
const aux = res.data;
setCat(aux);

})
} catch (error) {
console.log(error)
}

}, [])






return (

<button
onClick={() => { console.log('clicou') }}
className='border rounded-10 bg-white border-cinza-100 h-[23.125rem] w-[29.75rem] hover:border-[#7D55EF] hover:border-2'>
Expand All @@ -21,7 +57,7 @@ export default function IndicadorCardGraph({ indicador }: IndicadorCardGraphProp
{indicador.nome}
</h4>
<div className='mb-4'>
<LineGraph indicador={indicador} />
<LineGraph mmsdInd={cat} />
</div>
</div>
</button>
Expand Down
34 changes: 21 additions & 13 deletions src/componets/LineGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
import Plot from 'react-plotly.js';
//import { metasMesIndicadorType } from '../types';



type LineGraphProps = {
indicador: {
meses: string[],
meta: number[],
supermeta: number[],
desafio: number[]
mmsdInd: [][]
// mmsdInd significa Meses, Mestas, Super-metas, Desafios por Indicadores
/*
mmsdInd: {
esses valores sao referentes a um indicador
mmsdInd[0] = mese_ano: string[], todos o meses_anos
mmsdInd[1] = meta: number[], valor de metas batidas de cada mes
mmsdInd[2] = supermeta: number[], valor de super-metas batidas de cada mes
mmsdInd[3] = desafio: number[] valor de metas batidas de cada mes
}
*/
}

export default function LineGraph({ indicador }: LineGraphProps) {
export default function LineGraph({ mmsdInd }: LineGraphProps) {

//console.log(mmsdInd.desafio)

return (
<Plot
data={[
{
x: indicador.meses,
y: indicador.meta,
x: mmsdInd[0], //mese_ano
y: mmsdInd[1], //metas
type: 'scatter',
mode: 'lines+markers',
marker: { color: '#E51110' },
name: "Meta",
},
{
x: indicador.meses,
y: indicador.supermeta,
x: mmsdInd[0], //mese_ano
y: mmsdInd[2], //super-metas
type: 'scatter',
mode: 'lines+markers',
marker: { color: '#7D55EF' },
name: "Supermeta",
},
{
x: indicador.meses,
y: indicador.desafio,
x: mmsdInd[0], //mese_ano
y: mmsdInd[3], //desafios
type: 'scatter',
mode: 'lines+markers',
marker: { color: '#5EE0F1' },
Expand Down
14 changes: 13 additions & 1 deletion src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,16 @@ export interface collaboratorType {
totalColabBateramDesafio: number;
totalColab: number;
idIndicador: string;
}
}

export interface colaboradorIndicadorType {
mes_ano: string;
meta: number;
superMeta: number;
desafio: number;
peso: number;
resultado: number;
notaIndicador: number;
idColaborador: string;
idIndicador: string;
}