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 2 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
40 changes: 35 additions & 5 deletions src/componets/IndicadorCardGraph.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
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(() => {
Api.get('metas-mes-indicador/'+indicador.id).then(res =>{
const aux = res.data;
setCat(aux);

})
}, [])






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 +51,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;
}
10 changes: 10 additions & 0 deletions vite.config.ts.timestamp-1696095715514-3b4069a2a49ca.mjs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu não entendi esse arquivo aqui, aí joguei no google e descobri que ele já deu problema pra uma galera em alguns fóruns. Eu não consegui chegar a uma conclusão se é seguro apagar ele. Eu vi umas pessoas falando sobre adicionar ele no .gitignore nesse modelo vite.config.ts.timestamp-*.mjs, mas realmente não sei se é seguro. Talvez não tenha problema nenhum, mas se der pra tu dar uma olhada também. Eu caí nessa discussão aqui ó vitejs/vite#9470.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// vite.config.ts
import { defineConfig } from "file:///C:/Users/Jo%C3%A3o%20Marcos/Desktop/RocketLab/Front/vfoods/node_modules/vite/dist/node/index.js";
import react from "file:///C:/Users/Jo%C3%A3o%20Marcos/Desktop/RocketLab/Front/vfoods/node_modules/@vitejs/plugin-react/dist/index.mjs";
var vite_config_default = defineConfig({
plugins: [react()]
});
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCJDOlxcXFxVc2Vyc1xcXFxKb1x1MDBFM28gTWFyY29zXFxcXERlc2t0b3BcXFxcUm9ja2V0TGFiXFxcXEZyb250XFxcXHZmb29kc1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiQzpcXFxcVXNlcnNcXFxcSm9cdTAwRTNvIE1hcmNvc1xcXFxEZXNrdG9wXFxcXFJvY2tldExhYlxcXFxGcm9udFxcXFx2Zm9vZHNcXFxcdml0ZS5jb25maWcudHNcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfaW1wb3J0X21ldGFfdXJsID0gXCJmaWxlOi8vL0M6L1VzZXJzL0pvJUMzJUEzbyUyME1hcmNvcy9EZXNrdG9wL1JvY2tldExhYi9Gcm9udC92Zm9vZHMvdml0ZS5jb25maWcudHNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlJ1xyXG5pbXBvcnQgcmVhY3QgZnJvbSAnQHZpdGVqcy9wbHVnaW4tcmVhY3QnXHJcblxyXG4vLyBodHRwczovL3ZpdGVqcy5kZXYvY29uZmlnL1xyXG5leHBvcnQgZGVmYXVsdCBkZWZpbmVDb25maWcoe1xyXG4gIHBsdWdpbnM6IFtyZWFjdCgpXSxcclxufSlcclxuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUFnVyxTQUFTLG9CQUFvQjtBQUM3WCxPQUFPLFdBQVc7QUFHbEIsSUFBTyxzQkFBUSxhQUFhO0FBQUEsRUFDMUIsU0FBUyxDQUFDLE1BQU0sQ0FBQztBQUNuQixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=