Hello,
I am trying to build a dash app and trying to save charts/tables as png (or any other format). I have experience coding but it’s mostly with Matlab and limited building front-end dashboards.
I came across a viable solution in
matplotlib in dash
In there there is a portion of code which I don’t understand regarding to saving the figure in a temporary buffer.
# Save it to a temporary buffer.
buf = BytesIO()
fig.savefig(buf, format="png")
# Embed the result in the html output.
fig_data = base64.b64encode(buf.getbuffer()).decode("ascii")
fig_bar_matplotlib = f'data:image/png;base64,{fig_data}'
If I send fig directly to callback it gives me an error (as the writer mentioned). I could copy and paste the code to all my charts/graphs, but I would like to know the logic/theory behind so that if something goes wrong (because code never goes wrong /s)
Any links/blogs/books whatever would be helpful.
Thanks, J