Hi all, is there a way to export an existing dash_table.DataTable as an image (e.g. png, jpg) directly from the Callback? I tried fig.savefig but that doesn’t work here. Any ideas/directions? See my Callback below.
Thank you in advance!
# CALLBACK to return input value
@app.callback(
Output(component_id='output_report_part4', component_property='children'),
Input(component_id='advice-dropdown', component_property='value'),
Input(component_id='expanded-advice-text', component_property='value'),
)
def update_output_div4(advice, expanded_advice):
df = {'Metric': ['Advice to purchase the dataset:',
'Conclusion with expanded advice:'],
'Response': [advice, expanded_advice]}
# Create DataFrame
df = pd.DataFrame(df)
fig = dash_table.DataTable(df.to_dict('records'), [{"name": i, "id": i} for i in df.columns],
# style_cell={'textAlign': 'left'},
style_header={'backgroundColor': 'rgb(39,64,139)',
'color': 'white'},
style_data={'whiteSpace': 'normal',
'height': 'auto'},
style_cell_conditional=[
{
'if': {'column_id': c},
'textAlign': 'left'
} for c in ['Metric', 'Data Vendor']
],
style_cell={
'height': 'auto',
# all three widths are needed
'minWidth': '90px', 'width': '90px', 'maxWidth': '90px',
'whiteSpace': 'normal'
}
)
return fig