From b21c5b60840be40c260f3bcf8ae63252943e450c Mon Sep 17 00:00:00 2001
From: Vercin-G <97210222+Vercin-G@users.noreply.github.com>
Date: Tue, 12 Sep 2023 14:40:55 -0600
Subject: [PATCH] Statistics Rework
---
client/src/App.js | 219 +++++---------------
client/src/modules/Generic/Piechart.js | 50 -----
client/src/modules/Generic/Statistics.js | 85 ++++++++
client/src/modules/Generic/StrengthCount.js | 71 -------
4 files changed, 142 insertions(+), 283 deletions(-)
delete mode 100644 client/src/modules/Generic/Piechart.js
create mode 100644 client/src/modules/Generic/Statistics.js
delete mode 100644 client/src/modules/Generic/StrengthCount.js
diff --git a/client/src/App.js b/client/src/App.js
index a5ff53d..43c2010 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -3,9 +3,9 @@ import "./App.css";
import Collapsible from "react-collapsible";
import lists from "./modules/Generic/BilletBank";
import MilpacParse from "./modules/Generic/MilpacParse";
-import StrengthCount from "./modules/Generic/StrengthCount";
import ErrorMessage from "./errorMessage";
-import Piechart from "./modules/Generic/Piechart"
+import Statistics from "./modules/Generic/Statistics";
+
const CLIENT_TOKEN = process.env.REACT_APP_CLIENT_TOKEN;
const combatApiUrl = process.env.REACT_APP_COMBAT_API_URL;
const reserveApiUrl = process.env.REACT_APP_RESERVE_API_URL;
@@ -74,9 +74,7 @@ function MilpacRequest() {
setLoading(false);
});
}, []);
-
- var piechartArray = [];
-
+
var milpacArray = [];
milpacArray.push({
combat: milpacList,
@@ -467,162 +465,59 @@ function MilpacRequest() {
triggerOpenedClassName="Title"
open={true}
>
-
-
-
-
-
-
-
- {/* */}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ 7th Cavalry Regiment {'('}Active Duty and Line Billets only{')'}
+
+
+
+ First Battalion
+
+
+
+ Second Battalion
+
+
+
+ Auxillary Combat Division
+
+
@@ -631,4 +526,4 @@ function MilpacRequest() {
);
}
-export default MilpacRequest;
+export default MilpacRequest;
\ No newline at end of file
diff --git a/client/src/modules/Generic/Piechart.js b/client/src/modules/Generic/Piechart.js
deleted file mode 100644
index fe00f1e..0000000
--- a/client/src/modules/Generic/Piechart.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import React, { Component } from 'react';
-import Chart from 'react-apexcharts'
-
-class Donut extends Component {
-
- constructor(props) {
- super(props);
-
- //for the love of god, this is terrible. If you are reading this, DONT DO THIS! this is so unbelievibly bad. This will be reworked once the duplicated pieChartArray items are fixed
-
- var piechartObject = props.piechartObject;
- var useSelector0 = props.useSelector0
- var useSelector2 = props.useSelector2
- var useSelector4 = props.useSelector4
- var useSelector6 = props.useSelector6
- var useSelector8 = props.useSelector8
- var finalInput = [];
-
- if (useSelector0 !== false) {
- finalInput.push(piechartObject[0])
- }if (useSelector2 !== false) {
- finalInput.push(piechartObject[2])
- }if (useSelector4 !== false) {
- finalInput.push(piechartObject[4])
- }if (useSelector6 !== false) {
- finalInput.push(piechartObject[6])
- }if (useSelector8 !== false) {
- finalInput.push(piechartObject[8])
- };
-
- console.log (finalInput);
-
- this.state = {
- options: {},
- series: finalInput,
- labels: ['A', 'B', 'C', 'D', 'E']
- }
- }
-
- render() {
-
- return (
-
-
-
- );
- }
-}
-
-export default Donut;
\ No newline at end of file
diff --git a/client/src/modules/Generic/Statistics.js b/client/src/modules/Generic/Statistics.js
new file mode 100644
index 0000000..4de8bb8
--- /dev/null
+++ b/client/src/modules/Generic/Statistics.js
@@ -0,0 +1,85 @@
+import React, { Component } from "react";
+import Chart from "react-apexcharts";
+
+class Statistics extends Component {
+ constructor(props) {
+ super(props);
+
+ let milpacArray = props.milpacArray;
+ let billetIDs = props.billetIDs;
+ let labelArray = props.labelArray;
+ let piechartData = [];
+ let combinedArray = Array(billetIDs.length)
+ .fill()
+ .map(() => []);
+
+ console.log(billetIDs);
+ console.log(milpacArray);
+
+ for (let milpacIdCombat in milpacArray[0].combat.profiles) {
+ var primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
+
+ for (let billetIdArray in billetIDs) {
+ if (billetIDs[billetIdArray].includes(primary.positionId)) {
+ combinedArray[billetIdArray].push(primary.positionTitle);
+ }
+ }
+ }
+
+ combinedArray.forEach((subArray) => {
+ piechartData.push(subArray.length);
+ });
+
+ console.log(combinedArray);
+
+ this.state = {
+ options: {
+ labels: labelArray,
+ legend: {
+ show: true,
+ },
+ dataLabels: {
+ enabled: false,
+ },
+ tooltip: {
+ enabled: false,
+ },
+ plotOptions: {
+ pie: {
+ donut: {
+ size: "65%",
+ background: "transparent",
+ labels: {
+ show: true,
+ value: {
+ show: true,
+ },
+ total: {
+ show: true,
+ showAlways: false,
+ label: "Total",
+ },
+ },
+ },
+ },
+ },
+ },
+ series: piechartData,
+ };
+ }
+
+ render() {
+ return (
+
+
+
+ );
+ }
+}
+
+export default Statistics;
diff --git a/client/src/modules/Generic/StrengthCount.js b/client/src/modules/Generic/StrengthCount.js
deleted file mode 100644
index fdf489a..0000000
--- a/client/src/modules/Generic/StrengthCount.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import React from "react";
-
-function StrengthCount(props) {
- var useCompanyLevelLogic = props.useCompanyLevelLogic;
- var piechartArray = props.piechartArray;
-
- if (useCompanyLevelLogic !== true) {
- var combinedArray = [];
- var milpacArray = props.milpacArray;
- var billetIDs = props.billetIDs;
- var subtitle = props.subtitle;
-
- for (var milpacIdCombat in milpacArray[0].combat.profiles) {
- var primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
-
- for (var billetIdArray in billetIDs) {
- if (billetIDs[billetIdArray].includes(primary.positionId)) {
- combinedArray.push({ position: primary });
- }
- }
- }
-
- piechartArray.push(combinedArray.length)
-
- console.log(piechartArray)
-
- return (
-
-
-
{subtitle}
-
- Overall Strength{": "}
- {combinedArray.length}
-
-
-
- );
- } else if (useCompanyLevelLogic === true) {
- combinedArray = [];
- milpacArray = props.milpacArray;
- billetIDs = props.billetIDs;
- var subSubtitle = props.subSubtitle;
-
- for (milpacIdCombat in milpacArray[0].combat.profiles) {
- primary = milpacArray[0].combat.profiles[milpacIdCombat].primary;
-
- for (billetIdArray in billetIDs) {
- if (billetIDs[billetIdArray].includes(primary.positionId)) {
- combinedArray.push({ position: primary });
- }
- }
- }
-
- piechartArray.push(combinedArray.length)
-
- console.log(piechartArray)
-
-
- return (
-
-
- {subSubtitle}
- {": "}
- {combinedArray.length}
-
-
- );
- }
-}
-
-export default StrengthCount;