|
| 1 | +import * as React from 'react'; |
| 2 | +import Stack from '@mui/material/Stack'; |
| 3 | +import Typography from '@mui/material/Typography'; |
| 4 | +import { BarChart, BarChartProps, BarSeries } from '@mui/x-charts/BarChart'; |
| 5 | + |
| 6 | +const clubs = [ |
| 7 | + 'Arsenal', |
| 8 | + 'Liverpool', |
| 9 | + 'Man Utd', |
| 10 | + 'Tottenham', |
| 11 | + 'Everton', |
| 12 | + 'Sunderland', |
| 13 | + 'Newcastle', |
| 14 | + 'Nottingham Forest', |
| 15 | + 'Leeds', |
| 16 | + 'Man City', |
| 17 | + 'West Ham', |
| 18 | + 'Burnley', |
| 19 | + 'Fulham', |
| 20 | + 'Chelsea', |
| 21 | + 'Aston Villa', |
| 22 | + 'Wolves', |
| 23 | + 'Crystal Palace', |
| 24 | + 'Brentford', |
| 25 | + 'Bournemouth', |
| 26 | + 'Brighton', |
| 27 | +]; |
| 28 | + |
| 29 | +// Source: https://www.squawka.com/en/news/premier-league-net-spend-2025-26/ |
| 30 | +const netSpendInPounds = [ |
| 31 | + 251.4, 235, 166.9, 137.8, 116, 113.4, 95.6, 95.4, 91.5, 80.2, 69.7, 57.8, 18.93, |
| 32 | + 9.5, -8, -14.7, -23, -58.9, -63.3, -68.15, |
| 33 | +]; |
| 34 | +const clubColors = [ |
| 35 | + '#EF0107', // Arsenal - Red |
| 36 | + '#C8102E', // Liverpool - Red |
| 37 | + '#DA291C', // Man Utd - Red |
| 38 | + '#132257', // Tottenham - Navy Blue |
| 39 | + '#003399', // Everton - Royal Blue |
| 40 | + '#E03A3E', // Sunderland - Red |
| 41 | + '#241F20', // Newcastle - Black |
| 42 | + '#DD0000', // Nottingham Forest - Red |
| 43 | + '#FFCD00', // Leeds - Yellow |
| 44 | + '#6CABDD', // Man City - Sky Blue |
| 45 | + '#7A263A', // West Ham - Claret |
| 46 | + '#6C1D45', // Burnley - Claret |
| 47 | + '#CC0000', // Fulham - Red |
| 48 | + '#034694', // Chelsea - Blue |
| 49 | + '#670E36', // Aston Villa - Claret |
| 50 | + '#FDB913', // Wolves - Gold |
| 51 | + '#1B458F', // Crystal Palace - Blue |
| 52 | + '#E30613', // Brentford - Red |
| 53 | + '#DA291C', // Bournemouth - Red |
| 54 | + '#0057B8', // Brighton - Blue |
| 55 | +]; |
| 56 | + |
| 57 | +const valueFormatter = (v: number | null) => (v! < 0 ? `-£${-v!}m` : `£${v!}m`); |
| 58 | + |
| 59 | +const chartsParams = { |
| 60 | + margin: { top: 20, right: 40, bottom: 20, left: 20 }, |
| 61 | + xAxis: [{ data: clubs, tickLabelStyle: { angle: 45 }, height: 80 }], |
| 62 | + yAxis: [ |
| 63 | + { |
| 64 | + width: 60, |
| 65 | + valueFormatter, |
| 66 | + }, |
| 67 | + ], |
| 68 | + series: [ |
| 69 | + { |
| 70 | + data: netSpendInPounds, |
| 71 | + colorGetter: (data) => clubColors[data.dataIndex], |
| 72 | + valueFormatter, |
| 73 | + } satisfies BarSeries, |
| 74 | + ], |
| 75 | + height: 400, |
| 76 | +} satisfies BarChartProps; |
| 77 | + |
| 78 | +export default function ColorCallback() { |
| 79 | + return ( |
| 80 | + <Stack spacing={2} width="100%"> |
| 81 | + <Typography variant="h6" textAlign="center"> |
| 82 | + Premier League Clubs Net Spend - Summer 2025 |
| 83 | + </Typography> |
| 84 | + <BarChart {...chartsParams} /> |
| 85 | + <Typography variant="caption">Source: squawka.com</Typography> |
| 86 | + </Stack> |
| 87 | + ); |
| 88 | +} |
0 commit comments