dash icon indicating copy to clipboard operation
dash copied to clipboard

[Feature Request] Ability to view Dash pages offline without interactivity

Open rsandler00 opened this issue 2 years ago • 3 comments

Hi,

I plotted a bunch of things in a dash layout. I want to save them to an html file so I can look at them later. I understand that I will loose all interactivity with the server, but in my use case, I mostly use Dash to just display a bunch of plotly plots on a single page, so I dont mind.

When I reopen the saved html file, I first see everything correctly. However, within <1s, the page goes blank and I get an error: “Error loading layout”. (see gif below).

image

How can this be fixed?

NOTE: I had the same issue in 2018 and posted this on StackOverflow here: https://stackoverflow.com/questions/49677428/saving-dash-layout-to-html. I got a working answer to remove the bundle(2).js reference in the html, but this no longer works in Dash 2.3.1

rsandler00 avatar May 19 '22 14:05 rsandler00

We don't have any plans to officially support this behavior, but if you can find the script tag that says var renderer = new DashRenderer(); and delete that, it may do what you want.

alexcjohnson avatar May 23 '22 21:05 alexcjohnson

Thanks @alexcjohnson ! Unfortunately, that does not work (never gets past "Loading..").

Is there a better way to embed multiple plotly figures into a single HTML page within python? The subplots API is not flexible enough for what I need.

Thanks

rsandler00 avatar May 24 '22 06:05 rsandler00

How to view app.layout rendered in html? without starting the server? e.g.

from dash import Dash,html
app = Dash(__name__)
app.layout = html.Div('this is some text sample')

how to view app.layout like this:

<body>
<div id="react-entry-point">
    <div>this is some text sample</div>
</div>
</body>

it is very inconvenient to stop and start server, debug = True helps only if layout present in the main app, what if layout of app is present in another file layout.py or separated in multiple files. eg. narbar.py, footer.py ...

please consider adding a function .to_html() .

container = html.Div(className='container',id='main_div',children=[....])
container.to_html()

it will really help to increase productivity.

patilabhay679 avatar Sep 02 '22 12:09 patilabhay679