Spaces:
Running
Running
benediktstroebl
commited on
Commit
·
a30f956
1
Parent(s):
ad4ec76
added legend visibility dashboard
Browse files
utils.py
CHANGED
@@ -177,6 +177,7 @@ def create_flow_chart(steps):
|
|
177 |
mode='markers+text',
|
178 |
text=node_text,
|
179 |
textposition="top center",
|
|
|
180 |
hovertext=hover_text,
|
181 |
hoverinfo='text',
|
182 |
hoverlabel=dict(bgcolor="white", font_size=12, font_family="Arial"),
|
@@ -191,10 +192,37 @@ def create_flow_chart(steps):
|
|
191 |
x=edge_x, y=edge_y,
|
192 |
line=dict(width=2, color='#888'),
|
193 |
hoverinfo='none',
|
|
|
194 |
mode='lines')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
layout = go.Layout(
|
197 |
-
showlegend=
|
198 |
hovermode='closest',
|
199 |
margin=dict(b=20,l=5,r=5,t=40),
|
200 |
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
@@ -206,27 +234,20 @@ def create_flow_chart(steps):
|
|
206 |
orientation='h', # Vertical orientation
|
207 |
bgcolor='rgba(255,255,255,0.8)', # Slightly transparent white background
|
208 |
color='#777', # Color of inactive tools
|
209 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
)
|
211 |
|
212 |
-
fig = go.Figure(data=
|
213 |
-
|
214 |
-
# Add a legend for colors and shapes
|
215 |
-
for success, color in color_map.items():
|
216 |
-
fig.add_trace(go.Scatter(
|
217 |
-
x=[None], y=[None], mode='markers',
|
218 |
-
marker=dict(size=10, color=color),
|
219 |
-
showlegend=True,
|
220 |
-
name=f"{'Success' if success else 'Challenge'}"
|
221 |
-
))
|
222 |
-
|
223 |
-
for action, shape in shape_map.items():
|
224 |
-
fig.add_trace(go.Scatter(
|
225 |
-
x=[None], y=[None], mode='markers',
|
226 |
-
marker=dict(size=10, symbol=shape, color='gray'),
|
227 |
-
showlegend=True,
|
228 |
-
name=f"Action: {action.capitalize()}"
|
229 |
-
))
|
230 |
|
231 |
fig.update_layout(legend=dict(
|
232 |
orientation="h",
|
|
|
177 |
mode='markers+text',
|
178 |
text=node_text,
|
179 |
textposition="top center",
|
180 |
+
showlegend=False,
|
181 |
hovertext=hover_text,
|
182 |
hoverinfo='text',
|
183 |
hoverlabel=dict(bgcolor="white", font_size=12, font_family="Arial"),
|
|
|
192 |
x=edge_x, y=edge_y,
|
193 |
line=dict(width=2, color='#888'),
|
194 |
hoverinfo='none',
|
195 |
+
showlegend=False,
|
196 |
mode='lines')
|
197 |
+
|
198 |
+
# Create legend traces
|
199 |
+
legend_traces = []
|
200 |
+
|
201 |
+
# Color legend
|
202 |
+
for success, color in color_map.items():
|
203 |
+
legend_traces.append(go.Scatter(
|
204 |
+
x=[None], y=[None],
|
205 |
+
mode='markers',
|
206 |
+
marker=dict(size=10, color=color),
|
207 |
+
showlegend=True,
|
208 |
+
name=f"{'Success' if success else 'Issue'}"
|
209 |
+
))
|
210 |
+
|
211 |
+
# Shape legend
|
212 |
+
for action, shape in shape_map.items():
|
213 |
+
legend_traces.append(go.Scatter(
|
214 |
+
x=[None], y=[None],
|
215 |
+
mode='markers',
|
216 |
+
marker=dict(size=10, symbol=shape, color='gray'),
|
217 |
+
showlegend=True,
|
218 |
+
name=f"{action.capitalize()}"
|
219 |
+
))
|
220 |
+
|
221 |
+
# Combine all traces
|
222 |
+
all_traces = [edge_trace, node_trace] + legend_traces
|
223 |
|
224 |
layout = go.Layout(
|
225 |
+
showlegend=True,
|
226 |
hovermode='closest',
|
227 |
margin=dict(b=20,l=5,r=5,t=40),
|
228 |
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
|
|
234 |
orientation='h', # Vertical orientation
|
235 |
bgcolor='rgba(255,255,255,0.8)', # Slightly transparent white background
|
236 |
color='#777', # Color of inactive tools
|
237 |
+
),
|
238 |
+
legend=dict(
|
239 |
+
orientation="h",
|
240 |
+
yanchor="bottom",
|
241 |
+
y=0.02,
|
242 |
+
xanchor="right",
|
243 |
+
x=1,
|
244 |
+
bgcolor='rgba(255,255,255,0.8)',
|
245 |
+
bordercolor='rgba(0,0,0,0.1)',
|
246 |
+
borderwidth=1
|
247 |
+
),
|
248 |
)
|
249 |
|
250 |
+
fig = go.Figure(data=all_traces, layout=layout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
fig.update_layout(legend=dict(
|
253 |
orientation="h",
|