facets icon indicating copy to clipboard operation
facets copied to clipboard

How can facets-dive be integrated with dash-plotly

Open dantp-ai opened this issue 6 years ago • 4 comments
trafficstars

https://dash.plot.ly

dantp-ai avatar Jan 18 '19 11:01 dantp-ai

Basic working example. Though I'd still like to hear your opinion on better integration

import os
import sys
import pandas as pd

import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_dangerously_set_inner_html

DEBUG = True
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

data = pd.read_csv(???)
data = data.to_json(orient='records')

app = dash.Dash('')

app.layout = html.Div(children=[
    html.Iframe(
        width="1200",
        height="800",
        srcDoc="""
        <link rel="import" href="https://raw.githubusercontent.com/PAIR-code/facets/master/facets-dist/facets-jupyter.html">
      <facets-dive id="elem" height="800" width="1200"></facets-dive>
      <script>
        var data = {jsonstr};
        document.querySelector("#elem").data = data;
      </script>""".format(jsonstr=data)
    ),
])

if __name__ == '__main__':
    app.run_server(debug=DEBUG)

dantp-ai avatar Jan 18 '19 13:01 dantp-ai

I don't have any experience with dash-plotly. Did your above code work?

jameswex avatar Jan 18 '19 16:01 jameswex

Yes.

dantp-ai avatar Jan 18 '19 18:01 dantp-ai

Hi @plopd,

Thanks for you post. When I run the code with a local csv file, I get an empty frame. Am I missing some library?

Thanks, Davide

dbau avatar Feb 26 '21 08:02 dbau