Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -30,51 +30,90 @@ def get_states(bounds=None):
|
|
30 |
def create_monitoring_dashboard(states):
|
31 |
"""Create monitoring dashboard using Plotly"""
|
32 |
if not states:
|
33 |
-
return go.Figure()
|
34 |
|
35 |
-
# Create subplots
|
36 |
fig = make_subplots(
|
37 |
rows=2, cols=2,
|
38 |
subplot_titles=('Altitude Distribution', 'Speed Distribution',
|
39 |
-
'Aircraft by Country', 'Aircraft Categories')
|
|
|
|
|
|
|
|
|
40 |
)
|
41 |
|
42 |
# Altitude distribution
|
43 |
altitudes = [state[7] for state in states if state[7]]
|
44 |
fig.add_trace(
|
45 |
-
go.Histogram(
|
|
|
|
|
|
|
|
|
46 |
row=1, col=1
|
47 |
)
|
48 |
|
49 |
# Speed distribution
|
50 |
speeds = [state[9] for state in states if state[9]]
|
51 |
fig.add_trace(
|
52 |
-
go.Histogram(
|
|
|
|
|
|
|
|
|
53 |
row=1, col=2
|
54 |
)
|
55 |
|
56 |
# Aircraft by country
|
57 |
countries = pd.Series([state[2] for state in states if state[2]]).value_counts()
|
58 |
fig.add_trace(
|
59 |
-
go.Bar(
|
|
|
|
|
|
|
|
|
|
|
60 |
row=2, col=1
|
61 |
)
|
62 |
|
63 |
-
# Aircraft categories
|
|
|
|
|
64 |
fig.add_trace(
|
65 |
-
go.Pie(
|
66 |
-
|
|
|
|
|
|
|
|
|
67 |
row=2, col=2
|
68 |
)
|
69 |
|
|
|
70 |
fig.update_layout(
|
71 |
-
height=
|
72 |
-
showlegend=
|
73 |
template="plotly_dark",
|
74 |
-
paper_bgcolor='rgba(0,0,0,0)',
|
75 |
-
plot_bgcolor='rgba(0,0,0,0)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
)
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
return fig
|
79 |
|
80 |
def create_map(region="world"):
|
|
|
30 |
def create_monitoring_dashboard(states):
|
31 |
"""Create monitoring dashboard using Plotly"""
|
32 |
if not states:
|
33 |
+
return go.Figure()
|
34 |
|
35 |
+
# Create subplots with specific types
|
36 |
fig = make_subplots(
|
37 |
rows=2, cols=2,
|
38 |
subplot_titles=('Altitude Distribution', 'Speed Distribution',
|
39 |
+
'Aircraft by Country', 'Aircraft Categories'),
|
40 |
+
specs=[
|
41 |
+
[{"type": "xy"}, {"type": "xy"}],
|
42 |
+
[{"type": "xy"}, {"type": "domain"}] # pie chart를 위한 domain type
|
43 |
+
]
|
44 |
)
|
45 |
|
46 |
# Altitude distribution
|
47 |
altitudes = [state[7] for state in states if state[7]]
|
48 |
fig.add_trace(
|
49 |
+
go.Histogram(
|
50 |
+
x=altitudes,
|
51 |
+
name="Altitude",
|
52 |
+
marker_color='#4a90e2'
|
53 |
+
),
|
54 |
row=1, col=1
|
55 |
)
|
56 |
|
57 |
# Speed distribution
|
58 |
speeds = [state[9] for state in states if state[9]]
|
59 |
fig.add_trace(
|
60 |
+
go.Histogram(
|
61 |
+
x=speeds,
|
62 |
+
name="Speed",
|
63 |
+
marker_color='#50C878'
|
64 |
+
),
|
65 |
row=1, col=2
|
66 |
)
|
67 |
|
68 |
# Aircraft by country
|
69 |
countries = pd.Series([state[2] for state in states if state[2]]).value_counts()
|
70 |
fig.add_trace(
|
71 |
+
go.Bar(
|
72 |
+
x=countries.index[:10],
|
73 |
+
y=countries.values[:10],
|
74 |
+
name="Countries",
|
75 |
+
marker_color='#FF6B6B'
|
76 |
+
),
|
77 |
row=2, col=1
|
78 |
)
|
79 |
|
80 |
+
# Aircraft categories
|
81 |
+
categories = ['Commercial', 'Private', 'Military', 'Other']
|
82 |
+
values = [40, 30, 20, 10] # Example distribution
|
83 |
fig.add_trace(
|
84 |
+
go.Pie(
|
85 |
+
labels=categories,
|
86 |
+
values=values,
|
87 |
+
name="Categories",
|
88 |
+
marker=dict(colors=['#4a90e2', '#50C878', '#FF6B6B', '#FFD700'])
|
89 |
+
),
|
90 |
row=2, col=2
|
91 |
)
|
92 |
|
93 |
+
# Update layout
|
94 |
fig.update_layout(
|
95 |
+
height=800,
|
96 |
+
showlegend=True,
|
97 |
template="plotly_dark",
|
98 |
+
paper_bgcolor='rgba(0,0,0,0.3)',
|
99 |
+
plot_bgcolor='rgba(0,0,0,0.1)',
|
100 |
+
margin=dict(l=50, r=50, t=50, b=50),
|
101 |
+
font=dict(color='white'),
|
102 |
+
legend=dict(
|
103 |
+
bgcolor='rgba(0,0,0,0.3)',
|
104 |
+
bordercolor='rgba(255,255,255,0.2)',
|
105 |
+
borderwidth=1
|
106 |
+
)
|
107 |
)
|
108 |
|
109 |
+
# Update axes
|
110 |
+
fig.update_xaxes(gridcolor='rgba(255,255,255,0.1)', zeroline=False)
|
111 |
+
fig.update_yaxes(gridcolor='rgba(255,255,255,0.1)', zeroline=False)
|
112 |
+
|
113 |
+
# Update subplot titles
|
114 |
+
for i in fig['layout']['annotations']:
|
115 |
+
i['font'] = dict(size=12, color='white')
|
116 |
+
|
117 |
return fig
|
118 |
|
119 |
def create_map(region="world"):
|