Repository navigation
Expand file tree
/
Copy pathdashboard.py
More file actions
114 lines (98 loc) · 3.79 KB
/
Copy pathdashboard.py
File metadata and controls
114 lines (98 loc) · 3.79 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import dash
from dash import dcc, html, Output, Input
import plotly.io as pio
# Initialize the Dash app
app = dash.Dash(__name__)
# Load Goanna Test Flight Figures from JSON files
goanna_velocity_fig = pio.read_json("DashboardGraphs/goanna_velocity_fig.json")
goanna_acceleration_fig = pio.read_json("DashboardGraphs/goanna_acceleration_fig.json")
goanna_altitude_fig = pio.read_json("DashboardGraphs/goanna_altitude_fig.json")
goanna_3d_flight_fig = pio.read_json("DashboardGraphs/goanna_3d_flight_fig.json")
# Load Mullaley Test Flight Figures from JSON files
mullaley_velocity_fig = pio.read_json("DashboardGraphs/mullaley_velocity_fig.json")
mullaley_acceleration_fig = pio.read_json("DashboardGraphs/mullaley_acceleration_fig.json")
mullaley_altitude_fig = pio.read_json("DashboardGraphs/mullaley_altitude_fig.json")
mullaley_3d_flight_fig = pio.read_json("DashboardGraphs/mullaley_3d_flight_fig.json")
# Mapping each test flight to its corresponding figures
figures = {
"goanna": {
"velocity": goanna_velocity_fig,
"acceleration": goanna_acceleration_fig,
"altitude": goanna_altitude_fig,
"3d_flight": goanna_3d_flight_fig,
},
"mullaley": {
"velocity": mullaley_velocity_fig,
"acceleration": mullaley_acceleration_fig,
"altitude": mullaley_altitude_fig,
"3d_flight": mullaley_3d_flight_fig,
}
}
# Adjust figure layout
def update_figure_layout(fig):
fig.update_layout(
autosize=True,
margin=dict(l=30, r=20, t=40, b=20),
height = 150
)
return fig
# APP LAYOUT
app.layout = html.Div([
# html.H1("UTS Rocketry Flight Path Analysis Dashboard", className="header"),
html.Div([
html.Img(src='/assets/Rocketry_Logo.png', className="logo"),
html.H1("UTS Rocketry Flight Path Analysis Dashboard", className="header")
], className="header-container"),
# Dropdown for selecting the test flight
html.Div([
html.Label("Select Test Flight:", className="dropdown-label"),
dcc.Dropdown(
id='flight-dropdown',
options=[
{'label': 'Goanna Test Flight', 'value': 'goanna'},
{'label': 'Mullaley Test Flight', 'value': 'mullaley'}
],
value='goanna',
className="dropdown"
)
], className="dropdown-container"),
# Graph containers
html.Div([
html.Div([
html.H3("Velocity over Time", className="graph-title"),
dcc.Graph(id='velocity-graph')
], className="graph-container"),
html.Div([
html.H3("Acceleration over Time", className="graph-title"),
dcc.Graph(id='acceleration-graph')
], className="graph-container"),
], className="graph-row"),
html.Div([
html.Div([
html.H3("Altitude over Time", className="graph-title"),
dcc.Graph(id='altitude-graph')
], className="graph-container"),
html.Div([
html.H3("3D Flight Path", className="graph-title"),
dcc.Graph(id='flight-3d-graph')
], className="graph-container"),
], className="graph-row"),
])
# Update graphs based on dropdown selection
@app.callback(
[Output('velocity-graph', 'figure'),
Output('acceleration-graph', 'figure'),
Output('altitude-graph', 'figure'),
Output('flight-3d-graph', 'figure')],
[Input('flight-dropdown', 'value')]
)
def update_graphs(selected_flight):
# Retrieve the relevant figures based on the selected flight
selected_figures = figures[selected_flight]
return (selected_figures['velocity'],
selected_figures['acceleration'],
selected_figures['altitude'],
selected_figures['3d_flight'])
# Run the Dash app
if __name__ == '__main__':
app.run_server(debug=True)