Boxplot in Dash

Might be weird but want to ask. When I use the following code in python notebook,

import plotly
import plotly.plotly as py
import plotly.graph_objs as go

plotly.offline.init_notebook_mode()

import numpy as np
y0 = np.random.randn(50)-1
y1 = np.random.randn(50)+1
trace0 = go.Box(y=y0)
trace1 = go.Box(y=y1)
traces1 = [trace0, trace1]
data = [trace0,trace1]
layout = go.Layout(title = 'test title')

fig = go.Figure(data=data,layout=layout)
plotly.offline.iplot(data, filename='test')

I get

When I use the following as Dash Flask,

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

import flask
import numpy as np
import plotly.graph_objs as go

server = flask.Flask('app')

app = dash.Dash('app', server=server)
app.scripts.config.serve_locally = False
dcc._js_dist[0]['external_url'] = 'https://cdn.plot.ly/plotly-basic-latest.min.js'

app.layout = html.Div([
    html.H1('Test'),
    dcc.Input(
        id='my-input',
        placeholder='Enter a value...',
        type='text',
        value=''
    ),
    dcc.Graph(id='my-graph')
], className="container")

@app.callback(Output('my-graph', 'figure'),
              [Input('my-input', 'value')])
def update_graph(input_text):
    y0 = np.random.randn(50)-1
    y1 = np.random.randn(50)+1
    trace0 = go.Box(y=y0)
    trace1 = go.Box(y=y1)
    data = [trace0, trace1]
    return {
        'data': data,
        'layout': go.Layout(
            title=input_text
        )
    }

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

I get

Anything wrong with my Flask code? Why not getting Boxplot in web?

Thanks

1 Like

thanks for reporting! what version of dash_core_components are you on?

I install a few days ago:

sudo pip3 install dash==0.36.0  # The core dash backend
sudo pip3 install dash-html-components==0.13.5  # HTML components
sudo pip3 install dash-core-components==0.43.0  # Supercharged components
sudo pip3 install dash-table==3.1.11  # Interactive DataTable component (new!)
sudo pip3 install dash-daq==0.1.0  # DAQ components (newly open-sourced!)

And here are details:

ls /python3.6/site-packages/*dash*
/python3.6/site-packages/dash:

/python3.6/site-packages/dash-0.36.0-py3.6.egg-info:
PKG-INFO		dependency_links.txt	installed-files.txt	top_level.txt
SOURCES.txt		entry_points.txt	requires.txt

/python3.6/site-packages/dash_core_components:

/python3.6/site-packages/dash_core_components-0.43.0-py3.6.egg-info:

/python3.6/site-packages/dash_daq:

/python3.6/site-packages/dash_daq-0.1.0-py3.6.egg-info:

/python3.6/site-packages/dash_html_components:

/python3.6/site-packages/dash_html_components-0.13.5-py3.6.egg-info:
PKG-INFO		dependency_links.txt	requires.txt
SOURCES.txt		installed-files.txt	top_level.txt

/python3.6/site-packages/dash_renderer:
__init__.py				dash_renderer.min.js			react@15.4.2.min.js
__pycache__				dash_renderer.min.js.map		react@16.2.0.production.min.js
dash_renderer.dev.js			react-dom@15.4.2.min.js			version.py
dash_renderer.dev.js.map		react-dom@16.2.0.production.min.js

/python3.6/site-packages/dash_renderer-0.18.0-py3.6.egg-info:
PKG-INFO		SOURCES.txt		dependency_links.txt	installed-files.txt	top_level.txt

/python3.6/site-packages/dash_table:
DataTable.py		__pycache__		bundle.js		metadata.json
__init__.py		_imports_.py		bundle.js.map		package-info.json

/python3.6/site-packages/dash_table-3.1.11-py3.6.egg-info:
PKG-INFO		dependency_links.txt	requires.txt
SOURCES.txt		installed-files.txt	top_level.txt

I just tried newer version and has the same issue.

sudo pip3 install dash
sudo pip3 install dash-html-components
sudo pip3 install dash-core-components
sudo pip3 install dash-table
sudo pip3 install dash-daq

dash-0.37.0 dash-core-components-0.43.1 dash-html-components-0.13.5 dash-table-3.4.0 dash-daq-0.1.1

Hi,Any update on the issue, even am facing the same issue.

Also struggling with this, would appreciate an update

I did not get update for a while on this thread.

try removing this line? this is not an official api