|
import streamlit as st |
|
import pandas as pd |
|
import numpy as np |
|
import re |
|
|
|
import altair as alt |
|
from session import get_partie_prenante |
|
import os |
|
from streamlit_vertical_slider import vertical_slider |
|
|
|
def display_viz(): |
|
st.header("") |
|
st.title("Visualisation des parties prenantes") |
|
|
|
partie_prenante = get_partie_prenante() |
|
|
|
if partie_prenante is None: |
|
st.write("Veuillez entrer l'url dans l'onglet partie prenante avant de visualiser les parties prenantes") |
|
else: |
|
alphabet = [ pp[0] for pp in partie_prenante] |
|
pouvoir = [ 50 for _ in range(len(partie_prenante))] |
|
df = pd.DataFrame({'partie_prenante': partie_prenante, 'pouvoir': pouvoir, 'code couleur': partie_prenante}) |
|
c = ( |
|
alt.Chart(df) |
|
.mark_circle(size=300) |
|
.encode(x="partie_prenante", y=alt.Y("pouvoir",scale=alt.Scale(domain=[0,100])), color="code couleur",legend=None) |
|
) |
|
|
|
number_of_sliders = len(partie_prenante) |
|
st.write("Modifiez le pouvoir des parties prenantes en utilisant les sliders ci-dessous") |
|
bar = st.columns(number_of_sliders) |
|
for i in range(number_of_sliders): |
|
with bar[i]: |
|
df["pouvoir"][i] = vertical_slider( |
|
label=partie_prenante[i], |
|
height=100, |
|
key=partie_prenante[i], |
|
default_value=50, |
|
thumb_color= "orange", |
|
step=1, |
|
min_value=0, |
|
max_value=100, |
|
value_always_visible=False, |
|
) |
|
st.altair_chart(c, use_container_width=True) |