Dash RangeSlider & Slider unfit to min-max value and not displaying the marks

Hello,

I would like some help with setting my dcc.Slider and dcc.RangeSlider being unfit to given values and being not displayed in parts in some cases

Here are some examples of trouble cases:

First Case: Unfit slider

By Default it looks like this. Callback fired when I choose a Fund Asset Category.

Once I choose Equity, Slider goes outside of the range

This is the same case except this one falls below the max of the range

Second Case: RangeSlider marks not displaying


This is a case where Frais UC and Frais Euros are not displaying the marks for given maxima values (weird thing is code is identical to SCPI one but SCPI one works fine)

First Case Code:

""" FUND CALLBACKS """
@callback(
    Output("dropdown-asset-cat", "value"),
    Input("asset-cat-all", "value")
)
def all_asset_cat(value):
    if value == [" All"]:
        return df_fund['Global Broad Category Group'].drop_duplicates()

@callback(
    output=[
        Output("5y-return", "min"), Output("5y-return", "max"), Output("5y-return", "value"), Output("5y-return", "marks"),
        Output("5y-beta", "min"), Output("5y-beta", "max"), Output("5y-beta", "value"), Output("5y-beta", "marks"),
        Output("5y-alpha", "min"), Output("5y-alpha", "max"), Output("5y-alpha", "value"), Output("5y-alpha", "marks"),
        Output("5y-sharpe", "min"), Output("5y-sharpe", "max"), Output("5y-sharpe", "value"), Output("5y-sharpe", "marks"),
    ],
    inputs=[Input("dropdown-asset-cat", "value")]
)
def update_rangeslider(value):
    if value == None:
        raise PreventUpdate
    else:
        boolean_filter = df_fund['Global Broad Category Group'].isin(value)
        df = df_fund[boolean_filter][['Name', 'Total Ret Annlzd 5 Yr (Mo-End) EUR',
                                      'Alpha 5 Yr (Mo-End) EUR', 'Beta 5 Yr (Mo-End) EUR', 'Sharpe Ratio 5 Yr (Mo-End) EUR']]

        r_min = df['Total Ret Annlzd 5 Yr (Mo-End) EUR'].min()
        r_max = df['Total Ret Annlzd 5 Yr (Mo-End) EUR'].max()
        r_mid = (r_min + r_max)/2
        r_val = [r_min, r_max]
        r_marks = {
            r_min: f"{round(r_min, 2)}",
            (r_min + r_mid)/2: f"{round((r_min + r_mid)/2, 2)}",
            r_mid: f"{round(r_mid, 2)}",
            (r_mid + r_max)/2: f"{round((r_mid + r_max)/2, 2)}",
            r_max: f"{round(r_max, 2)}"
        }

        b_min = df['Beta 5 Yr (Mo-End) EUR'].min()
        b_max = df['Beta 5 Yr (Mo-End) EUR'].max()
        b_mid = (b_min + b_max) / 2
        b_val = [b_min, b_max]
        b_marks = {
            b_min: f"{round(b_min, 2)}",
            (b_min + b_mid)/2: f"{round((b_min + b_mid)/2, 2)}",
            b_mid: f"{round(b_mid, 2)}",
            (b_mid + b_max)/2: f"{round((b_mid + b_max)/2, 2)}",
            b_max: f"{round(b_max, 2)}"
        }

        a_min = df['Alpha 5 Yr (Mo-End) EUR'].min()
        a_max = df['Alpha 5 Yr (Mo-End) EUR'].max()
        a_mid = (a_min + a_max)/2
        a_val = [a_min, a_max]
        a_marks = {
            a_min: f"{round(a_min, 2)}",
            (a_min + a_mid)/2: f"{round((a_min + a_mid)/2, 2)}",
            a_mid: f"{round(a_mid, 2)}",
            (a_mid + a_max)/2: f"{round((a_mid + a_max)/2, 2)}",
            a_max: f"{round(a_max, 2)}"
        }

        s_min = df['Sharpe Ratio 5 Yr (Mo-End) EUR'].min()
        s_max = df['Sharpe Ratio 5 Yr (Mo-End) EUR'].max()
        s_mid = (s_min + s_max)/2
        s_val = [s_min, s_max]
        s_marks = {
            s_min: f"{round(s_min, 2)}",
            (s_min + s_mid)/2: f"{round((s_min + s_mid)/2, 2)}",
            s_mid: f"{round(s_mid, 2)}",
            (s_mid + s_max)/2: f"{round((s_mid + s_max)/2, 2)}",
            s_max: f"{round(s_max, 2)}"
        }
        return r_min, r_max, r_val, r_marks, b_min, b_max, b_val, b_marks, a_min, a_max, a_val, a_marks, s_min, s_max, s_val, s_marks

@callback(
    output=[
        # Output("sus-slider", "min"), Output("sus-slider", "max"), Output("sus-slider", "value"), Output("sus-slider", "marks"),
        Output("e-slider", "min"), Output("e-slider", "max"), Output("e-slider", "value"), Output("e-slider", "marks"),
        Output("s-slider", "min"), Output("s-slider", "max"), Output("s-slider", "value"), Output("s-slider", "marks"),
        Output("g-slider", "min"), Output("g-slider", "max"), Output("g-slider", "value"), Output("g-slider", "marks")
    ],
    inputs=[Input("dropdown-asset-cat", "value")]
)
def update_slider(value):
    if value == None:
        raise PreventUpdate
    else:
        boolean_filter = df_fund['Global Broad Category Group'].isin(value)
        df = df_fund[boolean_filter][['Name', 'Portfolio Sustainability Score', 'Portfolio Environmental Risk Score',
                                      'Portfolio Social Risk Score', 'Portfolio Governance Risk Score']]

        sus_min = df['Portfolio Sustainability Score'].min()
        sus_max = df['Portfolio Sustainability Score'].max()
        sus_mid = (sus_min + sus_max) / 2
        sus_val = round(sus_max, 2)
        sus_marks = {
            round(sus_min, 2): {'label': 'Indifferent', 'style': {'color': '#ffba00'}},
            # round((sus_min + sus_mid) / 2, 2): "",
            round(sus_mid, 2): {'label': 'Moderate', 'style': {'color': '#e3dd34'}},
            # round((sus_mid + sus_max) / 2, 2): "",
            round(sus_max, 2): {'label': 'High', 'style': {'color': '#2abd3b'}}
        }

        e_min = df['Portfolio Environmental Risk Score'].min()
        e_max = df['Portfolio Environmental Risk Score'].max()
        e_mid = (e_min + e_max) / 2
        e_val = round(e_max, 2)
        e_marks = {
            round(e_min, 2): {'label': 'Indifferent', 'style': {'color': '#ffba00'}},
            # round((sus_min + sus_mid) / 2, 2): "",
            round(e_mid, 2): {'label': 'Moderate', 'style': {'color': '#e3dd34'}},
            # round((sus_mid + sus_max) / 2, 2): "",
            round(e_max, 2): {'label': 'High', 'style': {'color': '#2abd3b'}}
        }

        s_min = df['Portfolio Social Risk Score'].min()
        s_max = df['Portfolio Social Risk Score'].max()
        s_mid = (s_min + s_max) / 2
        s_val = round(s_max, 2)
        s_marks = {
            round(s_min, 2): {'label': 'Indifferent', 'style': {'color': '#ffba00'}},
            # round((sus_min + sus_mid) / 2, 2): "",
            round(s_mid, 2): {'label': 'Moderate', 'style': {'color': '#e3dd34'}},
            # round((sus_mid + sus_max) / 2, 2): "",
            round(s_max, 2): {'label': 'High', 'style': {'color': '#2abd3b'}}
        }

        g_min = df['Portfolio Governance Risk Score'].min()
        g_max = df['Portfolio Governance Risk Score'].max()
        g_mid = (g_min + g_max) / 2
        g_val = round(g_max, 2)
        g_marks = {
            round(g_min, 2): {'label': 'Indifferent', 'style': {'color': '#ffba00'}},
            # round((sus_min + sus_mid) / 2, 2): "",
            round(g_mid, 2): {'label': 'Moderate', 'style': {'color': '#e3dd34'}},
            # round((sus_mid + sus_max) / 2, 2): "",
            round(g_max, 2): {'label': 'High', 'style': {'color': '#2abd3b'}}
        }
        # return sus_min, sus_max, sus_val, sus_marks, e_min, e_max, e_val, e_marks, s_min, s_max, s_val, s_marks, g_min, g_max, g_val, g_marks
        return e_min, e_max, e_val, e_marks, s_min, s_max, s_val, s_marks, g_min, g_max, g_val, g_marks

Second Case Code:

frais_uc_min = df_contract['Frais UC (%)'].min()
frais_uc_max = df_contract['Frais UC (%)'].max()
frais_uc_mid = (frais_uc_min + frais_uc_max)/2;

frais_euros_min = df_contract['Frais fonds en euros (%)'].min()
frais_euros_max = df_contract['Frais fonds en euros (%)'].max()
frais_euros_mid = (frais_euros_min + frais_euros_max)/2

frais_scpi_min = df_contract['Frais SCPI (%)'].min()
frais_scpi_max = df_contract['Frais SCPI (%)'].max()
frais_scpi_mid = (frais_scpi_min + frais_scpi_max)/2

""" CONTRACT TAB """
second_tab_container = dbc.Container(
    [
        dbc.Row(
            [
                dbc.Col(
                    [
                        html.H4("Assureur", className="card-title"),
                        dcc.Dropdown(
                            options=[
                                {'label': name, "value": name} for name in df_contract['Assureur'].drop_duplicates()
                            ],
                            value=[],
                            id="screener-contract-insurer-dropdown",
                            placeholder="Choose at least one insurer",
                            multi=True,
                            className="mb-1"
                        ),
                        dcc.Checklist(options=[{"label": " All", "value": " All", "disabled": False}],
                                      value=[], id="insurer-all", className="mb-4"),

                        html.H4("Contrat", className="card-title"),
                        dcc.Dropdown(
                            options=[
                                {'label': name, "value": name} for name in df_contract['Nom Assurance Vie']
                            ],
                            value=[],
                            id="screener-contract-contract-dropdown",
                            placeholder="Choose at least one contract",
                            multi=True,
                            className="mb-1"
                        ),
                        dcc.Checklist(options=[{"label": " All", "value": " All", "disabled": True}],
                                      value=[], id="contract-all", className="mb-4"),

                        html.H4("Frais UC (%)", className="card-title"),
                        dcc.RangeSlider(
                            id="screener-UC-slider",
                            min=frais_uc_min,
                            max=frais_uc_max,
                            step=0.01,
                            value = [frais_uc_min, frais_uc_max],
                            marks={
                                frais_uc_min: f"{round(frais_uc_min, 2)}",
                                (frais_uc_min + frais_uc_mid)/2: f"{round((frais_uc_min + frais_uc_mid)/2, 2)}",
                                frais_uc_mid: f"{frais_uc_mid}",
                                (frais_uc_max + frais_uc_mid)/2: f"{round((frais_uc_max + frais_uc_mid)/2, 2)}",
                                frais_uc_max: f"{round(frais_uc_max, 2)}",
                            },
                            allowCross=False,
                            className="mb-5"
                        ),

                        html.H4("Frais Euros (%)", className="card-title"),
                        dcc.RangeSlider(
                            id="screener-euros-slider",
                            min=frais_euros_min,
                            max=frais_euros_max,
                            step= 0.01,
                            value=[frais_euros_min, frais_euros_max],
                            marks={
                                frais_euros_min: f"{round(frais_euros_min, 2)}",
                                (frais_euros_min + frais_euros_mid) / 2: f"{round((frais_euros_min + frais_euros_mid) / 2, 2)}",
                                frais_euros_mid: f"{frais_euros_mid}",
                                (frais_euros_max + frais_euros_mid) / 2: f"{round((frais_euros_max + frais_euros_mid) / 2, 2)}",
                                frais_euros_max: "max"# f"{round(frais_euros_max, 2)}",
                            },
                            allowCross=False,
                            className="mb-5"
                        ),

                        html.H4("Frais SCPI (%)", className="card-title"),
                        dcc.RangeSlider(
                            id="screener-SCPI-slider",
                            min=frais_scpi_min,
                            max=frais_scpi_max,
                            step=0.01,
                            value=[frais_scpi_min, frais_scpi_max],
                            marks={
                                frais_scpi_min: f"{round(frais_scpi_min, 2)}",
                                (frais_scpi_min + frais_scpi_mid) / 2: f"{round((frais_scpi_min + frais_scpi_mid) / 2, 2)}",
                                frais_scpi_mid: f"{frais_scpi_mid}",
                                (frais_scpi_max + frais_scpi_mid) / 2: f"{round((frais_scpi_max + frais_scpi_mid) / 2, 2)}",
                                frais_scpi_max: f"{round(frais_scpi_max, 2)}",
                            },
                            allowCross=False
                        ),
                    ]
                )
            ],
        ),
    ],
    fluid=True
)

I don’t know if the problem is linked to the data but data types are correct (float) and some work and some don’t which makes me hard to figure out what is causing the error.

T_T