From f6bc5dc40134f1e326c6859f3a4f21eab384a0eb Mon Sep 17 00:00:00 2001 From: insvrgent Date: Mon, 3 Feb 2025 10:28:58 +0700 Subject: [PATCH] ok --- src/components/BarChart.module.css | 4 ++-- src/components/DailyCharts.js | 36 ++++++++++++++++++++++++++---- src/components/PeriodCharts.js | 4 ++-- src/pages/Reports.js | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/components/BarChart.module.css b/src/components/BarChart.module.css index 7ccf469..db18e0a 100644 --- a/src/components/BarChart.module.css +++ b/src/components/BarChart.module.css @@ -71,7 +71,7 @@ } .chartWrapper { - /* border: 1px solid rgb(179, 177, 177); - border-radius: 0 0 11px 11px; */ + width: 100%; /* This makes the chart responsive to its parent's width */ + height: 200px; /* Set a fixed height for the chart */ } \ No newline at end of file diff --git a/src/components/DailyCharts.js b/src/components/DailyCharts.js index 592e977..bc5449d 100644 --- a/src/components/DailyCharts.js +++ b/src/components/DailyCharts.js @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react"; import Chart from "react-apexcharts"; import styles from "./BarChart.module.css"; // Import the CSS module -const DailyCharts = ({ transactionGraph, colors, type }) => { +const DailyCharts = ({ incomeGraph, transactionGraph, materialGraph, colors, type, graphFilter }) => { const [selectedIndex, setSelectedIndex] = useState(-1); useEffect(() => { @@ -23,7 +23,9 @@ const DailyCharts = ({ transactionGraph, colors, type }) => { "21-24", ]; console.log(dayData) - const seriesData = [ + let seriesData = [] + if(graphFilter == 'transactions'){ + seriesData = [ dayData.hour0To3Transactions.reduce((acc, t) => acc + t.sold, 0), dayData.hour3To6Transactions.reduce((acc, t) => acc + t.sold, 0), dayData.hour6To9Transactions.reduce((acc, t) => acc + t.sold, 0), @@ -33,7 +35,31 @@ const DailyCharts = ({ transactionGraph, colors, type }) => { dayData.hour18To21Transactions.reduce((acc, t) => acc + t.sold, 0), dayData.hour21To24Transactions.reduce((acc, t) => acc + t.sold, 0), ]; - + } + else if(graphFilter == 'income'){ + seriesData = [ + dayData.hour0To3Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour3To6Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour6To9Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour9To12Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour12To15Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour15To18Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour18To21Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + dayData.hour21To24Transactions.reduce((acc, t) => acc + t.totalPrice, 0), + ]; + } + else if(graphFilter == 'outcome'){ + seriesData = [ + dayData.hour3To6MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour6To9MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour0To3MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour9To12MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour12To15MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour15To18MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour18To21MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + dayData.hour21To24MaterialIds.reduce((acc, t) => acc + t.materialOutcome, 0), + ]; + } return { date: new Date(dayData.date).toLocaleDateString(), categories, @@ -47,7 +73,7 @@ const DailyCharts = ({ transactionGraph, colors, type }) => { }); }; - const chartData = processData(transactionGraph); + const chartData = processData(graphFilter != 'outcome' ? transactionGraph : materialGraph); let globalMax = null; if (chartData) @@ -139,7 +165,9 @@ const DailyCharts = ({ transactionGraph, colors, type }) => { }, }, yaxis: { + show: false, max: globalMax, + min: 0, labels: { style: { colors: "transparent", diff --git a/src/components/PeriodCharts.js b/src/components/PeriodCharts.js index e8c68df..dd175b2 100644 --- a/src/components/PeriodCharts.js +++ b/src/components/PeriodCharts.js @@ -105,7 +105,7 @@ if (aggregatedCurrentReports || aggregatedPreviousReports) { } } }, - yaxis: { max: globalMax, min: 0, labels: { style: { colors: "transparent" } } }, + yaxis: { show: false, max: globalMax, min: 0, labels: { style: { colors: "transparent" } } }, grid: { show: false }, fill: { opacity: 0.5 }, colors: [colors[0]], @@ -166,7 +166,7 @@ if (aggregatedCurrentReports || aggregatedPreviousReports) { } } }, - yaxis: { max: globalMax, min: 0, labels: { style: { colors: "transparent" } } }, + yaxis: { show: false, max: globalMax, min: 0, labels: { style: { colors: "transparent" } } }, grid: { show: false }, fill: { opacity: 0.5 }, colors: [colors[1]], diff --git a/src/pages/Reports.js b/src/pages/Reports.js index e2204e4..8613949 100644 --- a/src/pages/Reports.js +++ b/src/pages/Reports.js @@ -612,7 +612,7 @@ const App = ({ forCafe = true, cafeId = -1, {filter == 'yesterday' || filter == 'weekly' ? - + : }