Hi guys,
I have a single page dash app that has a two tabs (Map and Status) and a callback function to render the tab based on the navigation selected and job site:
body = html.Div([
navbar.build_navbar(data_processor.site_name_list,
data_processor.config_builder),
dcc.Loading(children=[dbc.Container(
children=[
html.Div(id="main-area"),
]
)], type='default', fullscreen=True),
footer.build_footer()
], className="body"
)
@app.callback(
Output("main-area", "children"),
Input("navigation-tabs", "value"),
Input("jobsite-dropdown", "value"))
# Input('summary_map', 'clickData'))
def render_content(tab:str, job_site:str, map_click_data:dict=None):
'''
Renders the main area of the dashboard. Returns a list of dcc html.Divs
Parameters:
tab - the name of the tab selected in the navbar
job_site - the name of the job site
map_click_data - unit data of the clicked unit on the summary map
'''
# MAP PAGE
if tab == strings.TAB1_NAME:
return build_map_page(data_processor, job_site, last_data_refresh_html)
# STATUS PAGE
elif tab == strings.TAB2_NAME:
return build_statust_page(data_processor, job_site, last_data_refresh_html)
I would like to add some extra functionality so that a user can click on a marker on the map and go to a certain section on the status tab based on the marker clicked. I can get the marker name clicked using this callback:
# test callback when clicking on map
@app.callback(
Output('click-data', 'children'),
Input('summary_map', 'clickData'))
def display_click_data(clickData):
if clickData is None:
return None
else:
unit_name=clickData['points'][0]['customdata'][0]
return html.Div(unit_name)
What i would like to know is how to render the status tab when the user clicks on the map? Can you manually call the render_content() callback function? Can you change the Input(ânavigation-tabsâ) value somehow to trigger this callback? or is there a simpler way im overlooking?
Ive tried including Input(âsummary_mapâ, âclickDataâ)) to the render_content() callback but i get this error âA nonexistent object was used in an Input
of a Dash callback.â
Thanks for any suggestions, Precog