-
Notifications
You must be signed in to change notification settings - Fork 0
/
fulldb.py
85 lines (71 loc) · 2.87 KB
/
fulldb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import numpy as np
# Sample data
equipment_data = pd.DataFrame({
'Equipment': ['Machine A', 'Machine B', 'Machine C', 'Machine D'],
'Temperature': np.random.uniform(60, 100, 4),
'Vibration': np.random.uniform(0, 5, 4),
'Pressure': np.random.uniform(10, 50, 4),
'Status': ['Operational', 'Maintenance', 'Operational', 'Maintenance']
})
# Create the Dash application
app = dash.Dash(__name__)
# Define the layout of the dashboard
app.layout = html.Div([
html.Div([
html.Div([
html.H1("Tableau de Bord de Maintenance Prédictive d'Équipements Industriels", className="header-title"),
dcc.Dropdown(
id='equipment-dropdown',
options=[{'label': equip, 'value': equip} for equip in equipment_data['Equipment']],
value=equipment_data['Equipment'][0],
className="dropdown"
),
], className="header"),
dcc.Graph(id='temperature-vibration', className="graph"),
], className="content-container"),
html.Div([
dcc.Graph(id='pressure-graph', className="graph"),
], className="content-container"),
html.Div(id='equipment-status', className="status"),
], className="dashboard-container")
# Define callback to update graphs and status based on equipment selection
@app.callback(
[Output('temperature-vibration', 'figure'),
Output('pressure-graph', 'figure'),
Output('equipment-status', 'children')],
[Input('equipment-dropdown', 'value')]
)
def update_graphs(selected_equipment):
equipment = equipment_data[equipment_data['Equipment'] == selected_equipment]
temperature_vibration_fig = {
'data': [
{'x': ['Température', 'Vibration'], 'y': [equipment['Temperature'].values[0], equipment['Vibration'].values[0]], 'type': 'bar', 'name': selected_equipment},
],
'layout': {
'title': 'Température et Vibration',
'yaxis': {'title': 'Valeur'},
}
}
pressure_fig = {
'data': [
{'x': ['Pression'], 'y': [equipment['Pressure'].values[0]], 'type': 'bar', 'name': selected_equipment},
],
'layout': {
'title': 'Pression',
'yaxis': {'title': 'Valeur'},
}
}
equipment_status = f"Équipement: {selected_equipment}, État: {equipment['Status'].values[0]}"
return temperature_vibration_fig, pressure_fig, equipment_status
# Add CSS to style the dashboard (you can create a separate CSS file for better organization)
app.css.append_css({
'external_url': 'https://raw.githubusercontent.com/your-username/your-repo/master/your-styles.css'
})
# Run the app
if __name__ == '__main__':
app.run_server(debug=True)