PyLDAvis Component


I’m trying to leverage the dash-dangerously-set-inner-html custom component.

I have the following HTML file:

<link rel="stylesheet" type="text/css" href="">
<div id="ldavis_el239681122130198885674280583"></div>
<script type="text/javascript">

It basically renders graphs like the ones in this python notebook: (except my file is available as a standalone .html file)

I tried to include the content of the file in a dash-dangerously-set-inner-html section. It is actually well contained in the page source when I investigate, but I can’t see the graph.

Is there a way I can display this html file in a Dash application?

In advance, thanks.

1 Like

Very much +1! Would like to know this one too, as pyLDAvis and Dash are both amazing would be great to combine them in a Dash app.

You may find the beginning of an answer with the pyldavis_dash custom component I implemented. It’s quick and dirty, but it seems to work fine for my needs.

  • Clone it
  • pip install -e .
  • Argument you pass to data is the var section extracted from the htmlvis generated by pyLDAvis.save_html()
1 Like

Also trying to display a pyLDAvis html file but I can’t quite follow the advice above.

So I have my the output html file, but I don’t quite understand what “just extract the var section” means and what dash component should I be using?


1 Like

This link might be helpful for serving static assets such as images and html files:

I ended using an Iframe to display the html file:

                                            style=dict(position="absolute", left="0", top="0", width="100%", height="100%"))

Hey, thank you!!! You have no idea how many hours I have been stuck here. Now I am able to render an html file as a dash component. Thank you!

1 Like