Hey all!
Very new to Dash, and got a problem that I’m wrecking my brain with already, hooray! I’ve got a multitab data science Dash app with a dynamic number of tabs. This number is determined by the number of models, which in turn is determined by data (there’s a flag feature specifying which model any given datapoint belongs to, i.e. you can pass data that has model1 and model2 values, or model1, … , model_one_billion, it’s all up to the user). Because of that, tabs component is defined in the following way:
layout = dcc.Tabs(
id = ‘tabs-component’,
children = [
dcc.Tab(id={‘type’=‘tabs-component’, ‘id’ = m.id},
label = m.name,
selected_style={‘background-color’: "green’ if m.metrics.all() <= threshold else “white”}
for m in models
]
i.e. if all metrics of a given model are less than equal than a user defined threshold, the tab is colored green, otherwise it stays a default (white) color.
The difficulties begin to arise when I need to update the backgroud-color property. Metrics are also chosen by user (it’s a checkbox), so if the values of selected checkboxes change so should the color of the tabs (metric checkboxes are a global property, i.e. if you add a metric to one tab it’s added to the rest of them as well). The ids of individual tab components are determined on the fly depending on the data, so I can’t think of a way to specify them in a callback function in a functioning way. Any help would be greatly appreciated!