Skip to content

Commit

Permalink
Player page stats displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoruwaTolu committed Nov 27, 2023
1 parent 67aa6f3 commit 2727f34
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 13 deletions.
39 changes: 39 additions & 0 deletions prem-data/src/components/bar-chart/bar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@keyframes growAnimation {
from {
width: 0;
}
to {
width: 100%;
}
}
.bar-collection{
font-weight: 600;
}
.bar-info{
margin-bottom: 1em;
}
.bar {
width: 100%;
overflow: hidden; /* Hide overflow content */
font-weight: 400;
display: flex;
align-items: center;
font-style: italic;
}
.value{
width: 15%;
}
.jam {
display: flex;
justify-content: space-between;
background-color: lightblue;
animation: growAnimation 2s forwards;
box-sizing: border-box;
border-radius: 16px;
color: #838389;
width: 85%;

}
.bar:hover{
cursor: pointer;
}
19 changes: 19 additions & 0 deletions prem-data/src/components/bar-chart/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import './bar.css';

export function Bar(props){

var stats = props.props;
console.log(stats)

return(
<div className="bar">
<div className="value">{stats[0]}</div>
<div className="jam">
<div style={{width:`${stats[1]}%`, backgroundColor: "beige", borderRadius: "16px", padding: "0.5em 1em", boxSizing: "border-box"}}>
<div>{stats[1]}</div>
</div>
</div>
</div>
)
}
55 changes: 55 additions & 0 deletions prem-data/src/components/bar-chart/barchart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from "react";
import './bar.css';
import { Bar } from "./bar";

export function Bars(stats, percentileGroup){

var statistics = stats.stats;
console.log(statistics)


return(
<div className="bar-collection">
<div className="bar-info">
Expected Goals per 90
<Bar props={statistics.standard_stats.xG90}/>
</div>
<div className="bar-info">
Non-penalty xG per 90
<Bar props={statistics.standard_stats.nonPenXG90}/>
</div>
<div className="bar-info">
Goals per 90
<Bar props={statistics.standard_stats.goals90}/>
</div>
<div className="bar-info">
Non-penalty Goals per 90
<Bar props={statistics.standard_stats.nonPenGoals90}/>
</div>
<div className="bar-info">
Goals minus xG
<Bar props={statistics.shooting_stats.goalsMinusXG}/>
</div>
<div className="bar-info">
Goals minus Non-penalty xG
<Bar props={statistics.shooting_stats.nonPenGoalsMinusXG}/>
</div>
<div className="bar-info">
Non-penalty xG per Shot
<Bar props={statistics.shooting_stats.nonPenXGPerShot90}/>
</div>
<div className="bar-info">
Shots per 90
<Bar props={statistics.shooting_stats.shots90}/>
</div>
<div className="bar-info">
Shots on Target per 90
<Bar props={statistics.shooting_stats.shotOnTarget90}/>
</div>
<div className="bar-info">
Avg. Shot Distance from Goal
<Bar props={statistics.shooting_stats.avgShotDistance}/>
</div>
</div>
)
}
22 changes: 15 additions & 7 deletions prem-data/src/pages/page-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,22 @@
border-radius: 0 0 8px 8px;
padding-top: 1em;
box-sizing: border-box;
display: flex;
justify-content: center;
}
.chart-body{
height: fit-content;
width: 100%;
max-width: 100%;
display: flex;
gap: 1em;
box-sizing: border-box;
}
.chart-container{
max-height: fit-content;
max-width: fit-content;
max-width: 30%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-sizing: border-box;
}
Expand All @@ -111,6 +113,7 @@
text-align: center;
}
.position-tabs button{
max-height: 8vh;
cursor: pointer;
padding: 1em;
background-color: transparent;
Expand All @@ -130,15 +133,17 @@
display: flex;
justify-content: center;
margin-bottom: 1em;
flex-grow: 1;
box-sizing: border-box;
}
.numbers-container{
width: 100%;
width: 70%;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-columns: repeat(2, 1fr);
box-sizing: border-box;
}
.numbers-container div{
border: 0.5px solid #505050;
.player-statistics{
padding: 1em;
box-sizing: border-box;
}

@media screen and (max-width: 1023px) {
Expand All @@ -156,6 +161,9 @@
width: 100%;
max-width: 100%;
}
.numbers-container{
width: 100%;
}

}

Expand Down
17 changes: 11 additions & 6 deletions prem-data/src/pages/player-page-body/player-page-body.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PlayerPolarChart from '../../components/player-polar-chart';
import '../page-style.css';
import { Bars } from '../../components/bar-chart/barchart';
import {useState} from 'react';

function PlayerPageBody(props){
Expand All @@ -11,13 +12,17 @@ function PlayerPageBody(props){
<PlayerPolarChart props={props}/>
<div className='numbers-container'>
<div className='player-statistics'>
<div className="bar-container">
<div className="bar" style={{ width: `${props.player.standard_stats.assists90[1]}%` }}>{props.player.standard_stats.assists90[0]}</div>
</div>
<Bars stats={props.player} percentileGroup={1}/>
</div>
<div>1</div>
<div>1</div>
<div>1</div>
{/* <div className='player-statistics'>
<Bars stats={props.player.passing_stats} percentileGroup={1}/>
</div>
<div className='player-statistics'>
<Bars stats={props.player.possession_stats} percentileGroup={1}/>
</div>
<div className='player-statistics'>
<Bars stats={props.player.shot_goalCreation} percentileGroup={1}/>
</div> */}
<div>1</div>
<div>1</div>
</div>
Expand Down

0 comments on commit 2727f34

Please sign in to comment.