Skip to content

Commit

Permalink
Statistics Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Vercin-G committed Sep 12, 2023
1 parent 5112564 commit b21c5b6
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 283 deletions.
219 changes: 57 additions & 162 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,9 +74,7 @@ function MilpacRequest() {
setLoading(false);
});
}, []);

var piechartArray = [];


var milpacArray = [];
milpacArray.push({
combat: milpacList,
Expand Down Expand Up @@ -467,162 +465,59 @@ function MilpacRequest() {
triggerOpenedClassName="Title"
open={true}
>
<div className="OneSevenStrength">
<StrengthCount
piechartArray={piechartArray}
milpacArray={milpacArray}
billetIDs={[
lists.oneSevenCommand,
lists.alpha1,
lists.bravo1,
lists.charlie1,
]}
subtitle={"First Battalion"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.oneSevenCommand]}
subSubtitle={"Headquarters"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.alpha1]}
subSubtitle={"Alpha Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.bravo1]}
subSubtitle={"Bravo Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.charlie1]}
subSubtitle={"Charlie Co"}
/>
</div>
{/*<div className="OneSevenBreakdown">
<Piechart
piechartArray = {piechartArray}
useSelector0={false}
useSelector2={true}
useSelector4={true}
useSelector6={true}
/>
</div> */}
<div className="TwoSevenStrength">
<StrengthCount
piechartArray={piechartArray}
milpacArray={milpacArray}
billetIDs={[
lists.twoSevenCommand,
lists.alpha2,
lists.bravo2,
lists.charlie2,
]}
subtitle={"Second Battalion"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.twoSevenCommand]}
subSubtitle={"Headquarters"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.alpha2]}
subSubtitle={"Alpha Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.bravo2]}
subSubtitle={"Bravo Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.charlie2]}
subSubtitle={"Charlie Co"}
/>
</div>
<div className="ACDStrength">
<StrengthCount
piechartArray={piechartArray}
milpacArray={milpacArray}
billetIDs={[
lists.acdCommand,
lists.alpha3,
lists.bravo3,
lists.charlie3,
lists.delta3,
]}
subtitle={"ACD"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.acdCommand]}
subSubtitle={"Headquarters"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.alpha3]}
subSubtitle={"Alpha Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.bravo3]}
subSubtitle={"Bravo Co"}
/>
<StrengthCount
piechartArray={piechartArray}
useCompanyLevelLogic={true}
milpacArray={milpacArray}
billetIDs={[lists.charlie3]}
subSubtitle={"Charlie Co"}
/>
</div>
<div className="CombinedStrength">
<StrengthCount
piechartArray={piechartArray}
milpacArray={milpacArray}
billetIDs={[
lists.regiCommand,
lists.oneSevenCommand,
lists.alpha1,
lists.bravo1,
lists.charlie1,
lists.twoSevenCommand,
lists.alpha2,
lists.bravo2,
lists.charlie2,
lists.acdCommand,
lists.alpha3,
lists.bravo3,
lists.charlie3,
lists.delta3,
]}
subtitle={"Overall Strength"}
/>
</div>
<div className="Regiment Breakdown">
7th Cavalry Regiment {'('}Active Duty and Line Billets only{')'}
<Statistics
billetIDs={[
lists.oneSevenCommand,
lists.alpha1,
lists.bravo1,
lists.charlie1,
]}
labelArray = {['Headquarters','Alpha Company','Bravo Troop','Charlie Company']}
milpacArray = {milpacArray}
/>
</div>
<div className="OneSevenBreakdown">
First Battalion
<Statistics
billetIDs={[
lists.oneSevenCommand,
lists.alpha1,
lists.bravo1,
lists.charlie1,
]}
labelArray = {['1-7 Headquarters','Alpha Company','Bravo Troop','Charlie Company']}
milpacArray = {milpacArray}
/>
</div>
<div className="TwoSevenBreakdown">
Second Battalion
<Statistics
billetIDs={[
lists.twoSevenCommand,
lists.alpha2,
lists.bravo2,
lists.charlie2,
]}
labelArray = {['2-7 Headquarters','Alpha Company','Bravo Company','Charlie Company']}
milpacArray = {milpacArray}
/>
</div>
<div className="ACDStrength">
Auxillary Combat Division
<Statistics
billetIDs={[
lists.acdCommand,
lists.alpha3,
lists.bravo3,
lists.charlie3,
lists.starterPlatoon,
]}
labelArray = {['ACD Headquarters','Alpha Company','Bravo Company','Charlie Company','Star Citizen Starter Platoon']}
milpacArray = {milpacArray}
/>
</div>
</Collapsible>
</div>
</div>
Expand All @@ -631,4 +526,4 @@ function MilpacRequest() {
</div>
);
}
export default MilpacRequest;
export default MilpacRequest;
50 changes: 0 additions & 50 deletions client/src/modules/Generic/Piechart.js

This file was deleted.

85 changes: 85 additions & 0 deletions client/src/modules/Generic/Statistics.js
Original file line number Diff line number Diff line change
@@ -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 (
<div className="donut">
<Chart
options={this.state.options}
series={this.state.series}
type="donut"
width="380"
/>
</div>
);
}
}

export default Statistics;
Loading

0 comments on commit b21c5b6

Please sign in to comment.