Skip to content

Commit 93c47bd

Browse files
committed
Merge branch 'Data-Visualization' of https://github.com/Patribots4738/ScoutingBackend2024 into Data-Visualization
2 parents c7656ba + c8b37c1 commit 93c47bd

9 files changed

+226
-132
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@testing-library/user-event": "^13.5.0",
1010
"ag-grid-react": "^31.0.1",
1111
"apexcharts": "^3.45.2",
12+
"chroma-js": "^2.4.2",
1213
"firebase": "^10.7.1",
1314
"firebase-admin": "^12.0.0",
1415
"fs": "^0.0.1-security",

src/Pages/CompareTeams.css

-16
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,6 @@
5555
flex-direction: column;
5656
}
5757

58-
.match-stats-container {
59-
border: 1px solid var(--lighter-background-color);
60-
width: 100%;
61-
margin-left: 20px;
62-
margin-right: 20px;
63-
max-height: 250px;
64-
margin-top: 5px;
65-
box-shadow: 0px 0px 10px rgb(0, 0, 0);
66-
display: flex; /* turn the container into a flex container */
67-
justify-content: space-around; /* evenly distribute items along the line */
68-
flex-wrap: wrap;
69-
align-items: center; /* center items along the cross-axis */
70-
overflow-y: auto;
71-
margin-bottom: 15px;
72-
}
73-
7458
.match-content-selector {
7559
width: 200px;
7660
display: flex;

src/Pages/CompareTeams.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function Compare() {
1515
const [allTeams, setAllTeams] = useState([]);
1616
const [teamData, setTeamData] = useState([]);
1717
const [teamMatchData, setTeamMatchData] = useState([]);
18-
const [maxMin, setMaxMin] = useState({});
18+
const [maxMinAverages, setMaxMinAverages] = useState({});
1919
const [teamColors, setTeamColors] = useState([]);
2020
const [teamList, setTeamList] = useState([]);
2121

@@ -60,7 +60,7 @@ function Compare() {
6060
setAllTeams(getAllTeams(data));
6161
setAverageData(data.teamAverageMap);
6262
setMatchData(data.bigTeamMap);
63-
setMaxMin(data.maxMin);
63+
setMaxMinAverages(data.maxMinOfAverages);
6464
});
6565
}, 1000);
6666
}, []);
@@ -236,27 +236,23 @@ function Compare() {
236236

237237
// selects data points from teamData and formats them for
238238
// the radar chart
239-
const convertForReCharts = (isBar) => {
239+
const convertForReCharts = () => {
240240
let arr = [];
241241
for (let i = 1; i < teamData[0][0].length; i++) {
242242
if (isRadarPoint(teamData[0][0][i])) {
243243
let categoryObj = { key: teamData[0][0][i] };
244244
for (let j = 0; j < teamData.length; j++) {
245-
let min = maxMin.get(teamData[j][0][i])[0];
246-
let max = maxMin.get(teamData[j][0][i])[1];
245+
let min = maxMinAverages.get(teamData[j][0][i])[0];
246+
let max = maxMinAverages.get(teamData[j][0][i])[1];
247247
let val = ((teamData[j][1][i] - min) / (max - min)) * 100;
248-
if (isBar) {
249-
categoryObj[teamList[j]] = teamData[j][1][i];
250-
} else {
251-
categoryObj[teamList[j]] = val;
252-
}
248+
categoryObj[teamList[j]] = val; // Use team number as key
253249
}
254250
arr.push(categoryObj);
255251
}
256252
}
257253
console.log(arr);
258254
return arr;
259-
};
255+
};
260256

261257
const colors = [
262258
'#d4af37',
@@ -287,7 +283,7 @@ function Compare() {
287283
<MyBarChart
288284
width={1000}
289285
height={250}
290-
data={convertForReCharts(true)}
286+
data={convertForReCharts()}
291287
margin={{ top: 5, right: 30, left: 20, bottom: 50 }}
292288
barConfigs={teamList.map(
293289
(team, index) => colorConfig[`team${index + 1}`]
@@ -299,7 +295,7 @@ function Compare() {
299295

300296
<div className="radar-ct">
301297
<RadarGraph
302-
data={convertForReCharts(false)}
298+
data={convertForReCharts()}
303299
angleKey="key"
304300
radiusDomain={[0, 100]}
305301
radars={teamList.slice(0, 10).map((team, index) => ({

src/Pages/Rankings.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function Rankings() {
5151
"children": [
5252
{
5353
"name": data.rankingTable[i]["Team"],
54-
"Score": data.rankingTable[i]["Score"]
54+
"Score": data.rankingTable[i][sortCol]
5555
}
5656
]
5757
});

src/Pages/Search.css

+32-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
1-
.search-bar {
2-
position: absolute;
3-
width: 200px;
4-
left: 0;
5-
right: 0;
6-
top: 60px;
7-
margin-left: auto;
8-
margin-right: auto;
9-
display: inline-flex;
10-
}
11-
12-
.search-input {
13-
position: relative;
14-
width: 70%;
15-
height: 40px;
16-
border-radius: 20px 0px 0px 20px;
17-
border: none;
18-
outline: none;
19-
text-align: center;
20-
font-size: 20px;
21-
}
22-
23-
.search-button {
24-
position: relative;
25-
border: none;
26-
border-radius: 0px 20px 20px 0px;
27-
width: 30%;
28-
background-color: rgb(230, 230, 230);
29-
transition: background-color 0.25s;
30-
}
31-
32-
.search-button:hover {
33-
background-color: rgb(210, 210, 210);
34-
}
35-
36-
.search-button:active {
37-
background-color: rgb(190, 190, 190);
1+
.search {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
justify-content: center;
6+
height: 100%;
7+
width: 100%;
8+
background-color: var(--background-color);
9+
color: var(--text-color);
10+
position: relative
3811
}
3912

4013
.team-stats {
@@ -50,12 +23,33 @@
5023
flex-direction: column;
5124
}
5225

26+
.average-stats-container {
27+
border: 1px solid var(--lighter-background-color);
28+
width: 100%;
29+
margin-left: 20px;
30+
margin-right: 20px;
31+
max-height: 400px;
32+
margin-top: 5px;
33+
padding: 0;
34+
box-shadow: 0px 0px 10px rgb(0, 0, 0);
35+
justify-content: space-around; /* evenly distribute items along the line */
36+
flex-wrap: wrap;
37+
transition: border-color 0.3s ease-in-out, box-shadow 0.3s ease-in-out; /* animate border and shadow changes */
38+
left: 0;
39+
right: 0;
40+
margin-left: auto;
41+
margin-right: auto;
42+
overflow: auto;
43+
padding: 0px;
44+
}
45+
5346
.match-stats-container {
5447
border: 1px solid var(--lighter-background-color);
5548
width: 100%;
5649
margin-left: 20px;
5750
margin-right: 20px;
58-
max-height: 280px;
51+
max-height: 250px;
52+
margin-top: 5px;
5953
padding: 0;
6054
box-shadow: 0px 0px 10px rgb(0, 0, 0);
6155
justify-content: space-around; /* evenly distribute items along the line */

0 commit comments

Comments
 (0)