|
import streamlit as st |
|
import st_hc as hct |
|
import download_chart as dc |
|
from export_doc import convert_pp_to_csv |
|
|
|
|
|
|
|
|
|
cd2 = { |
|
"chart":{ |
|
"animation":False |
|
}, |
|
"title":{ |
|
"text":"Cartographie des parties prenantes" |
|
}, |
|
"tooltip":{ |
|
"valueDecimals":0 |
|
}, |
|
"xAxis":{ |
|
"title":{ |
|
"text":"Influence" |
|
}, |
|
"min":0, |
|
"max":100, |
|
"plotLines":[ |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":50, |
|
"label":{ |
|
"rotation":0, |
|
"y":290, |
|
"style":{ |
|
"color":"blue", |
|
"font-size": "20px" |
|
}, |
|
"text":"Tenir informé", |
|
}, |
|
"zIndex":3 |
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":50, |
|
"label":{ |
|
"rotation":0, |
|
"y":25, |
|
"style":{ |
|
"color":"orange", |
|
"font-size": "20px" |
|
}, |
|
"text":"Gérer étroitement", |
|
}, |
|
"zIndex":3 |
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":0, |
|
"label":{ |
|
"rotation":0, |
|
"y":25, |
|
"style":{ |
|
"color":"green", |
|
"font-size": "20px" |
|
}, |
|
"text":"Rendre satisfait", |
|
}, |
|
"zIndex":3 |
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":0, |
|
"label":{ |
|
"rotation":0, |
|
"y":290, |
|
"style":{ |
|
"color":"red", |
|
"font-size": "20px" |
|
}, |
|
"text":"Suivre de près", |
|
}, |
|
"zIndex":3 |
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":100, |
|
"zIndex":3 |
|
|
|
} |
|
] |
|
}, |
|
"yAxis":{ |
|
"title":{ |
|
"text":"Pouvoir" |
|
}, |
|
"min":0, |
|
"max":100, |
|
"plotLines":[ |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":50, |
|
"zIndex":3 |
|
|
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":100, |
|
"zIndex":3 |
|
}, |
|
{ |
|
"color":"gray", |
|
"dashStyle":"LongDash", |
|
"width":1, |
|
"value":0, |
|
"zIndex":3 |
|
} |
|
], |
|
}, |
|
"tooltip":{ |
|
"headerFormat":"", |
|
"pointFormat":"{point.name}", |
|
"valueDecimals":0 |
|
}, |
|
"series":[ |
|
{ |
|
"type":"bubble", |
|
"maxSize":50, |
|
"cursor":"move", |
|
"name":"Influence", |
|
"pointformat":"{point.name}", |
|
"dragDrop":{ |
|
"draggableX":True, |
|
"draggableY":True, |
|
"dragMinY":0, |
|
"dragMaxY":100, |
|
"dragMinX":0, |
|
"dragMaxX":100, |
|
"dragPrecisionX":1, |
|
"dragPrecisionY":1, |
|
"dragSensitivity":0 |
|
}, |
|
"data":[], |
|
"colorByPoint":True, |
|
|
|
} |
|
], |
|
"exporting": { |
|
"enabled": True |
|
|
|
}, |
|
"legend":{ |
|
"enabled":False |
|
} |
|
} |
|
|
|
|
|
def construct_data(): |
|
data = [] |
|
for i in range(10): |
|
object = { |
|
"x": 50+i*5, |
|
"y": 50, |
|
"name": f"Point{i}", |
|
|
|
} |
|
data.append(object) |
|
|
|
return data |
|
|
|
|
|
|
|
|
|
def test_chart(): |
|
|
|
if "pp_grouped" not in st.session_state or len(st.session_state['pp_grouped']) == 0: |
|
return None |
|
|
|
points = st.session_state['pp_grouped'] |
|
cd2["series"][0]["data"] = points |
|
chart = hct.streamlit_highcharts(cd2,640) |
|
|
|
|
|
|
|
col0, col1, col2, col3 = st.columns([1,1,1,1]) |
|
|
|
if col1.button("Sauvegarder",key="save"): |
|
st.session_state['pp_grouped'] = chart.copy() |
|
st.experimental_rerun() |
|
|
|
if col2.button("Télécharger",key="download"): |
|
if not chart: |
|
st.error("Un truc ne va pas. Veuillez réessayer") |
|
else: |
|
st.session_state['pp_grouped'] = chart.copy() |
|
fig = dc.construct_plot() |
|
st.plotly_chart(fig) |
|
|