homecontrol-dash: minor changes, update name, some formatting
This commit is contained in:
		
							parent
							
								
									91b4debe09
								
							
						
					
					
						commit
						4b7f2662b8
					
				
					 1 changed files with 8 additions and 8 deletions
				
			
		| 
						 | 
					@ -12,16 +12,17 @@ x = [1]
 | 
				
			||||||
y = [2]
 | 
					y = [2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
 | 
					external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
 | 
				
			||||||
 | 
					meta_tags=[{"name": "viewport", "content": "width=device-width, initial-scale=1"}]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
 | 
					app = dash.Dash(__name__, external_stylesheets=external_stylesheets, meta_tags=meta_tags)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
available_sensors = ["undefined"]
 | 
					available_sensors = ["undefined"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.layout = html.Div(children=[
 | 
					app.layout = html.Div(children=[
 | 
				
			||||||
    html.H1(children='homecontrol-dash'),
 | 
					    html.H1(children='dashboard.ykonni.de'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    html.Div(children='''
 | 
					    html.Div(children='''
 | 
				
			||||||
        homecontrol-dash: visualize data
 | 
					        visualize sensor data
 | 
				
			||||||
    '''),
 | 
					    '''),
 | 
				
			||||||
    dcc.Graph(
 | 
					    dcc.Graph(
 | 
				
			||||||
        id='example-graph',
 | 
					        id='example-graph',
 | 
				
			||||||
| 
						 | 
					@ -66,7 +67,7 @@ def update_graph(n_clicks, sensorId):
 | 
				
			||||||
        content = res.json()
 | 
					        content = res.json()
 | 
				
			||||||
        v = content[sensorId]["values"]
 | 
					        v = content[sensorId]["values"]
 | 
				
			||||||
        sensorType = content[sensorId]["sensorType"]
 | 
					        sensorType = content[sensorId]["sensorType"]
 | 
				
			||||||
        x = [time.strftime("%m%d-%H%M%S", time.localtime(float(v[i]["ts"]))) for i in range(len(v))]
 | 
					        x = [time.strftime("%m%d-%H%M", time.localtime(float(v[i]["ts"]))) for i in range(len(v))]
 | 
				
			||||||
        y = [v[i]["value"] for i in range(len(v))]
 | 
					        y = [v[i]["value"] for i in range(len(v))]
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        sensorType = sensorId
 | 
					        sensorType = sensorId
 | 
				
			||||||
| 
						 | 
					@ -75,15 +76,14 @@ def update_graph(n_clicks, sensorId):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        'data': [
 | 
					        'data': [
 | 
				
			||||||
            {'x': x, 'y': y, 'mode': 'markers', 'name': "%s (%s)" % (sensorType,
 | 
					            {'x': x, 'y': y, 'mode': 'markers', 'name': "%s" % (sensorType)}
 | 
				
			||||||
                sensorId)}
 | 
					 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
        'layout': {
 | 
					        'layout': {
 | 
				
			||||||
            'title': 'Data for sensor: %s (%s)' % (sensorType, sensorId)
 | 
					            'title': 'Data for sensor: %s' % (sensorType)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    app.run_server(debug=True)
 | 
					    app.run_server(port=8081,debug=True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue