File size: 4,333 Bytes
19341ef
 
 
d486d32
19341ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8df1e9f
 
19341ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439e01f
19341ef
439e01f
19341ef
 
 
 
 
f484ffe
c673bf2
19341ef
fda58da
19341ef
c673bf2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import streamlit as st
import st_hc as hct
import download_chart as dc
from export_doc import convert_pp_to_csv



# Define the highchart definition
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():
   #The component can render any highchart definition
   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) #640 is the chart height
   # if chart:
   #    st.session_state['pp_grouped'] = chart

   col0,col1,col2 = st.columns([1,1,1])

   if col1.button("Sauvegarder",key="save"):
      st.session_state['pp_grouped'] = chart.copy()
      return "saved"