prakharg24 commited on
Commit
67606c8
·
verified ·
1 Parent(s): 85dcbdf

Create multiverse.py

Browse files
Files changed (1) hide show
  1. my_pages/multiverse.py +66 -0
my_pages/multiverse.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import plotly.graph_objects as go
3
+ from utils import development_stages
4
+
5
+ def render():
6
+ st.title("Multiverse of Developer Decisions")
7
+
8
+ # Generate placeholder options for each stage
9
+ stage_options = {}
10
+ for stage in development_stages:
11
+ stage_options[stage] = [f"{stage} Option {i}" for i in range(1, 4)]
12
+
13
+ # User selects one option for each stage
14
+ selected_path = []
15
+ st.subheader("Choose your path")
16
+ for stage, options in stage_options.items():
17
+ choice = st.selectbox(f"{stage}:", options, key=stage)
18
+ selected_path.append(choice)
19
+
20
+ # Create Sankey diagram data
21
+ labels = []
22
+ for stage in development_stages:
23
+ labels.extend(stage_options[stage])
24
+
25
+ # Create links between every option in one stage to all options in the next
26
+ source = []
27
+ target = []
28
+ value = []
29
+ colors = []
30
+
31
+ for i in range(len(development_stages) - 1):
32
+ start_idx = i * 3
33
+ end_idx = (i + 1) * 3
34
+ next_start_idx = (i + 1) * 3
35
+
36
+ for s in range(start_idx, start_idx + 3):
37
+ for t in range(next_start_idx, next_start_idx + 3):
38
+ source.append(s)
39
+ target.append(t)
40
+ value.append(1) # constant flow thickness
41
+
42
+ # Highlight if both source and target are in selected path
43
+ if labels[s] == selected_path[i] and labels[t] == selected_path[i+1]:
44
+ colors.append("rgba(0, 150, 0, 0.8)")
45
+ else:
46
+ colors.append("rgba(200, 200, 200, 0.3)")
47
+
48
+ # Create Sankey diagram
49
+ fig = go.Figure(data=[go.Sankey(
50
+ arrangement="snap",
51
+ node=dict(
52
+ pad=15,
53
+ thickness=20,
54
+ line=dict(color="black", width=0.5),
55
+ label=labels,
56
+ color="rgba(100, 100, 200, 0.8)"
57
+ ),
58
+ link=dict(
59
+ source=source,
60
+ target=target,
61
+ value=value,
62
+ color=colors
63
+ )
64
+ )])
65
+
66
+ st.plotly_chart(fig, use_container_width=True)