Skip to content

Instantly share code, notes, and snippets.

@infinite-Joy
Created September 20, 2017 06:29
Show Gist options
  • Select an option

  • Save infinite-Joy/78ca76c16e40244b2bfa6df8bf2dbbc2 to your computer and use it in GitHub Desktop.

Select an option

Save infinite-Joy/78ca76c16e40244b2bfa6df8bf2dbbc2 to your computer and use it in GitHub Desktop.
print('Changing to jsonstr to feed to html file')
jsonstr = df_state.to_json(orient='records')
# Create an HTML file that will have the visualisation
from IPython.core.display import display, HTML
HTML_TEMPLATE = """<link rel="import" href="/nbextensions/facets-dist/facets-jupyter.html">
<facets-dive id="elem" height="600"></facets-dive>
<script>
var data = {jsonstr};
document.querySelector("#elem").data = data;
</script>"""
html = HTML_TEMPLATE.format(jsonstr=jsonstr)
out = HTML(html).data
# write the html to a file
with open('html_file.html', 'w') as f:
f.write(out)
print('file saved')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment