diff --git a/src/components/graph/DiscretizedConsumptionChart.tsx b/src/components/graph/DiscretizedConsumptionChart.tsx index 98071f3..d765acc 100644 --- a/src/components/graph/DiscretizedConsumptionChart.tsx +++ b/src/components/graph/DiscretizedConsumptionChart.tsx @@ -43,7 +43,7 @@ export function DiscretizedConsumptionChart({ title, subtitle, dataProps, label, }, ticks: { font: { - size: window.innerWidth/80 + size: window?.innerWidth/80 } }, }, @@ -53,7 +53,7 @@ export function DiscretizedConsumptionChart({ title, subtitle, dataProps, label, }, ticks: { font: { - size: window.innerWidth/80 + size: window?.innerWidth/80 } }, }, diff --git a/src/components/graph/cativoXLivreChart/index.tsx b/src/components/graph/cativoXLivreChart/index.tsx index ebbc830..e9ae7e7 100644 --- a/src/components/graph/cativoXLivreChart/index.tsx +++ b/src/components/graph/cativoXLivreChart/index.tsx @@ -79,9 +79,11 @@ export function CativoXLivreChart({ title, subtitle, chartData, label, dataset1, const options: any = config(miniature) + console.log(chartData?.map(value => value.dad_estimado)?.includes(true)) + const data: any = { labels, - datasets: [ + datasets: chartData?.map(value => value.dad_estimado)?.includes(true) ? [ { type: 'line' as const, label: dataset1? dataset1 : 'Dataset 1', @@ -102,9 +104,10 @@ export function CativoXLivreChart({ title, subtitle, chartData, label, dataset1, if (!value.dad_estimado) return parseInt(value.custo_cativo) }), - skipNull: true, + // skipNull: true, borderRadius: 8, backgroundColor: '#C2D5FB', + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) }, { type: 'bar' as const, @@ -113,9 +116,10 @@ export function CativoXLivreChart({ title, subtitle, chartData, label, dataset1, if (!value.dad_estimado) return parseInt(value.custo_livre) }), - skipNull: true, + // skipNull: true, borderRadius: 8, backgroundColor: '#255488', + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) }, { type: 'bar', @@ -124,9 +128,9 @@ export function CativoXLivreChart({ title, subtitle, chartData, label, dataset1, if (value.dad_estimado) return parseInt(value.custo_cativo) }), - skipNull: true, borderRadius: 8, backgroundColor: pattern.draw('diagonal', '#C2D5FB'), + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) }, { type: 'bar', @@ -135,9 +139,47 @@ export function CativoXLivreChart({ title, subtitle, chartData, label, dataset1, if (value.dad_estimado) return parseInt(value.custo_livre) }), - skipNull: true, borderRadius: 8, backgroundColor: pattern.draw('diagonal', '#255488'), + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) + } + ] : [ + { + type: 'line' as const, + label: dataset1? dataset1 : 'Dataset 1', + borderColor: '#0c9200', + datalabels: { + backgroundColor: 'white', + borderRadius: 8, + opacity: .8 + }, + borderWidth: 2, + fill: false, + data: chartData?.map(value => parseInt(value.economia_mensal)), + }, + { + type: 'bar' as const, + label: 'Cativo', + data: chartData?.map(value => { + if (!value.dad_estimado) + return parseInt(value.custo_cativo) + }), + // skipNull: true, + borderRadius: 8, + backgroundColor: '#C2D5FB', + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) + }, + { + type: 'bar' as const, + label: 'Livre', + data: chartData?.filter(value => !value.dad_estimad? true : false).map(value => { + if (!value.dad_estimado) + return parseInt(value.custo_livre) + }), + // skipNull: true, + borderRadius: 8, + backgroundColor: '#255488', + skipNull: chartData?.map(value => value.dad_estimado)?.includes(true) } ], } diff --git a/src/pages/economy/index.tsx b/src/pages/economy/index.tsx index abfcad8..c34d926 100644 --- a/src/pages/economy/index.tsx +++ b/src/pages/economy/index.tsx @@ -71,22 +71,27 @@ export default function economy({userName, anual, years, brutaMensal, catLiv, cl setLastDataBruta(`${parseFloat(lastData).toFixed(3)}`) }, [economyMenu]) - useEffect(() => { - api.post('/economy/estimates', unity!==''?{ + async function getChartsWithUnity() { + await api.post('/economy/estimates', unity!==''?{ "filters": [ {"type" : "=", "field":"dados_cadastrais.cod_smart_unidade", "value": unity === "default" ? unity : unity} ] }:{}).then(res => { + console.log(res.data.data) setCatLivDataState(res.data.data) }) - api.post('/economy/MWh', unity!==''?{ + await api.post('/economy/MWh', unity!==''?{ "filters": [ {"type" : "=", "field":"dados_cadastrais.cod_smart_unidade", "value": unity === "default"? unity : unity} ] }:{}).then(res => { setIndicatorDataState(res.data.data) }) + } + + useEffect(() => { + getChartsWithUnity() }, [unity]) return ( diff --git a/src/pages/telemetria/index.tsx b/src/pages/telemetria/index.tsx index 057584a..cc9cfbe 100644 --- a/src/pages/telemetria/index.tsx +++ b/src/pages/telemetria/index.tsx @@ -168,7 +168,15 @@ export default function Telemetria({userName, clients}: any) { .catch(() => {setSend(false); setOpenSnackFields(true)}) getDemand(unity, startDate, endDate, discretization) - .then(result => {setDemRegXDemCon(result); setSend(false); setTableData(result)}) + .then(result => { + // const html = document.querySelector("table")?.outerHTML; + // htmlToCSV(html, "telemetria.csv") + + setDemRegXDemCon(result); + setSend(false); + console.log(result) + setTableData(result) + }) .catch(() => {setSend(false); setOpenSnackFields(true); setLoader(false)}) getPowerFactorData(unity, startDate, endDate, discretization) @@ -225,6 +233,8 @@ export default function Telemetria({userName, clients}: any) {
+ { + typeof window === 'undefined' || typeof window === undefined? null : {/* - + @@ -423,7 +433,7 @@ export default function Telemetria({userName, clients}: any) { { setLoader(true) getDemand(unity, startDate, endDate, discretization) - .then(result => {setDemRegXDemCon(result); setSend(false); setLoader(false)}) + .then(result => {setDemRegXDemCon(result); setSend(false); setLoader(false); setTableData(result)}) .catch(exception => {setSend(false); setOpenSnackFields(true); setLoader(false)}) }}/> @@ -582,14 +592,9 @@ export default function Telemetria({userName, clients}: any) { {/* setShowChart(!showChart)} purple /> */} {/* handleVerifyFields()} orange /> */} { - if (send) { - const html = document.querySelector("table")?.outerHTML; - htmlToCSV(html, "telemetria.csv"); - } - else { - setSend(true) - getTableData() - } + console.log(send) + const html = document.querySelector("table")?.outerHTML; + htmlToCSV(html, "telemetria.csv"); }}/>

@@ -601,8 +606,8 @@ export default function Telemetria({userName, clients}: any) { medição - Distribuidora.

-
+ } ) }