Created
May 11, 2019 03:36
-
-
Save bretcj7/896d8c1e6f1d90c7de187377356ec37c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
from dash.dependencies import Input, Output | |
import plotly.plotly as py | |
import plotly.graph_objs as go | |
from flask import Flask | |
import random | |
import datetime | |
import time | |
external_css = ["https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css", | |
"https://fonts.googleapis.com/css?family=Raleway:400,400i,700,700i", | |
"https://fonts.googleapis.com/css?family=Product+Sans:400,400i,700,700i"] | |
app = dash.Dash(__name__, external_stylesheets=external_css) | |
app.config['suppress_callback_exceptions']=True | |
app.layout = html.Div([ | |
html.Div([ | |
html.H2("pneumo"), | |
], className='banner'), | |
html.Div([ | |
html.Div([ | |
html.H3("BP") | |
], className='Title'), | |
html.Div([ | |
dcc.Graph(id='resp-rate-graph'), | |
], className='twelve columns wind-speed'), | |
dcc.Interval(id='resp-rate-graph-update', interval=10, n_intervals=0), | |
], className='row wind-speed-row') | |
], style={'padding': '0px 10px 15px 10px', | |
'marginLeft': 'auto', 'marginRight': 'auto', "width": "900px", | |
'boxShadow': '0px 0px 5px 5px rgba(204,204,204,0.4)'}) | |
global pveco | |
pveco = [2,4,20,200,5,4,300] | |
@app.callback(Output('resp-rate-graph', 'figure'), | |
[Input('resp-rate-graph-update', 'n_intervals')]) | |
def mock_gen(n): | |
#pveco = [2,4,20,200,5,4,300] | |
global pveco | |
pveco.append(random.randint(0, 500)) | |
pveco = pveco[-200:] | |
#print (pveco) | |
trace = go.Scatter( | |
y=pveco, | |
line=go.scatter.Line( | |
color='#42C4F7' | |
), | |
hoverinfo='skip', | |
mode='lines' | |
) | |
layout = go.Layout( | |
height=400, | |
xaxis=dict( | |
range=[0, 60], | |
showgrid=False, | |
showline=True, | |
zeroline=False, | |
fixedrange=False, | |
tickvals=[0, 15, 30, 45, 60], | |
ticktext=['200', '150', '100', '50', '0'], | |
title='Time Elapsed (sec)', | |
autorange=True | |
), | |
yaxis=dict( | |
range=[0, 500], | |
showline=True, | |
fixedrange=True, | |
zeroline=False, | |
nticks=2 | |
), | |
margin=go.layout.Margin( | |
t=45, | |
l=50, | |
r=50 | |
) | |
) | |
return go.Figure(data=[trace], layout=layout) | |
server = app.server | |
if __name__ == "__main__": | |
#app.run_server(debug=True) | |
app.run_server() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment