I have a basic dash app but it has a lot of graphs, around 60+. Currently I have all my fig = px(…) written out one by one, but I would like to move to iterate through a dictionary of tables to create these figures. the figures then will go in the dash app hmtl.
I tried something like this, but I guess i don’t even know if these objects could be stored like this, or if this is the right concept to tackle this problem.
fx_charts = {}
for i in fx_tbls:
*#where fx_tbls{df1:dataframe, df2:dataframe, df3:dataframe}*
graph = px.line(fx_tbls[i], x='time', y='mid.c', title='{}'.format(i))
graph.update_xaxes(
title = 'Date Range',
rangeslider_visible=True,
rangeselector=dict(
bgcolor = '#F89880',
activecolor = '#FF4433',
buttons=list([
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all")
])
)
)
graph.update_yaxes(title = '')
graph.update_traces(line_color='#FF4500')
graph.update_layout(
plot_bgcolor='#1f2833',
paper_bgcolor='#1f2833',
font_color = 'white')
print(type(graph))
fx_charts[i] = graph
print(len(fx_charts))