Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -103,54 +103,30 @@ if 'key0' in st.session_state:
|
|
103 |
|
104 |
if topic == 'Vulnerability':
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
hover_name="Count",
|
129 |
-
# color_discrete_sequence=px.colors.qualitative.Plotly
|
130 |
-
)
|
131 |
-
|
132 |
-
#Show plot
|
133 |
-
st.plotly_chart(fig, use_container_width=True)
|
134 |
-
|
135 |
-
|
136 |
-
# Bar cart
|
137 |
-
with col2:
|
138 |
-
|
139 |
-
# Configure graph
|
140 |
-
fig = px.pie(df_labels,
|
141 |
-
names="Label",
|
142 |
-
values="Count",
|
143 |
-
# color='Country',
|
144 |
-
title='Label Counts',
|
145 |
-
hover_name="Count",
|
146 |
-
# color_discrete_sequence=px.colors.qualitative.Plotly
|
147 |
-
)
|
148 |
-
|
149 |
-
#Show plot
|
150 |
-
st.plotly_chart(fig, use_container_width=True)
|
151 |
-
|
152 |
|
153 |
-
|
154 |
st.table(st.session_state['key0'])
|
155 |
|
156 |
# vulnerability_analysis.vulnerability_display()
|
|
|
103 |
|
104 |
if topic == 'Vulnerability':
|
105 |
|
106 |
+
### Pie chart
|
107 |
+
|
108 |
+
# Create a df that stores all the labels
|
109 |
+
df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
110 |
+
|
111 |
+
# Count how often each label appears in the "Vulnerability Labels" column
|
112 |
+
label_counts = st.session_state['key0']['Vulnerability Label'].value_counts().reset_index()
|
113 |
+
label_counts.columns = ['Label', 'Count']
|
114 |
+
|
115 |
+
# Merge the label counts with the df_label DataFrame
|
116 |
+
df_labels = df_labels.merge(label_counts, on='Label', how='left')
|
117 |
+
|
118 |
+
# Configure graph
|
119 |
+
fig = px.pie(df_labels,
|
120 |
+
names="Label",
|
121 |
+
values="Count",
|
122 |
+
title='Label Counts',
|
123 |
+
hover_name="Count",
|
124 |
+
color_discrete_sequence=px.colors.qualitative.Plotly
|
125 |
+
|
126 |
+
#Show plot
|
127 |
+
st.plotly_chart(fig, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
+
### Table
|
130 |
st.table(st.session_state['key0'])
|
131 |
|
132 |
# vulnerability_analysis.vulnerability_display()
|