From 48a25b74cf8b923951bff97ff2ab16ba705aa8af Mon Sep 17 00:00:00 2001 From: Tolu Date: Fri, 1 Dec 2023 08:27:28 -0500 Subject: [PATCH] More data added to player pages --- prem-data/src/components/bar-chart/bar.css | 18 ++++-- prem-data/src/components/bar-chart/bar.js | 41 +++++++++++-- .../src/components/bar-chart/barchart.js | 55 ----------------- .../components/bar-chart/creation-barchart.js | 58 ++++++++++++++++++ .../bar-chart/involvement-barchart.js | 59 +++++++++++++++++++ .../components/bar-chart/passing-barchart.js | 46 +++++++++++++++ .../bar-chart/progression-barchart.js | 59 +++++++++++++++++++ .../components/bar-chart/scoring-barchart.js | 54 +++++++++++++++++ .../src/components/player-polar-chart.js | 13 ++-- .../player-page-body/player-page-body.js | 28 ++++++--- 10 files changed, 352 insertions(+), 79 deletions(-) delete mode 100644 prem-data/src/components/bar-chart/barchart.js create mode 100644 prem-data/src/components/bar-chart/creation-barchart.js create mode 100644 prem-data/src/components/bar-chart/involvement-barchart.js create mode 100644 prem-data/src/components/bar-chart/passing-barchart.js create mode 100644 prem-data/src/components/bar-chart/progression-barchart.js create mode 100644 prem-data/src/components/bar-chart/scoring-barchart.js diff --git a/prem-data/src/components/bar-chart/bar.css b/prem-data/src/components/bar-chart/bar.css index f8c5786..82908fe 100644 --- a/prem-data/src/components/bar-chart/bar.css +++ b/prem-data/src/components/bar-chart/bar.css @@ -12,6 +12,9 @@ .bar-info{ margin-bottom: 1em; } +.bar-title{ + margin-bottom: 0.2em; +} .bar { width: 100%; overflow: hidden; /* Hide overflow content */ @@ -26,14 +29,17 @@ .jam { display: flex; justify-content: space-between; - background-color: lightblue; - animation: growAnimation 2s forwards; box-sizing: border-box; border-radius: 16px; - color: #838389; + color: #FFFFFF; + animation: growAnimation 2s forwards; width: 85%; - } -.bar:hover{ - cursor: pointer; +.inner-bar{ + display: flex; + justify-content: center; + border-radius: 16px; + padding: 0.5em 1em; + box-sizing: border-box; + opacity: 0.7; } \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/bar.js b/prem-data/src/components/bar-chart/bar.js index 34241da..e09580f 100644 --- a/prem-data/src/components/bar-chart/bar.js +++ b/prem-data/src/components/bar-chart/bar.js @@ -1,19 +1,52 @@ import React from "react"; import './bar.css'; -export function Bar(props){ +export function Bar(props, percentileGroup){ var stats = props.props; - console.log(stats) + + var colour = perc2color(stats[props.percentileGroup]); + + var percentileAlignment = "left"; + + if(stats[props.percentileGroup] <= 14){ + percentileAlignment = "center" + } return(
{stats[0]}
-
-
{stats[1]}
+
+
{stats[props.percentileGroup]}
) +} + +//The function aims to give the statistics a colour based on it's percentage - red(really bad) green(really good) +function perc2color(perc) { + var r, g, b = 0; + if(perc < 50) { + r = 255; + g = Math.round(5.1 * perc); + } + else { + g = 255; + r = Math.round(510 - 5.10 * perc); + } + + //The if block below is used to make our colours a slightly darker shade to improve contrast and user visibility + if(r !== 0){ + r -= Math.round(r*0.1) + } + if(g !== 0){ + g -= Math.round(g*0.1) + } + if(b !== 0){ + b -= Math.round(b*0.1) + } + var h = r * 0x10000 + g * 0x100 + b * 0x1; + return ('#' + ('000000' + h.toString(16)).slice(-6)); } \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/barchart.js b/prem-data/src/components/bar-chart/barchart.js deleted file mode 100644 index 8315516..0000000 --- a/prem-data/src/components/bar-chart/barchart.js +++ /dev/null @@ -1,55 +0,0 @@ -import React from "react"; -import './bar.css'; -import { Bar } from "./bar"; - -export function Bars(stats, percentileGroup){ - - var statistics = stats.stats; - console.log(statistics) - - - return( -
-
- Expected Goals per 90 - -
-
- Non-penalty xG per 90 - -
-
- Goals per 90 - -
-
- Non-penalty Goals per 90 - -
-
- Goals minus xG - -
-
- Goals minus Non-penalty xG - -
-
- Non-penalty xG per Shot - -
-
- Shots per 90 - -
-
- Shots on Target per 90 - -
-
- Avg. Shot Distance from Goal - -
-
- ) -} \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/creation-barchart.js b/prem-data/src/components/bar-chart/creation-barchart.js new file mode 100644 index 0000000..d8b8abb --- /dev/null +++ b/prem-data/src/components/bar-chart/creation-barchart.js @@ -0,0 +1,58 @@ +import React from "react"; +import './bar.css'; +import { Bar } from "./bar"; + +export function CreationBars(stats, percentileGroup){ + + var statistics = stats.stats; + + return( +
+
Chance Creation
+
+
Expected Assists per 90
+ +
+
+
Assists per 90
+ +
+
+
Key Passes per 90
+ +
+
+
Goal Creating Actions per 90
+ +
+
+
Goal Creating Actions from Live Balls per 90
+ +
+
+
Goal Creating Actions from Dead Balls per 90
+ +
+
+
Goal Creating Actions from Take-ons per 90
+ +
+
+
Shot Creating Actions per 90
+ +
+
+
Shot Creating Actions from Live Balls per 90
+ +
+
+
Shot Creating Actions from Dead Balls per 90
+ +
+
+
Shot Creating Actions from Take-ons per 90
+ +
+
+ ) +} \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/involvement-barchart.js b/prem-data/src/components/bar-chart/involvement-barchart.js new file mode 100644 index 0000000..032dbe9 --- /dev/null +++ b/prem-data/src/components/bar-chart/involvement-barchart.js @@ -0,0 +1,59 @@ +import React from "react"; +import './bar.css'; +import { Bar } from "./bar"; + +export function InvolvementBars(stats, percentileGroup){ + + var statistics = stats.stats; + + return( +
+
Ball Security
+
+
Successful Take-ons per 90
+ +
+
+
Take-ons Attempted per 90
+ +
+
+
Successful Take-on percent
+ +
+
+
Times dispossessed per 90
+ +
+
+
Miscontrols per 90
+ +
+
Involvement
+
+
Touches per 90
+ +
+
+
Touches in Attacking Penalty Area per 90
+ +
+
+
Touches in Attacking 3rd per 90
+ +
+
+
Touches in Middle 3rd per 90
+ +
+
+
Touches in Defensive 3rd per 90
+ +
+
+
Passes Received per 90
+ +
+
+ ) +} \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/passing-barchart.js b/prem-data/src/components/bar-chart/passing-barchart.js new file mode 100644 index 0000000..80db139 --- /dev/null +++ b/prem-data/src/components/bar-chart/passing-barchart.js @@ -0,0 +1,46 @@ +import React from "react"; +import './bar.css'; +import { Bar } from "./bar"; + +export function PassingBars(stats, percentileGroup){ + + var statistics = stats.stats; + + return( +
+
Passing
+
+
Passes Attempted per 90
+ +
+
+
Passes Completed per 90
+ +
+
+
Long Passes Attempted per 90
+ +
+
+
Long Passes Completed per 90
+ +
+
+
Medium Passes Attempted per 90
+ +
+
+
Medium Passes Completed per 90
+ +
+
+
Short Passes Attempted per 90
+ +
+
+
Short Passes Completed per 90
+ +
+
+ ) +} \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/progression-barchart.js b/prem-data/src/components/bar-chart/progression-barchart.js new file mode 100644 index 0000000..c64984b --- /dev/null +++ b/prem-data/src/components/bar-chart/progression-barchart.js @@ -0,0 +1,59 @@ +import React from "react"; +import './bar.css'; +import { Bar } from "./bar"; + +export function ProgressionBars(stats, percentileGroup){ + + var statistics = stats.stats; + + return( +
+
Ball Progression
+
+
Progressive Carries per 90
+ +
+
+
Carries per 90
+ +
+
+
Carries into Final 3rd per 90
+ +
+
+
Carries into Penalty Area per 90
+ +
+
+
Progressive Carrying Distance per 90
+ +
+
+
Progressive Passes per 90
+ +
+
+
Through Balls per 90
+ +
+
+
Progressive Passes Received per 90
+ +
+
+
Passes Received per 90
+ +
+
+
Passes into Final 3rd per 90
+ +
+
+
Passes into Penalty Area per 90
+ +
+ +
+ ) +} \ No newline at end of file diff --git a/prem-data/src/components/bar-chart/scoring-barchart.js b/prem-data/src/components/bar-chart/scoring-barchart.js new file mode 100644 index 0000000..85c71db --- /dev/null +++ b/prem-data/src/components/bar-chart/scoring-barchart.js @@ -0,0 +1,54 @@ +import React from "react"; +import './bar.css'; +import { Bar } from "./bar"; + +export function ScoringBars(stats, percentileGroup){ + + var statistics = stats.stats; + + return( +
+
Goal Scoring
+
+
Expected Goals per 90
+ +
+
+
Non-penalty xG per 90
+ +
+
+
Goals per 90
+ +
+
+
Non-penalty Goals per 90
+ +
+
+
Goals minus xG
+ +
+
+
Goals minus Non-penalty xG
+ +
+
+
Non-penalty xG per Shot
+ +
+
+
Shots per 90
+ +
+
+
Shots on Target per 90
+ +
+
+
Avg. Shot Distance from Goal
+ +
+
+ ) +} \ No newline at end of file diff --git a/prem-data/src/components/player-polar-chart.js b/prem-data/src/components/player-polar-chart.js index 47bf299..cd23037 100644 --- a/prem-data/src/components/player-polar-chart.js +++ b/prem-data/src/components/player-polar-chart.js @@ -12,11 +12,14 @@ import {makePositionReadable, playerCardDisplayLabels} from '../pages/player-pag ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend); -function PlayerPolarChart(props){ +function PlayerPolarChart({player, view, setView}){ - var playerInfo = props.props.player; + var playerInfo = player; var positionArray = []; - const [view, setView] = useState(0); + // const [view, setView] = useState(0); + + console.log(player) + function changeView(id){ setView(id); @@ -112,8 +115,8 @@ function PlayerPolarChart(props){ return(
- - + +
{view === 0 && (
diff --git a/prem-data/src/pages/player-page-body/player-page-body.js b/prem-data/src/pages/player-page-body/player-page-body.js index eb2dacf..8f2791c 100644 --- a/prem-data/src/pages/player-page-body/player-page-body.js +++ b/prem-data/src/pages/player-page-body/player-page-body.js @@ -1,28 +1,38 @@ import PlayerPolarChart from '../../components/player-polar-chart'; import '../page-style.css'; -import { Bars } from '../../components/bar-chart/barchart'; +import { ScoringBars } from '../../components/bar-chart/scoring-barchart'; +import { CreationBars } from '../../components/bar-chart/creation-barchart'; +import { ProgressionBars } from '../../components/bar-chart/progression-barchart'; +import { InvolvementBars } from '../../components/bar-chart/involvement-barchart'; +import { PassingBars } from '../../components/bar-chart/passing-barchart'; import {useState} from 'react'; function PlayerPageBody(props){ - console.log(props.player.standard_stats.assists90[1]) + const [view, setView] = useState(0); + var percentileGroup = view + 1; + + console.log(view) return(
- +
- +
- {/*
- +
+
- +
- -
*/} + +
+
+ +
1
1