Python – How to export a plotly dashboard app into a html standalone file to share with the others

plotlyplotly-dashpython

I have built a plotly interactive dashboard, and am looking a way to export this app to HTML format, and share it with others.

Is there any hints for me?

I have googled, and most answer divert me to the following links.

https://plot.ly/python/getting-started-with-chart-studio/

and i have tried to put :

import plotly.io as pio

pio.write_html(app, file='hello_world.html', auto_open=True)

in my app.py after :

if __name__ == "__main__":
    app.run_server(debug=True, port=8052)

but it doesn't work.

Best Answer

So I think the answer you needed was "it cannot be done".

To clarify the repeated ask of converting a dashboard to HTML:

HTML is a markup language; it displays text in aesthetic ways, you can use CSS to improve the aesthetics.

The idea of interactivity like a dashboard where onClick() leads to changes in visuals because the csv file was re-queried or filtered or re-calculated is what a server-side brings to the HTML/CSS/JavaScript front-end.

You cannot have a fully encapsulated dashboard with interactivity in an HTML file alone. You must bring server-side logic to the table. This is why everyone is mentioning Heroku, AWS, etc.

Now if your dashboard is not interactive, and it's actually just a bunch of static visuals with some basic hover-over effects; then a standalone HTML file can read in SVGs that contain hover over text prepared. This is what plotly's write_html does (my understanding is plotly.offline.plot just uses this under the hood or something similar).

The gist that someone else noted, duplicated here:

https://gist.github.com/ybressler/e0d40e63a5f35cf2dda65378333c6436

Shows the limits of HTML only "dashboarding". You can show/hide and hover over points, but you can't incorporate sliders that change values without the server side or very bloated and complex show/hide logic hidden somewhere.

Image of 3-D HTML plot with limited interactivity.