File size: 1,695 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
"""Configuration et constantes pour les graphiques"""

# Couleurs Stade Toulousain
COLORS = {
    'primary': '#CC0C13',      # Rouge principal
    'secondary': '#000000',    # Noir
    'white': '#FFFFFF',        # Blanc
    'light_red': 'rgba(204, 12, 19, 0.2)',
    'gray': '#666666'
}

# Palette pour dégradés STANDARD (noir -> rouge)
COLORSCALE = [[0, COLORS['secondary']], [1, COLORS['primary']]]

# Palette pour dégradés HEATMAP (blanc -> rouge)
COLORSCALE_HEATMAP = [[0, COLORS['white']], [1, COLORS['primary']]]

# Palette inversée (rouge -> blanc) pour certains cas
COLORSCALE_REVERSED = [[0, COLORS['primary']], [1, COLORS['white']]]

# Couleurs discrètes
DISCRETE_COLORS = [COLORS['primary'], COLORS['secondary'], COLORS['white'], COLORS['gray']]

# Style de base réutilisable
BASE_LAYOUT = {
    'plot_bgcolor': 'rgba(248, 249, 250, 0.5)',
    'paper_bgcolor': 'rgba(0,0,0,0)',
    'font': dict(family='Arial', color=COLORS['secondary'], size=11)
}

def remove_colorscale_legend(fig):
    """Fonction utilitaire pour enlever la colorscale de n'importe quel graphique"""
    fig.update_traces(showscale=False)
    return fig

def apply_stade_style(fig, title=None, remove_colorbar=True):
    """Applique le style Stade Toulousain avec option pour enlever la colorbar"""
    
    if remove_colorbar:
        fig.update_traces(showscale=False)
    
    fig.update_layout(
        **BASE_LAYOUT,
        title={
            'text': title,
            'font': dict(color=COLORS['primary'], size=16, family='Arial Black'),
            'x': 0.5,
            'xanchor': 'center'
        } if title else None
    )
    
    return fig