@AIMPED
This is my code for ( a datepicker, dropdown and graph ) then you will find the code of callback
dbc.Col(
dcc.DatePickerRange(
id='org-mt-voice-per-site-date-picker', # ID to be used for callback
calendar_orientation='horizontal', # vertical or horizontal
day_size=39, # size of calendar image. Default is 39
end_date_placeholder_text="End Date", # text that appears when no end date chosen
with_portal=False, # if True calendar will open in a full screen overlay portal
first_day_of_week=0, # Display of calendar when open (0 = Sunday)
reopen_calendar_on_clear=True,
is_RTL=False, # True or False for direction of calendar
clearable=True, # whether or not the user can clear the dropdown
number_of_months_shown=1, # number of months shown when calendar is open
min_date_allowed=org_mt_traffic_ob_per_road['date'].min(),
# minimum date allowed on the DatePickerRange component
max_date_allowed=org_mt_traffic_ob_per_road['date'].max(),
initial_visible_month=org_mt_traffic_ob_per_road['date'].min(),
display_format='MMM Do, YY',
month_format='MMMM, YYYY',
persistence=True,
persisted_props=['start_date'],
# persistence_type='session',
updatemode='bothdates',
# className='bg-opacity-50 p-2 m-1 bg-primary'
),
),
dbc.Col(
dcc.Dropdown(
id="dropdown-sites-mt-traffic",
options=[
{'label': i, 'value': i} for i in org_mt_roads
],
multi=True,
placeholder="Select Road",
),
),
dcc.Graph(id='org-mt-per-site-paragraph',
figure=px.line(data_frame=org_mt_traffic_ob_per_site, x='date', y="Duration_Min",
color='Site', title="ORG MT Voice Traffic Per Site - Min/day", markers=True,
),
responsive=True, style={'display': 'block', 'margin-top': '3rem', 'width': '58rem',
'margin-right': '2rem', 'border': 'solid black'},
),
]),
@app.callback(
Output(component_id="org-mt-per-site-paragraph", component_property='figure'),
Input(component_id="dropdown-sites-mt-traffic", component_property="value"),
prevent_inital_call=True
)
def update_org_mt_site_ob(selected_road):
print(selected_road)
if selected_road is None:
selected_road = ["Beheira"]
df = org_mt_traffic_ob_per_site[org_mt_traffic_ob_per_site['Road_Name'].isin(selected_road)]
print(df.head())
org_mt_per_site_paragraph = Patch()
org_mt_per_site_paragraph['layout']['color'] = df['Site'].values
return org_mt_per_site_paragraph