7575 { value: ' SP1' , label: ' La Liga' , icon: ' 🇪🇸' },
7676 { value: ' D1' , label: ' Bundesliga' , icon: ' 🇩🇪' },
7777 { value: ' I1' , label: ' Serie A' , icon: ' 🇮🇹' },
78- { value: ' F1' , label: ' Ligue 1' , icon: ' 🇫🇷' }
78+ { value: ' F1' , label: ' Ligue 1' , icon: ' 🇫🇷' },
79+ { value: ' N1' , label: ' Eredivisie' , icon: ' 🇳🇱' },
80+ { value: ' P1' , label: ' Primeira Liga' , icon: ' 🇵🇹' },
81+ { value: ' SC0' , label: ' Scottish Premiership' , icon: ' 🏴' },
82+ { value: ' E1' , label: ' Championship' , icon: ' 🏴' }
7983 ];
8084
8185 // League-specific top teams (based on typical strong performers)
8488 ' SP1' : [' Real Madrid' , ' Barcelona' , ' Atletico Madrid' , ' Real Sociedad' , ' Betis' , ' Villarreal' , ' Athletic Club' , ' Valencia' ],
8589 ' D1' : [' Bayern Munich' , ' Dortmund' , ' RB Leipzig' , ' Union Berlin' , ' Eintracht Frankfurt' , ' Bayer Leverkusen' , ' Freiburg' , ' Wolfsburg' ],
8690 ' I1' : [' Inter' , ' Juventus' , ' AC Milan' , ' Napoli' , ' Roma' , ' Lazio' , ' Atalanta' , ' Fiorentina' ],
87- ' F1' : [' PSG' , ' Marseille' , ' Monaco' , ' Lyon' , ' Lille' , ' Rennes' , ' Nice' , ' Lens' ]
91+ ' F1' : [' PSG' , ' Marseille' , ' Monaco' , ' Lyon' , ' Lille' , ' Rennes' , ' Nice' , ' Lens' ],
92+ ' N1' : [' PSV' , ' Ajax' , ' Feyenoord' , ' AZ Alkmaar' , ' Twente' , ' Utrecht' , ' Go Ahead Eagles' , ' Heerenveen' ],
93+ ' P1' : [' Benfica' , ' Porto' , ' Sporting CP' , ' Braga' , ' Vitoria Guimaraes' , ' Moreirense' , ' Famalicao' , ' Casa Pia' ],
94+ ' SC0' : [' Celtic' , ' Rangers' , ' Hearts' , ' Aberdeen' , ' Hibernian' , ' Motherwell' , ' Dundee Utd' , ' Kilmarnock' ],
95+ ' E1' : [' Leicester' , ' Leeds' , ' Southampton' , ' Burnley' , ' Sheffield Utd' , ' Norwich' , ' Middlesbrough' , ' West Brom' ]
8896 };
8997
9098 // Filter matches based on league with loading state
336344 };
337345 }
338346
339- const labels = recentMatches .map (m => {
340- try {
341- return format (new Date (m .match_date ), ' MMM dd' );
342- } catch (e ) {
343- return ' Invalid Date' ;
344- }
347+ // Convert to gameweek labels (every 10 games = 1 gameweek)
348+ const labels = recentMatches .map ((m , idx ) => {
349+ const gameweek = Math .floor (idx / 10 ) + 1 ;
350+ return ` GW${gameweek } ` ;
345351 });
346352 const homeGoals = recentMatches .map (m => m .home_score || 0 );
347353 const awayGoals = recentMatches .map (m => m .away_score || 0 );
447453 const apiData = apiChartData .team_performance ;
448454 const colors = [' #10b981' , ' #f59e0b' , ' #ef4444' , ' #8b5cf6' , ' #06b6d4' , ' #f97316' ];
449455 return {
450- labels: apiData .labels || [' Wins' , ' Points/Game' , ' Goals/Game' , ' Defense ' , ' Form' ],
456+ labels: apiData .labels || [' Wins' , ' Points/Game' , ' Goals/Game' , ' Clean Sheets ' , ' Form' ],
451457 datasets: (apiData .datasets || []).map ((dataset : any , index : number ) => ({
452458 ... dataset ,
453459 borderColor: dataset .borderColor || colors [index ] || ' #10b981' ,
493499 const matchesPlayed = teamMatches .length ;
494500 const goalDifference = goals - goalsAgainst ;
495501
502+ // Calculate clean sheets (matches where team conceded 0 goals)
503+ const cleanSheets = teamMatches .filter (m => {
504+ if (m .home_team === team ) return (m .away_score || 0 ) === 0 ;
505+ if (m .away_team === team ) return (m .home_score || 0 ) === 0 ;
506+ return false ;
507+ }).length ;
508+
496509 return {
497510 wins: wins * 2 , // Scale for visualization
498511 points: points / Math .max (matchesPlayed , 1 ) * 10 , // Points per game * 10
499512 goals: goals / Math .max (matchesPlayed , 1 ) * 15 , // Goals per game * 15
500- defense: Math . max ( 0 , ( 20 - ( goalsAgainst / Math . max ( matchesPlayed , 1 ) * 10 ))) , // Defensive rating
513+ cleanSheets: cleanSheets * 2 , // Clean sheets scaled for visualization
501514 form: goalDifference > 0 ? Math .min (goalDifference * 2 , 20 ) : 0 // Goal difference scaled
502515 };
503516 });
504517
505518 return {
506- labels: [' Wins' , ' Points/Game' , ' Goals/Game' , ' Defense ' , ' Form' ],
519+ labels: [' Wins' , ' Points/Game' , ' Goals/Game' , ' Clean Sheets ' , ' Form' ],
507520 datasets: teams .map ((team , i ) => ({
508521 label: team ,
509522 data: [
510523 stats [i ].wins ,
511524 stats [i ].points ,
512525 stats [i ].goals ,
513- stats [i ].defense ,
526+ stats [i ].cleanSheets ,
514527 stats [i ].form
515528 ],
516529 borderColor: colors [i ] || ' #10b981' ,
835848 <div class =" flex items-center justify-between mb-4" >
836849 <div class =" flex items-center gap-2" >
837850 <TrendingUp class =" w-4 h-4 sm:w-5 sm:h-5 text-green-500" />
838- <h3 class =" text-base sm:text-lg font-bold text-slate-900 dark:text-green-400 font-mono" >Goals Trend </h3 >
851+ <h3 class =" text-base sm:text-lg font-bold text-slate-900 dark:text-green-400 font-mono" >Goal Trends </h3 >
839852 </div >
840853 <button
841- on:click ={() => handleQueryClick (' goals_trend' , ' Goals Trend ' )}
854+ on:click ={() => handleQueryClick (' goals_trend' , ' Goal Trends ' )}
842855 class =" flex items-center gap-1.5 px-3 py-1.5 bg-green-500 hover:bg-green-600 text-white text-xs sm:text-sm rounded-lg transition-colors shadow-sm"
843856 title =" Generate SQL query for this chart"
844857 >
0 commit comments