Update my_pages/multiverse.py
Browse files- my_pages/multiverse.py +21 -19
my_pages/multiverse.py
CHANGED
|
@@ -5,41 +5,43 @@ from utils import development_stages
|
|
| 5 |
def render():
|
| 6 |
st.title("Multiverse of Developer Decisions")
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
for stage in development_stages:
|
| 11 |
-
stage_options[stage] = [f"{stage} Option {i}" for i in range(1, 4)]
|
| 12 |
|
| 13 |
-
#
|
|
|
|
|
|
|
|
|
|
| 14 |
selected_path = []
|
| 15 |
st.subheader("Choose your path")
|
| 16 |
-
for
|
| 17 |
-
choice = st.selectbox(f"{
|
| 18 |
selected_path.append(choice)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
labels = []
|
| 22 |
-
for
|
| 23 |
-
labels.extend(stage_options[
|
| 24 |
|
| 25 |
-
# Create links between
|
| 26 |
source = []
|
| 27 |
target = []
|
| 28 |
value = []
|
| 29 |
colors = []
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
-
for s in range(start_idx, start_idx +
|
| 37 |
-
for t in range(next_start_idx, next_start_idx +
|
| 38 |
source.append(s)
|
| 39 |
target.append(t)
|
| 40 |
-
value.append(1) # constant
|
| 41 |
|
| 42 |
-
# Highlight
|
| 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:
|
|
|
|
| 5 |
def render():
|
| 6 |
st.title("Multiverse of Developer Decisions")
|
| 7 |
|
| 8 |
+
# Extract stage labels
|
| 9 |
+
stage_labels = [stage["label"] for stage in development_stages]
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Generate options from each stage's questions
|
| 12 |
+
stage_options = {stage["label"]: stage["questions"] for stage in development_stages}
|
| 13 |
+
|
| 14 |
+
# Let user pick one option from each stage
|
| 15 |
selected_path = []
|
| 16 |
st.subheader("Choose your path")
|
| 17 |
+
for stage_label, options in stage_options.items():
|
| 18 |
+
choice = st.selectbox(f"{stage_label}:", options, key=stage_label)
|
| 19 |
selected_path.append(choice)
|
| 20 |
|
| 21 |
+
# Prepare Sankey diagram labels
|
| 22 |
labels = []
|
| 23 |
+
for stage_label in stage_labels:
|
| 24 |
+
labels.extend(stage_options[stage_label])
|
| 25 |
|
| 26 |
+
# Create links between options in consecutive stages
|
| 27 |
source = []
|
| 28 |
target = []
|
| 29 |
value = []
|
| 30 |
colors = []
|
| 31 |
|
| 32 |
+
options_per_stage = [stage_options[stage] for stage in stage_labels]
|
| 33 |
+
|
| 34 |
+
for i in range(len(stage_labels) - 1):
|
| 35 |
+
start_idx = sum(len(opts) for opts in options_per_stage[:i])
|
| 36 |
+
next_start_idx = sum(len(opts) for opts in options_per_stage[:i+1])
|
| 37 |
|
| 38 |
+
for s in range(start_idx, start_idx + len(options_per_stage[i])):
|
| 39 |
+
for t in range(next_start_idx, next_start_idx + len(options_per_stage[i+1])):
|
| 40 |
source.append(s)
|
| 41 |
target.append(t)
|
| 42 |
+
value.append(1) # constant thickness for now
|
| 43 |
|
| 44 |
+
# Highlight chosen path
|
| 45 |
if labels[s] == selected_path[i] and labels[t] == selected_path[i+1]:
|
| 46 |
colors.append("rgba(0, 150, 0, 0.8)")
|
| 47 |
else:
|