File size: 2,780 Bytes
ffe1030
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import streamlit as st
import pandas as pd
import plotly.express as px 
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from charts import (
    create_top_players_chart, 
    create_actions_distribution_chart, 
    create_matches_activity_chart,
    create_performance_heatmap,        # ← NOUVEAU
    create_team_activity_heatmap,       # ← NOUVEAU
    create_performance_comparison_chart,  # ← NOUVEAU
    create_performance_violin_chart
)
from analytics.scoring import *

def show_dashboard(df):
    """Affiche le tableau de bord principal"""

    st.divider()
    
    # Métriques générales

    metrics_config = [
        {
            "title": "Moy. note match",
            "value": get_global_score(df),
            "format": "{:,.2f}"
        },
        {
            "title": "Total actions",
            "value": df['Nb_actions'].sum(),
            "format": "{:,.0f}"
        },
        {
            "title": "Joueuses actives", 
            "value": df['Nom'].nunique(),
            "format": "{}"
        },
        {
            "title": "Matchs analysés",
            "value": df['Match'].nunique(), 
            "format": "{}"
        },
        {
            "title": "Moy. actions/joueuse",
            "value": df.groupby(['Prenom', 'Nom'])['Nb_actions'].sum().mean(),
            "format": "{:.0f}"
        }
    ]
    
    # Création des colonnes dynamiquement
    cols = st.columns(len(metrics_config))
    
    # Affichage des métriques avec une boucle
    for i, metric in enumerate(metrics_config):
        with cols[i]:
            formatted_value = metric["format"].format(metric["value"])
            st.metric(metric["title"], formatted_value)

    
    st.divider()
    


    fig = create_performance_violin_chart(df)
    # fig = create_performance_comparison_chart(df)
    st.plotly_chart(fig, use_container_width=True)

    # Graphiques principaux
    col1, col2 = st.columns(2)
    
    with col1:
        fig = create_top_players_chart(df, n_players=15)
        st.plotly_chart(fig, use_container_width=True)
    
    with col2:
        fig = create_actions_distribution_chart(df)
        st.plotly_chart(fig, use_container_width=True)
        
    # Graphiques pleine largeur
    # col1, col2 = st.columns(2)
    
    # with col1:
    #     fig = create_matches_activity_chart(df)
    #     st.plotly_chart(fig, use_container_width=True)
    
    # with col2:
    #     fig = create_team_activity_heatmap(df)
    #     st.plotly_chart(fig, use_container_width=True)
    
    # st.divider()

    # fig = create_performance_heatmap(df, n_players=15)
    # st.plotly_chart(fig, use_container_width=True)