How to define def update_output after callback to taht the value ap gets changed?

Hello the treemap displays the difference in sales between two days i want to be able to change the date in the dashboard so that the treemap gets updated automaticly but can^t fix it so that it works i think everything works but the def update_output i dont know how to make it corectly
thanks for your help

import os

import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
import keyring
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.io as pio
import seaborn as sns
from dash import dash, dcc, html
from dash.dependencies import Input, Output, State
from dash_bootstrap_templates import load_figure_template
from sqlalchemy.types import NVARCHAR

from HANA_connect import HANA

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.DARKLY])

load_figure_template("darkly")
colors = {
    'background': '#111111',
    'text': 'white'
}

login = os.getlogin() # Login holen
pwd=keyring.get_password('HANA_CS4',os.getlogin().upper()) # Passwort holen

cs4 = HANA(login, pwd) # Verbindung ertellen

sqlquery="""SELECT * FROM ZOLS2.korr_plot"""

df = cs4.getDf2(sqlquery)


sqlquery="""SELECT * FROM ZOLS2.hccoop_Treemap WHERE CCM_HC_CD  IN ('010112') and NU_AP>50000"""
sqlquery="""SELECT * FROM ZOLS2.HCCOOP_TREEMAP_ZEITREIHE WHERE CCM_HC_CD  IN ('010112') """

df1 = cs4.getDf2(sqlquery)

df1.head()
df1.JAHR_MONAT.unique()


ap= '202108'
vp= '202208'
df_ap = df1.loc[df1.JAHR_MONAT==ap,['JAHR_MONAT', 'CCM_HC_CD', 'CCM_HC_TEXT', 'CCM_CATEGORY_CD','CCM_CATEGORY_TEXT', 'CCM_SUBCATEGORY_CD', 'CCM_SUBCATEGORY_TEXT','MARKE_CD', 'MARKE_TEXT', 'NU','DB_KUNDE']]
df_vp = df1.loc[df1.JAHR_MONAT==vp,['JAHR_MONAT', 'CCM_HC_CD', 'CCM_HC_TEXT', 'CCM_CATEGORY_CD','CCM_CATEGORY_TEXT', 'CCM_SUBCATEGORY_CD', 'CCM_SUBCATEGORY_TEXT','MARKE_CD', 'MARKE_TEXT', 'NU','DB_KUNDE']]
df_tree = pd.merge(df_ap, df_vp, how='inner', on = [ 'CCM_HC_CD', 'CCM_HC_TEXT', 'CCM_CATEGORY_CD','CCM_CATEGORY_TEXT', 'CCM_SUBCATEGORY_CD', 'CCM_SUBCATEGORY_TEXT','MARKE_CD', 'MARKE_TEXT'],suffixes=('_AP', '_VP'))
df_tree['NU_INDEX'] = df_tree.NU_AP/df_tree.NU_VP
df_tree['DB_INDEX'] = df_tree.DB_KUNDE_AP/df_tree.DB_KUNDE_VP
df_tree['NU_INDEX'] = df_tree['NU_INDEX'].apply(lambda x : 1 if x==0 else x)
df_tree['NU_INDEX'] = df_tree['NU_INDEX'].astype(float)
df_tree['NU_INDEX'] = round(df_tree['NU_INDEX']*1,4)
df_tree['DB_INDEX'] = df_tree['DB_INDEX'].apply(lambda x : 1 if x==0 else x)
df_tree['DB_INDEX'] = df_tree['DB_INDEX'].astype(float)
df_tree['DB_INDEX'] = round(df_tree['DB_INDEX']*1,4)
df_tree.NU_VP = df_tree.NU_VP.astype(float)
df_tree.NU_AP = df_tree.NU_AP.astype(float)
df_tree.DB_KUNDE_VP = df_tree.DB_KUNDE_VP.astype(float)
df_tree.DB_KUNDE_AP = df_tree.DB_KUNDE_AP.astype(float)
df_tree.CCM_HC_TEXT = df_tree.CCM_HC_TEXT.astype(str)
df_tree.CCM_CATEGORY_TEXT = df_tree.CCM_CATEGORY_TEXT.astype(str)
df_tree.CCM_SUBCATEGORY_TEXT = df_tree.CCM_SUBCATEGORY_TEXT.astype(str)
df_tree.MARKE_TEXT = df_tree.MARKE_TEXT.astype(str)
#df1.CCM_SEGMENT_TEXT = df1.CCM_SEGMENT_TEXT.astype(str)
#df1.CCM_SUBSEGMENT_TEXT = df1.CCM_SUBSEGMENT_TEXT.astype(str)
df_tree.fillna('-', inplace=True)
df_tree = df_tree[df_tree['NU_AP']!=0]
df_tree['INDEX_COLOR_NU'] = df_tree['NU_INDEX'].apply(lambda x : 0.6 if x<0.6 else  1.4 if x>1.4 else x)
df_tree['INDEX_COLOR_DB'] = df_tree['DB_INDEX'].apply(lambda x : 0.6 if x<0.6 else  1.4 if x>1.4 else x)


fig = px.treemap(df_tree, path=[px.Constant("Coop"),"CCM_HC_TEXT" ,"CCM_CATEGORY_TEXT","CCM_SUBCATEGORY_TEXT",'MARKE_TEXT'], values='NU_AP',
                  color_continuous_scale=[(0, "red"), (0.5, "white"), (1, "green")],
                  color_continuous_midpoint=1,
                  color=df_tree.INDEX_COLOR_NU,
                width=1800, height=1250)

fig.update_layout(margin = dict(t=100, l=50, r=25, b=25))

app.layout = html.Div(style={'backgroundColor': colors['background']}, children=[
    html.H1(
        children='Brot/Backwaren NU Dashboard',
        style={
            'textAlign': 'center',
            'color': colors['text']
        }
    ),
  dcc.Dropdown([{
            "label": html.Div(['08.2022'], style={'text': 'black', 'font-size': 20}),
            "value": "202208",
        },
        {
            "label": html.Div(['07.2022'], style={'text': 'black', 'font-size': 20}),
            "value": "202207",
        },
        {
            "label": html.Div(['06.2022'], style={'text': 'black', 'font-size': 20}),
            "value": "202206",
        },  ], value='202208',  id='demo1dropdown'), 
        html.Div(id='dd1outputcontainer'),

 dcc.Dropdown([{
            "label": html.Div(['08.2022'], style={'text': 'black', 'font-size': 20}),
            "value": "202208",
        },
        {
            "label": html.Div(['07.2022'], style={'text': 'black', 'font-size': 20}),
            "value": "202207",
        },
        {
            "label": html.Div(['06.2021'], style={'text': 'black', 'font-size': 20}),
            "value": "202106",
        },  ],   placeholder='Select_Datum', value='202208',  
        id='demo2dropdown'),   
        html.Div(id='dd2outputcontainer'),
    dcc.Graph(
        id='life-exp-vs-gdp',
        figure = fig
    )

])   


@app.callback(
    Output('dd2outputcontainer', 'children'),
    Input('demo2dropdown', 'value'))


def update_output(input_value):
  
  
    df_aap = df_ap[df_ap.ap == input_value]
    df_updatefig = df_tree[df_tree.df_ap == df_aap]
    
   
    fig = px.treemap(df_updatefig, path=[px.Constant("Coop"),"CCM_HC_TEXT" ,"CCM_CATEGORY_TEXT","CCM_SUBCATEGORY_TEXT",'MARKE_TEXT'], values='NU_AP',
                  color_continuous_scale=[(0, "red"), (0.5, "white"), (1, "green")],
                  color_continuous_midpoint=1, color=df_tree.INDEX_COLOR_NU, width=3840, height=1750)

    fig.update_layout(margin = dict(t=100, l=50, r=25, b=25))
    return fig



if __name__ == '__main__':
    app.run_server(debug=True)