Ilyas KHIAT commited on
Commit
19341ef
1 Parent(s): cea395e

AXE DES INFLUENCE ET CARTE SUR LE CHATBOT

Browse files
app.py CHANGED
@@ -21,6 +21,7 @@ from documentations import display_documentation
21
  from RAG_PDF_WEB import rag_pdf_web
22
  from prompt import get_prompts_list,prompt_execution,execute_prompt
23
  from chat_with_pps import display_chat
 
24
 
25
  def main():
26
  st.markdown(":point_left: Cliquez pour vous inspirer", unsafe_allow_html=True)
@@ -71,9 +72,8 @@ def main():
71
  "Prompt RSE disponibles",
72
  "Générations de contenus RSE",
73
  "Parties prenantes",
74
- "Cartographie",
75
  "Matrice de matérialité",
76
- "Chatbot Matrice de matérialité"
77
  ]
78
  )
79
 
@@ -83,13 +83,6 @@ def main():
83
  # if selected_company:
84
  # display_materiality_partiesprenantes(selected_company, data, bziiit_data)
85
  display_pp()
86
-
87
- elif ia_mode == "Cartographie":
88
- # data, bziiit_data = fetch_data()
89
- # selected_company = display_company_selection_for_materiality(data)
90
- # if selected_company:
91
- # display_materiality_partiesprenantes(selected_company, data, bziiit_data)
92
- display_viz()
93
 
94
  elif ia_mode == "Matrice de matérialité":
95
  data, bziiit_data = fetch_data()
@@ -97,7 +90,7 @@ def main():
97
  if selected_company:
98
  display_materiality_matrix(selected_company, data, bziiit_data)
99
 
100
- elif ia_mode == "Chatbot Matrice de matérialité":
101
  display_chat()
102
 
103
  elif ia_mode == "Audit flash RSE de vos contenus":
 
21
  from RAG_PDF_WEB import rag_pdf_web
22
  from prompt import get_prompts_list,prompt_execution,execute_prompt
23
  from chat_with_pps import display_chat
24
+ from high_chart import test_chart
25
 
26
  def main():
27
  st.markdown(":point_left: Cliquez pour vous inspirer", unsafe_allow_html=True)
 
72
  "Prompt RSE disponibles",
73
  "Générations de contenus RSE",
74
  "Parties prenantes",
 
75
  "Matrice de matérialité",
76
+ "Chatbot RSE"
77
  ]
78
  )
79
 
 
83
  # if selected_company:
84
  # display_materiality_partiesprenantes(selected_company, data, bziiit_data)
85
  display_pp()
 
 
 
 
 
 
 
86
 
87
  elif ia_mode == "Matrice de matérialité":
88
  data, bziiit_data = fetch_data()
 
90
  if selected_company:
91
  display_materiality_matrix(selected_company, data, bziiit_data)
92
 
93
+ elif ia_mode == "Chatbot RSE":
94
  display_chat()
95
 
96
  elif ia_mode == "Audit flash RSE de vos contenus":
chat_with_pps.py CHANGED
@@ -4,22 +4,24 @@ from langchain_community.chat_models import ChatOpenAI
4
  from dotenv import load_dotenv
5
  from langchain_core.output_parsers import StrOutputParser
6
  from langchain_core.prompts import ChatPromptTemplate
 
7
 
8
 
9
  load_dotenv()
10
 
11
- def format_context(df,brand_name):
12
- formatted_string = "le nom de la marque est " + brand_name + "\n" + "Les parties prenantes et leur pouvoir en pourcentage sont les suivants:\n"
13
- for index, row in df.iterrows():
14
- formatted_string += f"{row['partie_prenante']}: {row['pouvoir']}%\n"
15
- return formatted_string
 
16
 
17
 
18
 
19
  def get_response(user_query, chat_history, context):
20
 
21
  template = """
22
- Fournir des réponses précises et contextuelles en agissant comme un expert en affaires, en utilisant le contexte des parties prenantes et leur pouvoir en pourcentage pour expliquer les implications pour la marque. Le modèle doit connecter les informations du contexte et de l'historique de la conversation pour donner une réponse éclairée à la dernière question posée.
23
 
24
  Contexte: {context}
25
 
@@ -40,14 +42,21 @@ def get_response(user_query, chat_history, context):
40
  "user_question": user_query,
41
  })
42
 
 
 
 
 
 
 
 
 
43
  def display_chat():
44
  # app config
45
  st.title("Chatbot")
46
-
47
  # session state
48
  if "chat_history" not in st.session_state:
49
  st.session_state.chat_history = [
50
- AIMessage(content="Salut, pose-moi des questions sur tes parties prenantes."),
51
  ]
52
 
53
 
@@ -56,6 +65,8 @@ def display_chat():
56
  if isinstance(message, AIMessage):
57
  with st.chat_message("AI"):
58
  st.write(message.content)
 
 
59
  elif isinstance(message, HumanMessage):
60
  with st.chat_message("Moi"):
61
  st.write(message.content)
@@ -69,7 +80,8 @@ def display_chat():
69
  st.markdown(user_query)
70
 
71
  with st.chat_message("AI"):
72
- response = st.write_stream(get_response(user_query, st.session_state.chat_history,format_context(st.session_state['partie_prenante_grouped'],st.session_state['Nom de la marque'])))
73
-
 
74
 
75
  st.session_state.chat_history.append(AIMessage(content=response))
 
4
  from dotenv import load_dotenv
5
  from langchain_core.output_parsers import StrOutputParser
6
  from langchain_core.prompts import ChatPromptTemplate
7
+ from download_chart import construct_plot
8
 
9
 
10
  load_dotenv()
11
 
12
+ def format_context(partie_prenante_grouped,marque):
13
+ context = ""
14
+ for partie_prenante in partie_prenante_grouped:
15
+ context += f"{partie_prenante['name']} est une partie prenante de {marque} et a un pouvoir de {partie_prenante['y']}% et une influence de {partie_prenante['x']}%.\n"
16
+ return context
17
+
18
 
19
 
20
 
21
  def get_response(user_query, chat_history, context):
22
 
23
  template = """
24
+ Fournir des réponses précises et contextuelles en agissant comme un expert en affaires, en utilisant le contexte des parties prenantes et leur pouvoir en pourcentage et leur influence en pourcentage pour expliquer les implications pour la marque. Le modèle doit connecter les informations du contexte et de l'historique de la conversation pour donner une réponse éclairée à la dernière question posée.
25
 
26
  Contexte: {context}
27
 
 
42
  "user_question": user_query,
43
  })
44
 
45
+ def display_chart():
46
+ if "pp_grouped" not in st.session_state or st.session_state['pp_grouped'] is None or len(st.session_state['pp_grouped']) == 0:
47
+ st.warning("Aucune partie prenante n'a été définie")
48
+ return None
49
+ plot = construct_plot()
50
+ st.plotly_chart(plot)
51
+
52
+
53
  def display_chat():
54
  # app config
55
  st.title("Chatbot")
 
56
  # session state
57
  if "chat_history" not in st.session_state:
58
  st.session_state.chat_history = [
59
+ AIMessage(content="Salut, voici votre cartographie des parties prenantes. Que puis-je faire pour vous?"),
60
  ]
61
 
62
 
 
65
  if isinstance(message, AIMessage):
66
  with st.chat_message("AI"):
67
  st.write(message.content)
68
+ if "cartographie des parties prenantes" in message.content:
69
+ display_chart()
70
  elif isinstance(message, HumanMessage):
71
  with st.chat_message("Moi"):
72
  st.write(message.content)
 
80
  st.markdown(user_query)
81
 
82
  with st.chat_message("AI"):
83
+ response = st.write_stream(get_response(user_query, st.session_state.chat_history,format_context(st.session_state['pp_grouped'],st.session_state['Nom de la marque'])))
84
+ if "cartographie des parties prenantes" in message.content:
85
+ display_chart()
86
 
87
  st.session_state.chat_history.append(AIMessage(content=response))
download_chart.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import plotly.graph_objects as go
3
+ import plotly.express as px
4
+
5
+ from PIL import Image
6
+ import pdfkit
7
+ import pandas as pd
8
+ import plotly.io as pio
9
+ import tempfile
10
+
11
+
12
+ def construct_plot():
13
+ # Define data
14
+ stakeholders = st.session_state['pp_grouped']
15
+
16
+ if stakeholders is None or len(stakeholders) == 0:
17
+ st.error("Aucune partie prenante n'a été définie")
18
+ return None
19
+ # Create plot
20
+ fig = go.Figure()
21
+
22
+ # Add category areas
23
+ fig.add_shape(type="rect", x0=0, y0=50, x1=50, y1=100, fillcolor="lightblue", opacity=0.2, line_width=0)
24
+ fig.add_shape(type="rect", x0=50, y0=50, x1=100, y1=100, fillcolor="lightyellow", opacity=0.2, line_width=0)
25
+ fig.add_shape(type="rect", x0=0, y0=0, x1=50, y1=50, fillcolor="lightcoral", opacity=0.2, line_width=0)
26
+ fig.add_shape(type="rect", x0=50, y0=0, x1=100, y1=50, fillcolor="lightcyan", opacity=0.2, line_width=0)
27
+
28
+ # Add category titles
29
+ fig.add_annotation(x=10, y=90, text="Rendre satisfait", showarrow=False)
30
+ fig.add_annotation(x=60, y=90, text="Gérer étroitement", showarrow=False)
31
+ fig.add_annotation(x=10, y=40, text="Suivre de près", showarrow=False)
32
+ fig.add_annotation(x=60, y=40, text="Tenir informé", showarrow=False)
33
+
34
+ x_array = [stakeholder['x'] for stakeholder in stakeholders]
35
+ y_array = [stakeholder['y'] for stakeholder in stakeholders]
36
+ name_array = [stakeholder['name'] for stakeholder in stakeholders]
37
+
38
+ color_sequence = px.colors.qualitative.Plotly
39
+ # Add stakeholders to plot
40
+ for i,stakeholder in enumerate(stakeholders):
41
+ fig.add_trace(go.Scatter(
42
+ x=[stakeholder['x']],
43
+ y=[stakeholder['y']],
44
+ mode='markers+text',
45
+ marker=dict(color=color_sequence[i % len(color_sequence)],size=20),
46
+ textposition="top center",
47
+ name=stakeholder['name']
48
+ ))
49
+
50
+ # Update layout
51
+ fig.update_layout(
52
+ title="Cartographie des parties prenantes",
53
+ xaxis=dict(title="Influence", range=[0, 100]),
54
+ yaxis=dict(title="Pouvoir", range=[0, 100]),
55
+ showlegend=True
56
+ )
57
+
58
+ # Display plot in Streamlit
59
+ return fig
60
+
61
+ def save_plot_as_pdf(fig, logo_path, title):
62
+ st.write("saving plot as pdf")
63
+
64
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmpfile:
65
+ fig.write_image("./plot.png")
66
+ st.write("tmpfile created")
67
+ image_bytes = pio.to_image(fig, format='png')
68
+ st.write("image_bytes")
69
+
70
+ tmpfile.write(image_bytes)
71
+ tmpfile.close()
72
+ plot_image_path = tmpfile.name
73
+
74
+ st.write(plot_image_path)
75
+
76
+ html_content = f"""
77
+ <!DOCTYPE html>
78
+ <html lang="en">
79
+ <head>
80
+ <meta charset="UTF-8">
81
+ <title>{title}</title>
82
+ <style>
83
+ body {{ font-family: Arial, sans-serif; text-align: center; }}
84
+ .logo {{ width: 100px; margin-top: 20px; }}
85
+ .title {{ font-size: 24px; margin-top: 20px; }}
86
+ .plot-image {{ width: 80%; margin-top: 20px; }}
87
+ </style>
88
+ </head>
89
+ <body>
90
+ {"<img src='" + logo_path + "' class='logo'>" if logo_path else ""}
91
+ <div class="title">{title}</div>
92
+ <img src="{plot_image_path}" class="plot-image">
93
+ </body>
94
+ </html>
95
+ """
96
+
97
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".html") as tmpfile:
98
+ tmpfile.write(html_content.encode('utf-8'))
99
+ tmpfile.close()
100
+ html_path = tmpfile.name
101
+
102
+ pdf_path = html_path.replace('.html', '.pdf')
103
+ st.write(pdf_path)
104
+ pdfkit.from_file(html_path, pdf_path)
105
+ return pdf_path
106
+
107
+ def download_pdf():
108
+ # Construct plot
109
+ fig = construct_plot()
110
+
111
+ if fig is None:
112
+ return None
113
+ st.write("fig constructed")
114
+
115
+ logo_path = "https://static.wixstatic.com/media/d7d3da_b69e03ae99224f7d8b6e358918e60071~mv2.png/v1/crop/x_173,y_0,w_1906,h_938/fill/w_242,h_119,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/BZIIIT_LOGO-HORIZ-COULEUR.png"
116
+ pdf_title = "Cartographie des parties prenantes"
117
+ # Button to download PDF
118
+ pdf_path = save_plot_as_pdf(fig, logo_path, pdf_title)
119
+
120
+ st.write("pdf saved")
121
+ with open(pdf_path, "rb") as pdf_file:
122
+ st.download_button(label="Download PDF", data=pdf_file, file_name="stakeholder_analysis.pdf")
123
+
high_chart.py ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import st_hc as hct
3
+ import download_chart as dc
4
+
5
+
6
+
7
+ # Define the highchart definition
8
+ cd2 = {
9
+ "chart":{
10
+ "animation":False
11
+ },
12
+ "title":{
13
+ "text":"Cartographie des parties prenantes"
14
+ },
15
+ "tooltip":{
16
+ "valueDecimals":0
17
+ },
18
+ "xAxis":{
19
+ "title":{
20
+ "text":"Influence"
21
+ },
22
+ "min":0,
23
+ "max":100,
24
+ "plotLines":[
25
+ {
26
+ "color":"gray",
27
+ "dashStyle":"LongDash",
28
+ "width":1,
29
+ "value":50,
30
+ "label":{
31
+ "rotation":0,
32
+ "y":290,
33
+ "style":{
34
+ "color":"blue",
35
+ "font-size": "20px"
36
+ },
37
+ "text":"Tenir informé",
38
+ },
39
+ "zIndex":3
40
+ },
41
+ {
42
+ "color":"gray",
43
+ "dashStyle":"LongDash",
44
+ "width":1,
45
+ "value":50,
46
+ "label":{
47
+ "rotation":0,
48
+ "y":25,
49
+ "style":{
50
+ "color":"orange",
51
+ "font-size": "20px"
52
+ },
53
+ "text":"Gérer étroitement",
54
+ },
55
+ "zIndex":3
56
+ },
57
+ {
58
+ "color":"gray",
59
+ "dashStyle":"LongDash",
60
+ "width":1,
61
+ "value":0,
62
+ "label":{
63
+ "rotation":0,
64
+ "y":25,
65
+ "style":{
66
+ "color":"green",
67
+ "font-size": "20px"
68
+ },
69
+ "text":"Rendre satisfait",
70
+ },
71
+ "zIndex":3
72
+ },
73
+ {
74
+ "color":"gray",
75
+ "dashStyle":"LongDash",
76
+ "width":1,
77
+ "value":0,
78
+ "label":{
79
+ "rotation":0,
80
+ "y":290,
81
+ "style":{
82
+ "color":"red",
83
+ "font-size": "20px"
84
+ },
85
+ "text":"Suivre de près",
86
+ },
87
+ "zIndex":3
88
+ },
89
+ {
90
+ "color":"gray",
91
+ "dashStyle":"LongDash",
92
+ "width":1,
93
+ "value":100,
94
+ "zIndex":3
95
+
96
+ }
97
+ ]
98
+ },
99
+ "yAxis":{
100
+ "title":{
101
+ "text":"Pouvoir"
102
+ },
103
+ "min":0,
104
+ "max":100,
105
+ "plotLines":[
106
+ {
107
+ "color":"gray",
108
+ "dashStyle":"LongDash",
109
+ "width":1,
110
+ "value":50,
111
+ "zIndex":3
112
+
113
+ },
114
+ {
115
+ "color":"gray",
116
+ "dashStyle":"LongDash",
117
+ "width":1,
118
+ "value":100,
119
+ "zIndex":3
120
+ },
121
+ {
122
+ "color":"gray",
123
+ "dashStyle":"LongDash",
124
+ "width":1,
125
+ "value":0,
126
+ "zIndex":3
127
+ }
128
+ ],
129
+ },
130
+ "tooltip":{
131
+ "headerFormat":"",
132
+ "pointFormat":"{point.name}",
133
+ "valueDecimals":0
134
+ },
135
+ "series":[
136
+ {
137
+ "type":"bubble",
138
+ "maxSize":50,
139
+ "cursor":"move",
140
+ "name":"Influence",
141
+ "pointformat":"{point.name}",
142
+ "dragDrop":{
143
+ "draggableX":True,
144
+ "draggableY":True,
145
+ "dragMinY":0,
146
+ "dragMaxY":100,
147
+ "dragMinX":0,
148
+ "dragMaxX":100,
149
+ "dragPrecisionX":1,
150
+ "dragPrecisionY":1,
151
+ "dragSensitivity":0
152
+ },
153
+ "data":[],
154
+ "colorByPoint":True
155
+ }
156
+ ],
157
+ "exporting": {
158
+ "enabled": True
159
+
160
+ },
161
+ "legend":{
162
+ "enabled":False
163
+ }
164
+ }
165
+
166
+
167
+ def construct_data():
168
+ data = []
169
+ for i in range(10):
170
+ object = {
171
+ "x": 50+i*5,
172
+ "y": 50,
173
+ "name": f"Point{i}",
174
+
175
+ }
176
+ data.append(object)
177
+
178
+ return data
179
+
180
+
181
+
182
+
183
+ def test_chart():
184
+ #The component can render any highchart definition
185
+ if len(st.session_state['pp_grouped']) == 0:
186
+ return None
187
+ points = st.session_state['pp_grouped']
188
+ cd2["series"][0]["data"] = points
189
+ chart = hct.streamlit_highcharts(cd2,640) #640 is the chart height
190
+ # if chart:
191
+ # st.session_state['pp_grouped'] = chart
192
+
193
+ emp = st.empty()
194
+
195
+ col1, col2, col3 = st.columns([2,2,8])
196
+
197
+ if col1.button("Save"):
198
+ st.session_state['pp_grouped'] = chart.copy()
199
+ emp.success("Saved")
200
+ st.experimental_rerun()
201
+
202
+ if col2.button("download"):
203
+ if not chart:
204
+ st.error("Un truc ne va pas. Veuillez réessayer")
205
+ else:
206
+ st.session_state['pp_grouped'] = chart.copy()
207
+ dc.construct_plot()
208
+ dc.download_pdf()
209
+
210
+ return chart
partie_prenante_carte.py CHANGED
@@ -22,6 +22,7 @@ from session import set_partie_prenante
22
  import os
23
  from streamlit_vertical_slider import vertical_slider
24
  from pp_viz import display_viz
 
25
 
26
  load_dotenv()
27
 
@@ -44,10 +45,6 @@ def get_doc_chunks(docs):
44
  return docs
45
 
46
 
47
- def disp_test():
48
- chart_data = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
49
- st.scatter_chart(chart_data)
50
-
51
  def get_vectorstore_from_docs(doc_chunks):
52
  embedding = OpenAIEmbeddings(model="text-embedding-3-large")
53
  vectorstore = FAISS.from_documents(documents=doc_chunks, embedding=embedding)
@@ -84,8 +81,10 @@ def text_to_list(text):
84
 
85
  def delete_pp(pps):
86
  for pp in pps:
87
- st.session_state['partie_prenante_grouped'] = st.session_state['partie_prenante_grouped'].drop(st.session_state['partie_prenante_grouped'][st.session_state['partie_prenante_grouped']['partie_prenante'] == pp].index)
88
- st.session_state['partie_prenante_grouped'].reset_index()
 
 
89
 
90
  def display_list_urls():
91
  for index, item in enumerate(st.session_state["urls"]):
@@ -107,7 +106,7 @@ def display_list_urls():
107
  st.write(pd.DataFrame(pp, columns=["Partie prenante"]))
108
  else:
109
  emp.empty() # Clear the placeholder if the index exceeds the list
110
-
111
  def extract_pp(urls,input_variables):
112
  template_extraction_PP = '''
113
  Objectif : identifiez tout les noms de marques qui sont des parties prenantes de la marque suivante pour développer un marketing de coopération (co-op marketing)
@@ -137,7 +136,7 @@ def extract_pp(urls,input_variables):
137
 
138
  # version plus poussée a considérer
139
  # each item in the list is a list with the name of the brand and the similarity percentage
140
- #partie_prenante = text_to_list(response.content)
141
 
142
  #version simple
143
  partie_prenante = response.content.replace("- ","").split('\n')
@@ -166,15 +165,21 @@ def disp_vertical_slider(partie_prenante):
166
  )
167
  st.write(tst)
168
 
 
 
 
 
 
 
 
 
169
  def add_pp(new_pp, default_value=50):
170
  new_pp = sorted(new_pp)
171
  new_pp = [item.lower().capitalize() for item in new_pp]
172
  st.session_state['parties_prenantes'].append(new_pp)
173
  for pp in new_pp:
174
- if pp not in st.session_state['partie_prenante_grouped']['partie_prenante'].values:
175
- st.session_state['partie_prenante_grouped'].loc[len(st.session_state['partie_prenante_grouped'])] = [pp, default_value, pp]
176
- st.session_state['partie_prenante_grouped'] = st.session_state['partie_prenante_grouped'].sort_values(by='partie_prenante')
177
- st.session_state['partie_prenante_grouped'] = st.session_state['partie_prenante_grouped'].reset_index(drop=True)
178
 
179
  def complete_and_verify_url(partial_url):
180
  # Regex pattern for validating a URL
@@ -188,7 +193,7 @@ def complete_and_verify_url(partial_url):
188
 
189
  # Complete the URL if it doesn't have http:// or https://
190
  if not partial_url.startswith(('http://', 'https://')):
191
- complete_url = 'http://' + partial_url
192
  else:
193
  complete_url = partial_url
194
 
@@ -205,25 +210,22 @@ def display_pp():
205
  #check if brand name and description are already set
206
  if "Nom de la marque" not in st.session_state:
207
  st.session_state["Nom de la marque"] = ""
208
- if "Description de la marque" not in st.session_state:
209
- st.session_state["Description de la marque"] = ""
210
 
211
  #check if urls and partie prenante are already set
212
  if "urls" not in st.session_state:
213
  st.session_state["urls"] = []
214
  if "parties_prenantes" not in st.session_state:
215
  st.session_state['parties_prenantes'] = []
216
- if "partie_prenante_grouped" not in st.session_state: #servira pour le plot et la cartographie
217
- st.session_state['partie_prenante_grouped'] = pd.DataFrame(columns=['partie_prenante', 'pouvoir', 'Code couleur'])
218
 
219
  st.header("Parties prenantes de la marque")
220
  #set brand name and description
221
  brand_name = st.text_input("Nom de la marque", st.session_state["Nom de la marque"])
222
  st.session_state["Nom de la marque"] = brand_name
223
- brand_description = st.text_input("Description de la marque", st.session_state["Description de la marque"])
224
- st.session_state["Description de la marque"] = brand_description
225
 
226
  option = st.radio("Source", ("A partir de votre site web", "A partir de vos documents entreprise"))
 
227
  #if the user chooses to extract from website
228
  if option == "A partir de votre site web":
229
 
@@ -231,11 +233,14 @@ def display_pp():
231
 
232
  #if the user clicks on the button
233
  if st.button("ajouter"):
 
 
234
  is_valid,url = complete_and_verify_url(url)
235
  if not is_valid:
236
  st.error("URL invalide")
237
  elif url in st.session_state["urls"] :
238
  st.error("URL déjà ajoutée")
 
239
  else:
240
  # Création de l'expander
241
  with st.expander("Cliquez ici pour éditer et voir le document"):
@@ -243,13 +248,14 @@ def display_pp():
243
  text_value = st.text_area("Modifier le texte ci-dessous:", value=cleaned_text, height=300)
244
  if st.button('Sauvegarder'):
245
  st.success("Texte sauvegardé avec succès!")
 
246
  with st.spinner("Processing..."):
247
 
248
  #handle the extraction
249
- input_variables = {"BRAND_NAME": brand_name, "BRAND_DESCRIPTION": brand_description}
250
  partie_prenante = extract_pp([url], input_variables)
251
 
252
- if "444" in partie_prenante:
253
  st.error("Aucune partie prenante trouvée")
254
  else:
255
  partie_prenante = sorted(partie_prenante)
@@ -272,10 +278,8 @@ def display_pp():
272
 
273
  # disp_vertical_slider(partie_prenante)
274
  # st.altair_chart(c, use_container_width=True)
275
-
276
  display_list_urls()
277
- display_viz()
278
- st.write(st.session_state["partie_prenante_grouped"])
279
 
280
 
281
 
 
22
  import os
23
  from streamlit_vertical_slider import vertical_slider
24
  from pp_viz import display_viz
25
+ from high_chart import test_chart
26
 
27
  load_dotenv()
28
 
 
45
  return docs
46
 
47
 
 
 
 
 
48
  def get_vectorstore_from_docs(doc_chunks):
49
  embedding = OpenAIEmbeddings(model="text-embedding-3-large")
50
  vectorstore = FAISS.from_documents(documents=doc_chunks, embedding=embedding)
 
81
 
82
  def delete_pp(pps):
83
  for pp in pps:
84
+ for i in range(len(st.session_state['pp_grouped'])):
85
+ if st.session_state['pp_grouped'][i]['name'] == pp:
86
+ del st.session_state['pp_grouped'][i]
87
+ break
88
 
89
  def display_list_urls():
90
  for index, item in enumerate(st.session_state["urls"]):
 
106
  st.write(pd.DataFrame(pp, columns=["Partie prenante"]))
107
  else:
108
  emp.empty() # Clear the placeholder if the index exceeds the list
109
+
110
  def extract_pp(urls,input_variables):
111
  template_extraction_PP = '''
112
  Objectif : identifiez tout les noms de marques qui sont des parties prenantes de la marque suivante pour développer un marketing de coopération (co-op marketing)
 
136
 
137
  # version plus poussée a considérer
138
  # each item in the list is a list with the name of the brand and the similarity percentage
139
+ # partie_prenante = text_to_list(response.content)
140
 
141
  #version simple
142
  partie_prenante = response.content.replace("- ","").split('\n')
 
165
  )
166
  st.write(tst)
167
 
168
+ def format_pp_add_viz(pp):
169
+
170
+ for i in range(len(st.session_state['pp_grouped'])):
171
+ if st.session_state['pp_grouped'][i]['name'] == pp:
172
+ return None
173
+ else:
174
+ st.session_state['pp_grouped'].append({'name':pp, 'x':50,'y':50 + len(st.session_state['pp_grouped'])*5})
175
+
176
  def add_pp(new_pp, default_value=50):
177
  new_pp = sorted(new_pp)
178
  new_pp = [item.lower().capitalize() for item in new_pp]
179
  st.session_state['parties_prenantes'].append(new_pp)
180
  for pp in new_pp:
181
+ format_pp_add_viz(pp)
182
+
 
 
183
 
184
  def complete_and_verify_url(partial_url):
185
  # Regex pattern for validating a URL
 
193
 
194
  # Complete the URL if it doesn't have http:// or https://
195
  if not partial_url.startswith(('http://', 'https://')):
196
+ complete_url = 'https://' + partial_url
197
  else:
198
  complete_url = partial_url
199
 
 
210
  #check if brand name and description are already set
211
  if "Nom de la marque" not in st.session_state:
212
  st.session_state["Nom de la marque"] = ""
 
 
213
 
214
  #check if urls and partie prenante are already set
215
  if "urls" not in st.session_state:
216
  st.session_state["urls"] = []
217
  if "parties_prenantes" not in st.session_state:
218
  st.session_state['parties_prenantes'] = []
219
+ if "pp_grouped" not in st.session_state: #servira pour le plot et la cartographie des parties prenantes, regroupe sans doublons
220
+ st.session_state['pp_grouped'] = []
221
 
222
  st.header("Parties prenantes de la marque")
223
  #set brand name and description
224
  brand_name = st.text_input("Nom de la marque", st.session_state["Nom de la marque"])
225
  st.session_state["Nom de la marque"] = brand_name
 
 
226
 
227
  option = st.radio("Source", ("A partir de votre site web", "A partir de vos documents entreprise"))
228
+
229
  #if the user chooses to extract from website
230
  if option == "A partir de votre site web":
231
 
 
233
 
234
  #if the user clicks on the button
235
  if st.button("ajouter"):
236
+
237
+ #complete and verify the url
238
  is_valid,url = complete_and_verify_url(url)
239
  if not is_valid:
240
  st.error("URL invalide")
241
  elif url in st.session_state["urls"] :
242
  st.error("URL déjà ajoutée")
243
+
244
  else:
245
  # Création de l'expander
246
  with st.expander("Cliquez ici pour éditer et voir le document"):
 
248
  text_value = st.text_area("Modifier le texte ci-dessous:", value=cleaned_text, height=300)
249
  if st.button('Sauvegarder'):
250
  st.success("Texte sauvegardé avec succès!")
251
+
252
  with st.spinner("Processing..."):
253
 
254
  #handle the extraction
255
+ input_variables = {"BRAND_NAME": brand_name, "BRAND_DESCRIPTION": ""}
256
  partie_prenante = extract_pp([url], input_variables)
257
 
258
+ if "444" in partie_prenante: #444 is the code for no brand found , chosen
259
  st.error("Aucune partie prenante trouvée")
260
  else:
261
  partie_prenante = sorted(partie_prenante)
 
278
 
279
  # disp_vertical_slider(partie_prenante)
280
  # st.altair_chart(c, use_container_width=True)
 
281
  display_list_urls()
282
+ test_chart()
 
283
 
284
 
285
 
requirements.txt CHANGED
@@ -29,4 +29,7 @@ altair[all]
29
  streamlit-vertical-slider
30
  streamlit_toggle
31
  langchain_experimental
32
- streamlit_draggable_list
 
 
 
 
29
  streamlit-vertical-slider
30
  streamlit_toggle
31
  langchain_experimental
32
+ streamlit_draggable_list
33
+ streamlit-highcharts
34
+ pdfkit
35
+ kaleido
st_hc/__init__.py ADDED
@@ -0,0 +1,2562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from typing import Optional
3
+
4
+ import streamlit as st
5
+ import streamlit.components.v1 as components
6
+
7
+ SAMPLE={
8
+
9
+ "title": {
10
+ "text": 'U.S Solar Employment Growth by Job Category, 2010-2020'
11
+ },
12
+
13
+ "subtitle": {
14
+ "text": 'Source: <a href="https://irecusa.org/programs/solar-jobs-census/" target="_blank">IREC</a>'
15
+ },
16
+
17
+ "yAxis": {
18
+ "title": {
19
+ "text": 'Number of Employees'
20
+ }
21
+ },
22
+
23
+ "xAxis": {
24
+ "accessibility": {
25
+ "rangeDescription": 'Range: 2010 to 2020'
26
+ }
27
+ },
28
+
29
+ "legend": {
30
+ "layout": 'vertical',
31
+ "align": 'right',
32
+ "verticalAlign": 'middle'
33
+ },
34
+
35
+ "plotOptions": {
36
+ "series": {
37
+ "label": {
38
+ "connectorAllowed": False
39
+ },
40
+ "pointStart": 2010
41
+ }
42
+ },
43
+
44
+ "series": [{
45
+ "name": 'Installation & Developers',
46
+ "data": [43934, 48656, 65165, 81827, 112143, 142383,
47
+ 171533, 165174, 155157, 161454, 154610]
48
+ }, {
49
+ "name": 'Manufacturing',
50
+ "data": [24916, 37941, 29742, 29851, 32490, 30282,
51
+ 38121, 36885, 33726, 34243, 31050]
52
+ }, {
53
+ "name": 'Sales & Distribution',
54
+ "data": [11744, 30000, 16005, 19771, 20185, 24377,
55
+ 32147, 30912, 29243, 29213, 25663]
56
+ }, {
57
+ "name": 'Operations & Maintenance',
58
+ "data": ["null", "null", "null", "null", "null", "null", "null",
59
+ "null", 11164, 11218, 10077]
60
+ }, {
61
+ "name": 'Other',
62
+ "data": [21908, 5548, 8105, 11248, 8989, 11816, 18274,
63
+ 17300, 13053, 11906, 10073]
64
+ }],
65
+
66
+ "responsive": {
67
+ "rules": [{
68
+ "condition": {
69
+ "maxWidth": 500
70
+ },
71
+ "chartOptions": {
72
+ "legend": {
73
+ "layout": 'horizontal',
74
+ "align": 'center',
75
+ "verticalAlign": 'bottom'
76
+ }
77
+ }
78
+ }]
79
+ }
80
+
81
+ }
82
+ SAMPLE2={
83
+
84
+ "chart": {
85
+ "type": 'streamgraph',
86
+ "marginBottom": 30,
87
+ "zoomType": 'x'
88
+ },
89
+
90
+ "title": {
91
+ "floating": True,
92
+ "align": 'left',
93
+ "text": 'Winter Olympic Medal Wins'
94
+ },
95
+ "subtitle": {
96
+ "floating": True,
97
+ "align": 'left',
98
+ "y": 30,
99
+ "text": 'Source: <a href="https://www.sports-reference.com/olympics/winter/1924/">sports-reference.com</a>'
100
+ },
101
+
102
+ "xAxis": {
103
+ "maxPadding": 0,
104
+ "type": 'category',
105
+ "crosshair": True,
106
+ "categories": [
107
+ '',
108
+ '1924 Chamonix',
109
+ '1928 St. Moritz',
110
+ '1932 Lake Placid',
111
+ '1936 Garmisch-Partenkirchen',
112
+ '1940 <i>Cancelled (Sapporo)</i>',
113
+ '1944 <i>Cancelled (Cortina d\'Ampezzo)</i>',
114
+ '1948 St. Moritz',
115
+ '1952 Oslo',
116
+ '1956 Cortina d\'Ampezzo',
117
+ '1960 Squaw Valley',
118
+ '1964 Innsbruck',
119
+ '1968 Grenoble',
120
+ '1972 Sapporo',
121
+ '1976 Innsbruck',
122
+ '1980 Lake Placid',
123
+ '1984 Sarajevo',
124
+ '1988 Calgary',
125
+ '1992 Albertville',
126
+ '1994 Lillehammer',
127
+ '1998 Nagano',
128
+ '2002 Salt Lake City',
129
+ '2006 Turin',
130
+ '2010 Vancouver',
131
+ '2014 Sochi'
132
+ ],
133
+ "labels": {
134
+ "align": 'left',
135
+ "reserveSpace": False,
136
+ "rotation": 270
137
+ },
138
+ "lineWidth": 0,
139
+ "margin": 20,
140
+ "tickWidth": 0
141
+ },
142
+
143
+ "yAxis": {
144
+ "visible": False,
145
+ "startOnTick": False,
146
+ "endOnTick": False
147
+ },
148
+
149
+ "legend": {
150
+ "enabled": False
151
+ },
152
+
153
+ "annotations": [{
154
+ "labels": [{
155
+ "point": {
156
+ "x": 5.5,
157
+ "xAxis": 0,
158
+ "y": 30,
159
+ "yAxis": 0
160
+ },
161
+ "text": 'Cancelled<br>during<br>World War II'
162
+ }, {
163
+ "point": {
164
+ "x": 18,
165
+ "xAxis": 0,
166
+ "y": 90,
167
+ "yAxis": 0
168
+ },
169
+ "text": 'Soviet Union fell,<br>Germany united'
170
+ }],
171
+ "labelOptions": {
172
+ "backgroundColor": 'rgba(255,255,255,0.5)',
173
+ "borderColor": 'silver'
174
+ }
175
+ }],
176
+
177
+ "plotOptions": {
178
+ "series": {
179
+ "label": {
180
+ "minFontSize": 5,
181
+ "maxFontSize": 15,
182
+ "style": {
183
+ "color": 'rgba(255,255,255,0.75)'
184
+ }
185
+ },
186
+ "accessibility": {
187
+ "exposeAsGroupOnly": True
188
+ }
189
+ }
190
+ },
191
+ "series": [{
192
+ "name": "Finland",
193
+ "data": [
194
+ 0, 11, 4, 3, 6, 0, 0, 6, 9, 7, 8, 10, 5, 5, 7, 9, 13, 7,
195
+ 7, 6, 12, 7, 9, 5, 5
196
+ ]
197
+ }, {
198
+ "name": "Austria",
199
+ "data": [
200
+ 0, 3, 4, 2, 4, 0, 0, 8, 8, 11, 6, 12, 11, 5, 6, 7, 1, 10,
201
+ 21, 9, 17, 17, 23, 16, 17
202
+ ]
203
+ }, {
204
+ "name": "Sweden",
205
+ "data": [
206
+ 0, 2, 5, 3, 7, 0, 0, 10, 4, 10, 7, 7, 8, 4, 2, 4, 8, 6, 4,
207
+ 3, 3, 7, 14, 11, 15
208
+ ]
209
+ }, {
210
+ "name": "Norway",
211
+ "data": [
212
+ 0, 17, 15, 10, 15, 0, 0, 10, 16, 4, 6, 15, 14, 12, 7, 10,
213
+ 9, 5, 20, 26, 25, 25, 19, 23, 26
214
+ ]
215
+ }, {
216
+ "name": "U.S.",
217
+ "data": [
218
+ 0, 4, 6, 12, 4, 0, 0, 9, 11, 7, 10, 7, 7, 8, 10, 12, 8, 6,
219
+ 11, 13, 13, 34, 25, 37, 28
220
+ ]
221
+ }, {
222
+ "name": "East Germany",
223
+ "data": [
224
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 14, 19, 23, 24, 25,
225
+ 0, 0, 0, 0, 0, 0, 0
226
+ ]
227
+ }, {
228
+ "name": "West Germany",
229
+ "data": [
230
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 5, 10, 5, 4, 8, 0,
231
+ 0, 0, 0, 0, 0, 0
232
+ ]
233
+ }, {
234
+ "name": "Germany",
235
+ "data": [
236
+ 0, 0, 1, 2, 6, 0, 0, 0, 7, 2, 8, 9, 0, 0, 0, 0, 0, 0, 26,
237
+ 24, 29, 36, 29, 30, 19
238
+ ]
239
+ }, {
240
+ "name": "Netherlands",
241
+ "data": [
242
+ 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 2, 9, 9, 6, 4, 0, 7, 4,
243
+ 4, 11, 8, 9, 8, 24
244
+ ]
245
+ }, {
246
+ "name": "Italy",
247
+ "data": [
248
+ 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 1, 4, 4, 5, 4, 2, 2, 5, 14,
249
+ 20, 10, 13, 11, 5, 8
250
+ ]
251
+ }, {
252
+ "name": "Canada",
253
+ "data": [
254
+ 0, 1, 1, 7, 1, 0, 0, 3, 2, 3, 4, 3, 3, 1, 3, 2, 4, 5, 7,
255
+ 13, 15, 17, 24, 26, 25
256
+ ]
257
+ }, {
258
+ "name": "Switzerland",
259
+ "data": [
260
+ 0, 3, 1, 1, 3, 0, 0, 10, 2, 6, 2, 0, 6, 10, 5, 5, 5, 15,
261
+ 3, 9, 7, 11, 14, 9, 11
262
+ ]
263
+ }, {
264
+ "name": "Great Britain",
265
+ "data": [
266
+ 0, 4, 1, 0, 3, 0, 0, 2, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0,
267
+ 2, 1, 2, 1, 1, 4
268
+ ]
269
+ }, {
270
+ "name": "France",
271
+ "data": [
272
+ 0, 3, 1, 1, 1, 0, 0, 5, 1, 0, 3, 7, 9, 3, 1, 1, 3, 2, 9,
273
+ 5, 8, 11, 9, 11, 15
274
+ ]
275
+ }, {
276
+ "name": "Hungary",
277
+ "data": [
278
+ 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
279
+ 0, 0, 0, 0, 0, 0
280
+ ]
281
+ }, {
282
+ "name": "Unified Team",
283
+ "data": [
284
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23,
285
+ 0, 0, 0, 0, 0, 0
286
+ ]
287
+ }, {
288
+ "name": "Soviet Union",
289
+ "data": [
290
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 21, 25, 13, 16, 27, 22, 25,
291
+ 29, 0, 0, 0, 0, 0, 0, 0
292
+ ]
293
+ }, {
294
+ "name": "Russia",
295
+ "data": [
296
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
297
+ 23, 18, 13, 22, 15, 33
298
+ ]
299
+ }, {
300
+ "name": "Japan",
301
+ "data": [
302
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 1, 1, 1, 7,
303
+ 5, 10, 2, 1, 5, 8
304
+ ]
305
+ }, {
306
+ "name": "Czechoslovakia",
307
+ "data": [
308
+ 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 4, 3, 1, 1, 6, 3, 3,
309
+ 0, 0, 0, 0, 0, 0
310
+ ]
311
+ }, {
312
+ "name": "Poland",
313
+ "data": [
314
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0,
315
+ 0, 0, 2, 2, 6, 6
316
+ ]
317
+ }, {
318
+ "name": "Spain",
319
+ "data": [
320
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
321
+ 0, 0, 0, 0, 0, 0
322
+ ]
323
+ }, {
324
+ "name": "China",
325
+ "data": [
326
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
327
+ 3, 8, 8, 11, 11, 9
328
+ ]
329
+ }, {
330
+ "name": "South Korea",
331
+ "data": [
332
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4,
333
+ 6, 6, 4, 11, 14, 8
334
+ ]
335
+ }, {
336
+ "name": "Czech Republic",
337
+ "data": [
338
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
339
+ 0, 3, 3, 4, 6, 8
340
+ ]
341
+ }, {
342
+ "name": "Belarus",
343
+ "data": [
344
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
345
+ 2, 2, 1, 1, 3, 6
346
+ ]
347
+ }, {
348
+ "name": "Kazakhstan",
349
+ "data": [
350
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
351
+ 3, 2, 0, 0, 1, 1
352
+ ]
353
+ }, {
354
+ "name": "Bulgaria",
355
+ "data": [
356
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
357
+ 0, 1, 3, 1, 0, 0
358
+ ]
359
+ }, {
360
+ "name": "Denmark",
361
+ "data": [
362
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
363
+ 0, 1, 0, 0, 0, 0
364
+ ]
365
+ }, {
366
+ "name": "Ukraine",
367
+ "data": [
368
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
369
+ 2, 1, 0, 2, 0, 2
370
+ ]
371
+ }, {
372
+ "name": "Australia",
373
+ "data": [
374
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
375
+ 1, 1, 2, 2, 3, 3
376
+ ]
377
+ }, {
378
+ "name": "Belgium",
379
+ "data": [
380
+ 0, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
381
+ 0, 1, 0, 0, 0, 0
382
+ ]
383
+ }, {
384
+ "name": "Romania",
385
+ "data": [
386
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
387
+ 0, 0, 0, 0, 0, 0
388
+ ]
389
+ }, {
390
+ "name": "Liechtenstein",
391
+ "data": [
392
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 2, 1, 0,
393
+ 0, 0, 0, 0, 0, 0
394
+ ]
395
+ }, {
396
+ "name": "Yugoslavia",
397
+ "data": [
398
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0,
399
+ 0, 0, 0, 0, 0, 0
400
+ ]
401
+ }, {
402
+ "name": "Luxembourg",
403
+ "data": [
404
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
405
+ 0, 0, 0, 0, 0, 0
406
+ ]
407
+ }, {
408
+ "name": "New Zealand",
409
+ "data": [
410
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
411
+ 0, 0, 0, 0, 0, 0
412
+ ]
413
+ }, {
414
+ "name": "North Korea",
415
+ "data": [
416
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1,
417
+ 0, 0, 0, 0, 0, 0
418
+ ]
419
+ }, {
420
+ "name": "Slovakia",
421
+ "data": [
422
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
423
+ 0, 0, 0, 1, 3, 1
424
+ ]
425
+ }, {
426
+ "name": "Croatia",
427
+ "data": [
428
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
429
+ 0, 0, 4, 3, 3, 1
430
+ ]
431
+ }, {
432
+ "name": "Slovenia",
433
+ "data": [
434
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
435
+ 3, 0, 1, 0, 3, 8
436
+ ]
437
+ }, {
438
+ "name": "Latvia",
439
+ "data": [
440
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
441
+ 0, 0, 0, 1, 2, 4
442
+ ]
443
+ }, {
444
+ "name": "Estonia",
445
+ "data": [
446
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
447
+ 0, 0, 3, 3, 1, 0
448
+ ]
449
+ }, {
450
+ "name": "Uzbekistan",
451
+ "data": [
452
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
453
+ 1, 0, 0, 0, 0, 0
454
+ ]
455
+ }],
456
+
457
+ "exporting": {
458
+ "sourceWidth": 800,
459
+ "sourceHeight": 600
460
+ }
461
+
462
+ }
463
+ SAMPLE3={
464
+
465
+ "chart": {
466
+ "type": 'bubble',
467
+ "plotBorderWidth": 1,
468
+ "zoomType": 'xy'
469
+ },
470
+
471
+ "title": {
472
+ "text": 'Highcharts bubbles with radial gradient fill'
473
+ },
474
+
475
+ "xAxis": {
476
+ "gridLineWidth": 1,
477
+ "accessibility": {
478
+ "rangeDescription": 'Range: 0 to 100.'
479
+ }
480
+ },
481
+
482
+ "yAxis": {
483
+ "startOnTick": False,
484
+ "endOnTick": False,
485
+ "accessibility": {
486
+ "rangeDescription": 'Range: 0 to 100.'
487
+ }
488
+ },
489
+
490
+ "series": [{
491
+ "data": [
492
+ [9, 81, 63],
493
+ [98, 5, 89],
494
+ [51, 50, 73],
495
+ [41, 22, 14],
496
+ [58, 24, 20],
497
+ [78, 37, 34],
498
+ [55, 56, 53],
499
+ [18, 45, 70],
500
+ [42, 44, 28],
501
+ [3, 52, 59],
502
+ [31, 18, 97],
503
+ [79, 91, 63],
504
+ [93, 23, 23],
505
+ [44, 83, 22]
506
+ ],
507
+ "marker": {
508
+ "fillColor": {
509
+ "radialGradient": { "cx": 0.4, "cy": 0.3, "r": 0.7 },
510
+ "stops": [
511
+ [0, 'rgba(255,255,255,0.5)'],
512
+ [1, 'rgba(124,181,236,0.5)']
513
+ ]
514
+ }
515
+ }
516
+ }, {
517
+ "data": [
518
+ [42, 38, 20],
519
+ [6, 18, 1],
520
+ [1, 93, 55],
521
+ [57, 2, 90],
522
+ [80, 76, 22],
523
+ [11, 74, 96],
524
+ [88, 56, 10],
525
+ [30, 47, 49],
526
+ [57, 62, 98],
527
+ [4, 16, 16],
528
+ [46, 10, 11],
529
+ [22, 87, 89],
530
+ [57, 91, 82],
531
+ [45, 15, 98]
532
+ ],
533
+ "marker": {
534
+ "fillColor": {
535
+ "radialGradient": { "cx": 0.4, "cy": 0.3, "r": 0.7 },
536
+ "stops": [
537
+ [0, 'rgba(255,255,255,0.5)'],
538
+ [1, 'rgba(67,67,72,0.5)']
539
+ ]
540
+ }
541
+ }
542
+ }]
543
+
544
+ }
545
+ SAMPLE4={
546
+
547
+ "chart":{
548
+ "type":"packedbubble",
549
+ "height":"100%"
550
+ },
551
+ "title":{
552
+ "text":"Carbon emissions around the world (2014)"
553
+ },
554
+ "tooltip":{
555
+ "useHTML":True,
556
+ "pointFormat":"<b>{point.name}:</b> {point.value}m CO<sub>2</sub>"
557
+ },
558
+ "plotOptions":{
559
+ "packedbubble":{
560
+ "minSize":"20%",
561
+ "maxSize":"100%",
562
+ "zMin":0,
563
+ "zMax":1000,
564
+ "layoutAlgorithm":{
565
+ "gravitationalConstant":0.05,
566
+ "splitSeries":True,
567
+ "seriesInteraction":False,
568
+ "dragBetweenSeries":True,
569
+ "parentNodeLimit":True
570
+ },
571
+ "dataLabels":{
572
+ "enabled":True,
573
+ "format":"{point.name}",
574
+ "filter":{
575
+ "property":"y",
576
+ "operator":">",
577
+ "value":250
578
+ },
579
+ "style":{
580
+ "color":"black",
581
+ "textOutline":"none",
582
+ "fontWeight":"normal"
583
+ }
584
+ }
585
+ }
586
+ },
587
+ "series":[
588
+ {
589
+ "name":"Europe",
590
+ "data":[
591
+ {
592
+ "name":"Germany",
593
+ "value":767.1
594
+ },
595
+ {
596
+ "name":"Croatia",
597
+ "value":20.7
598
+ },
599
+ {
600
+ "name":"Belgium",
601
+ "value":97.2
602
+ },
603
+ {
604
+ "name":"Czech Republic",
605
+ "value":111.7
606
+ },
607
+ {
608
+ "name":"Netherlands",
609
+ "value":158.1
610
+ },
611
+ {
612
+ "name":"Spain",
613
+ "value":241.6
614
+ },
615
+ {
616
+ "name":"Ukraine",
617
+ "value":249.1
618
+ },
619
+ {
620
+ "name":"Poland",
621
+ "value":298.1
622
+ },
623
+ {
624
+ "name":"France",
625
+ "value":323.7
626
+ },
627
+ {
628
+ "name":"Romania",
629
+ "value":78.3
630
+ },
631
+ {
632
+ "name":"United Kingdom",
633
+ "value":415.4
634
+ },
635
+ {
636
+ "name":"Turkey",
637
+ "value":353.2
638
+ },
639
+ {
640
+ "name":"Italy",
641
+ "value":337.6
642
+ },
643
+ {
644
+ "name":"Greece",
645
+ "value":71.1
646
+ },
647
+ {
648
+ "name":"Austria",
649
+ "value":69.8
650
+ },
651
+ {
652
+ "name":"Belarus",
653
+ "value":67.7
654
+ },
655
+ {
656
+ "name":"Serbia",
657
+ "value":59.3
658
+ },
659
+ {
660
+ "name":"Finland",
661
+ "value":54.8
662
+ },
663
+ {
664
+ "name":"Bulgaria",
665
+ "value":51.2
666
+ },
667
+ {
668
+ "name":"Portugal",
669
+ "value":48.3
670
+ },
671
+ {
672
+ "name":"Norway",
673
+ "value":44.4
674
+ },
675
+ {
676
+ "name":"Sweden",
677
+ "value":44.3
678
+ },
679
+ {
680
+ "name":"Hungary",
681
+ "value":43.7
682
+ },
683
+ {
684
+ "name":"Switzerland",
685
+ "value":40.2
686
+ },
687
+ {
688
+ "name":"Denmark",
689
+ "value":40
690
+ },
691
+ {
692
+ "name":"Slovakia",
693
+ "value":34.7
694
+ },
695
+ {
696
+ "name":"Ireland",
697
+ "value":34.6
698
+ },
699
+ {
700
+ "name":"Croatia",
701
+ "value":20.7
702
+ },
703
+ {
704
+ "name":"Estonia",
705
+ "value":19.4
706
+ },
707
+ {
708
+ "name":"Slovenia",
709
+ "value":16.7
710
+ },
711
+ {
712
+ "name":"Lithuania",
713
+ "value":12.3
714
+ },
715
+ {
716
+ "name":"Luxembourg",
717
+ "value":10.4
718
+ },
719
+ {
720
+ "name":"Macedonia",
721
+ "value":9.5
722
+ },
723
+ {
724
+ "name":"Moldova",
725
+ "value":7.8
726
+ },
727
+ {
728
+ "name":"Latvia",
729
+ "value":7.5
730
+ },
731
+ {
732
+ "name":"Cyprus",
733
+ "value":7.2
734
+ }
735
+ ]
736
+ },
737
+ {
738
+ "name":"Africa",
739
+ "data":[
740
+ {
741
+ "name":"Senegal",
742
+ "value":8.2
743
+ },
744
+ {
745
+ "name":"Cameroon",
746
+ "value":9.2
747
+ },
748
+ {
749
+ "name":"Zimbabwe",
750
+ "value":13.1
751
+ },
752
+ {
753
+ "name":"Ghana",
754
+ "value":14.1
755
+ },
756
+ {
757
+ "name":"Kenya",
758
+ "value":14.1
759
+ },
760
+ {
761
+ "name":"Sudan",
762
+ "value":17.3
763
+ },
764
+ {
765
+ "name":"Tunisia",
766
+ "value":24.3
767
+ },
768
+ {
769
+ "name":"Angola",
770
+ "value":25
771
+ },
772
+ {
773
+ "name":"Libya",
774
+ "value":50.6
775
+ },
776
+ {
777
+ "name":"Ivory Coast",
778
+ "value":7.3
779
+ },
780
+ {
781
+ "name":"Morocco",
782
+ "value":60.7
783
+ },
784
+ {
785
+ "name":"Ethiopia",
786
+ "value":8.9
787
+ },
788
+ {
789
+ "name":"United Republic of Tanzania",
790
+ "value":9.1
791
+ },
792
+ {
793
+ "name":"Nigeria",
794
+ "value":93.9
795
+ },
796
+ {
797
+ "name":"South Africa",
798
+ "value":392.7
799
+ },
800
+ {
801
+ "name":"Egypt",
802
+ "value":225.1
803
+ },
804
+ {
805
+ "name":"Algeria",
806
+ "value":141.5
807
+ }
808
+ ]
809
+ },
810
+ {
811
+ "name":"Oceania",
812
+ "data":[
813
+ {
814
+ "name":"Australia",
815
+ "value":409.4
816
+ },
817
+ {
818
+ "name":"New Zealand",
819
+ "value":34.1
820
+ },
821
+ {
822
+ "name":"Papua New Guinea",
823
+ "value":7.1
824
+ }
825
+ ]
826
+ },
827
+ {
828
+ "name":"North America",
829
+ "data":[
830
+ {
831
+ "name":"Costa Rica",
832
+ "value":7.6
833
+ },
834
+ {
835
+ "name":"Honduras",
836
+ "value":8.4
837
+ },
838
+ {
839
+ "name":"Jamaica",
840
+ "value":8.3
841
+ },
842
+ {
843
+ "name":"Panama",
844
+ "value":10.2
845
+ },
846
+ {
847
+ "name":"Guatemala",
848
+ "value":12
849
+ },
850
+ {
851
+ "name":"Dominican Republic",
852
+ "value":23.4
853
+ },
854
+ {
855
+ "name":"Cuba",
856
+ "value":30.2
857
+ },
858
+ {
859
+ "name":"USA",
860
+ "value":5334.5
861
+ },
862
+ {
863
+ "name":"Canada",
864
+ "value":566
865
+ },
866
+ {
867
+ "name":"Mexico",
868
+ "value":456.3
869
+ }
870
+ ]
871
+ },
872
+ {
873
+ "name":"South America",
874
+ "data":[
875
+ {
876
+ "name":"El Salvador",
877
+ "value":7.2
878
+ },
879
+ {
880
+ "name":"Uruguay",
881
+ "value":8.1
882
+ },
883
+ {
884
+ "name":"Bolivia",
885
+ "value":17.8
886
+ },
887
+ {
888
+ "name":"Trinidad and Tobago",
889
+ "value":34
890
+ },
891
+ {
892
+ "name":"Ecuador",
893
+ "value":43
894
+ },
895
+ {
896
+ "name":"Chile",
897
+ "value":78.6
898
+ },
899
+ {
900
+ "name":"Peru",
901
+ "value":52
902
+ },
903
+ {
904
+ "name":"Colombia",
905
+ "value":74.1
906
+ },
907
+ {
908
+ "name":"Brazil",
909
+ "value":501.1
910
+ },
911
+ {
912
+ "name":"Argentina",
913
+ "value":199
914
+ },
915
+ {
916
+ "name":"Venezuela",
917
+ "value":195.2
918
+ }
919
+ ]
920
+ },
921
+ {
922
+ "name":"Asia",
923
+ "data":[
924
+ {
925
+ "name":"Nepal",
926
+ "value":6.5
927
+ },
928
+ {
929
+ "name":"Georgia",
930
+ "value":6.5
931
+ },
932
+ {
933
+ "name":"Brunei Darussalam",
934
+ "value":7.4
935
+ },
936
+ {
937
+ "name":"Kyrgyzstan",
938
+ "value":7.4
939
+ },
940
+ {
941
+ "name":"Afghanistan",
942
+ "value":7.9
943
+ },
944
+ {
945
+ "name":"Myanmar",
946
+ "value":9.1
947
+ },
948
+ {
949
+ "name":"Mongolia",
950
+ "value":14.7
951
+ },
952
+ {
953
+ "name":"Sri Lanka",
954
+ "value":16.6
955
+ },
956
+ {
957
+ "name":"Bahrain",
958
+ "value":20.5
959
+ },
960
+ {
961
+ "name":"Yemen",
962
+ "value":22.6
963
+ },
964
+ {
965
+ "name":"Jordan",
966
+ "value":22.3
967
+ },
968
+ {
969
+ "name":"Lebanon",
970
+ "value":21.1
971
+ },
972
+ {
973
+ "name":"Azerbaijan",
974
+ "value":31.7
975
+ },
976
+ {
977
+ "name":"Singapore",
978
+ "value":47.8
979
+ },
980
+ {
981
+ "name":"Hong Kong",
982
+ "value":49.9
983
+ },
984
+ {
985
+ "name":"Syria",
986
+ "value":52.7
987
+ },
988
+ {
989
+ "name":"DPR Korea",
990
+ "value":59.9
991
+ },
992
+ {
993
+ "name":"Israel",
994
+ "value":64.8
995
+ },
996
+ {
997
+ "name":"Turkmenistan",
998
+ "value":70.6
999
+ },
1000
+ {
1001
+ "name":"Oman",
1002
+ "value":74.3
1003
+ },
1004
+ {
1005
+ "name":"Qatar",
1006
+ "value":88.8
1007
+ },
1008
+ {
1009
+ "name":"Philippines",
1010
+ "value":96.9
1011
+ },
1012
+ {
1013
+ "name":"Kuwait",
1014
+ "value":98.6
1015
+ },
1016
+ {
1017
+ "name":"Uzbekistan",
1018
+ "value":122.6
1019
+ },
1020
+ {
1021
+ "name":"Iraq",
1022
+ "value":139.9
1023
+ },
1024
+ {
1025
+ "name":"Pakistan",
1026
+ "value":158.1
1027
+ },
1028
+ {
1029
+ "name":"Vietnam",
1030
+ "value":190.2
1031
+ },
1032
+ {
1033
+ "name":"United Arab Emirates",
1034
+ "value":201.1
1035
+ },
1036
+ {
1037
+ "name":"Malaysia",
1038
+ "value":227.5
1039
+ },
1040
+ {
1041
+ "name":"Kazakhstan",
1042
+ "value":236.2
1043
+ },
1044
+ {
1045
+ "name":"Thailand",
1046
+ "value":272
1047
+ },
1048
+ {
1049
+ "name":"Taiwan",
1050
+ "value":276.7
1051
+ },
1052
+ {
1053
+ "name":"Indonesia",
1054
+ "value":453
1055
+ },
1056
+ {
1057
+ "name":"Saudi Arabia",
1058
+ "value":494.8
1059
+ },
1060
+ {
1061
+ "name":"Japan",
1062
+ "value":1278.9
1063
+ },
1064
+ {
1065
+ "name":"China",
1066
+ "value":10540.8
1067
+ },
1068
+ {
1069
+ "name":"India",
1070
+ "value":2341.9
1071
+ },
1072
+ {
1073
+ "name":"Russia",
1074
+ "value":1766.4
1075
+ },
1076
+ {
1077
+ "name":"Iran",
1078
+ "value":618.2
1079
+ },
1080
+ {
1081
+ "name":"Korea",
1082
+ "value":610.1
1083
+ }
1084
+ ]
1085
+ }
1086
+ ]
1087
+ }
1088
+ SAMPLE5={
1089
+ "chart":{
1090
+ "type":"column"
1091
+ },
1092
+ "title":{
1093
+ "align":"left",
1094
+ "text":"Browser market shares. January, 2022"
1095
+ },
1096
+ "subtitle":{
1097
+ "align":"left",
1098
+ "text":"Click the columns to view versions. Source: <a href=\"http://statcounter.com\" target=\"_blank\">statcounter.com</a>"
1099
+ },
1100
+ "accessibility":{
1101
+ "announceNewData":{
1102
+ "enabled":True
1103
+ }
1104
+ },
1105
+ "xAxis":{
1106
+ "type":"category"
1107
+ },
1108
+ "yAxis":{
1109
+ "title":{
1110
+ "text":"Total percent market share"
1111
+ }
1112
+ },
1113
+ "legend":{
1114
+ "enabled":False
1115
+ },
1116
+ "plotOptions":{
1117
+ "series":{
1118
+ "borderWidth":0,
1119
+ "dataLabels":{
1120
+ "enabled":True,
1121
+ "format":"{point.y:.1f}%"
1122
+ }
1123
+ }
1124
+ },
1125
+ "tooltip":{
1126
+ "headerFormat":"<span style=\"font-size:11px\">{series.name}</span><br>",
1127
+ "pointFormat":"<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>"
1128
+ },
1129
+ "series":[
1130
+ {
1131
+ "name":"Browsers",
1132
+ "colorByPoint":True,
1133
+ "data":[
1134
+ {
1135
+ "name":"Chrome",
1136
+ "y":63.06,
1137
+ "drilldown":"Chrome"
1138
+ },
1139
+ {
1140
+ "name":"Safari",
1141
+ "y":19.84,
1142
+ "drilldown":"Safari"
1143
+ },
1144
+ {
1145
+ "name":"Firefox",
1146
+ "y":4.18,
1147
+ "drilldown":"Firefox"
1148
+ },
1149
+ {
1150
+ "name":"Edge",
1151
+ "y":4.12,
1152
+ "drilldown":"Edge"
1153
+ },
1154
+ {
1155
+ "name":"Opera",
1156
+ "y":2.33,
1157
+ "drilldown":"Opera"
1158
+ },
1159
+ {
1160
+ "name":"Internet Explorer",
1161
+ "y":0.45,
1162
+ "drilldown":"Internet Explorer"
1163
+ },
1164
+ {
1165
+ "name":"Other",
1166
+ "y":1.582,
1167
+ "drilldown":"null"
1168
+ }
1169
+ ]
1170
+ }
1171
+ ],
1172
+ "drilldown":{
1173
+ "breadcrumbs":{
1174
+ "position":{
1175
+ "align":"right"
1176
+ }
1177
+ },
1178
+ "series":[
1179
+ {
1180
+ "name":"Chrome",
1181
+ "id":"Chrome",
1182
+ "data":[
1183
+ [
1184
+ "v65.0",
1185
+ 0.1
1186
+ ],
1187
+ [
1188
+ "v64.0",
1189
+ 1.3
1190
+ ],
1191
+ [
1192
+ "v63.0",
1193
+ 53.02
1194
+ ],
1195
+ [
1196
+ "v62.0",
1197
+ 1.4
1198
+ ],
1199
+ [
1200
+ "v61.0",
1201
+ 0.88
1202
+ ],
1203
+ [
1204
+ "v60.0",
1205
+ 0.56
1206
+ ],
1207
+ [
1208
+ "v59.0",
1209
+ 0.45
1210
+ ],
1211
+ [
1212
+ "v58.0",
1213
+ 0.49
1214
+ ],
1215
+ [
1216
+ "v57.0",
1217
+ 0.32
1218
+ ],
1219
+ [
1220
+ "v56.0",
1221
+ 0.29
1222
+ ],
1223
+ [
1224
+ "v55.0",
1225
+ 0.79
1226
+ ],
1227
+ [
1228
+ "v54.0",
1229
+ 0.18
1230
+ ],
1231
+ [
1232
+ "v51.0",
1233
+ 0.13
1234
+ ],
1235
+ [
1236
+ "v49.0",
1237
+ 2.16
1238
+ ],
1239
+ [
1240
+ "v48.0",
1241
+ 0.13
1242
+ ],
1243
+ [
1244
+ "v47.0",
1245
+ 0.11
1246
+ ],
1247
+ [
1248
+ "v43.0",
1249
+ 0.17
1250
+ ],
1251
+ [
1252
+ "v29.0",
1253
+ 0.26
1254
+ ]
1255
+ ]
1256
+ },
1257
+ {
1258
+ "name":"Firefox",
1259
+ "id":"Firefox",
1260
+ "data":[
1261
+ [
1262
+ "v58.0",
1263
+ 1.02
1264
+ ],
1265
+ [
1266
+ "v57.0",
1267
+ 7.36
1268
+ ],
1269
+ [
1270
+ "v56.0",
1271
+ 0.35
1272
+ ],
1273
+ [
1274
+ "v55.0",
1275
+ 0.11
1276
+ ],
1277
+ [
1278
+ "v54.0",
1279
+ 0.1
1280
+ ],
1281
+ [
1282
+ "v52.0",
1283
+ 0.95
1284
+ ],
1285
+ [
1286
+ "v51.0",
1287
+ 0.15
1288
+ ],
1289
+ [
1290
+ "v50.0",
1291
+ 0.1
1292
+ ],
1293
+ [
1294
+ "v48.0",
1295
+ 0.31
1296
+ ],
1297
+ [
1298
+ "v47.0",
1299
+ 0.12
1300
+ ]
1301
+ ]
1302
+ },
1303
+ {
1304
+ "name":"Internet Explorer",
1305
+ "id":"Internet Explorer",
1306
+ "data":[
1307
+ [
1308
+ "v11.0",
1309
+ 6.2
1310
+ ],
1311
+ [
1312
+ "v10.0",
1313
+ 0.29
1314
+ ],
1315
+ [
1316
+ "v9.0",
1317
+ 0.27
1318
+ ],
1319
+ [
1320
+ "v8.0",
1321
+ 0.47
1322
+ ]
1323
+ ]
1324
+ },
1325
+ {
1326
+ "name":"Safari",
1327
+ "id":"Safari",
1328
+ "data":[
1329
+ [
1330
+ "v11.0",
1331
+ 3.39
1332
+ ],
1333
+ [
1334
+ "v10.1",
1335
+ 0.96
1336
+ ],
1337
+ [
1338
+ "v10.0",
1339
+ 0.36
1340
+ ],
1341
+ [
1342
+ "v9.1",
1343
+ 0.54
1344
+ ],
1345
+ [
1346
+ "v9.0",
1347
+ 0.13
1348
+ ],
1349
+ [
1350
+ "v5.1",
1351
+ 0.2
1352
+ ]
1353
+ ]
1354
+ },
1355
+ {
1356
+ "name":"Edge",
1357
+ "id":"Edge",
1358
+ "data":[
1359
+ [
1360
+ "v16",
1361
+ 2.6
1362
+ ],
1363
+ [
1364
+ "v15",
1365
+ 0.92
1366
+ ],
1367
+ [
1368
+ "v14",
1369
+ 0.4
1370
+ ],
1371
+ [
1372
+ "v13",
1373
+ 0.1
1374
+ ]
1375
+ ]
1376
+ },
1377
+ {
1378
+ "name":"Opera",
1379
+ "id":"Opera",
1380
+ "data":[
1381
+ [
1382
+ "v50.0",
1383
+ 0.96
1384
+ ],
1385
+ [
1386
+ "v49.0",
1387
+ 0.82
1388
+ ],
1389
+ [
1390
+ "v12.1",
1391
+ 0.14
1392
+ ]
1393
+ ]
1394
+ }
1395
+ ]
1396
+ }
1397
+ }
1398
+ SAMPLE6={
1399
+ "chart":{
1400
+ "type":"tilemap",
1401
+ "inverted":True,
1402
+ "height":"80%"
1403
+ },
1404
+ "accessibility":{
1405
+ "description":"A tile map represents the states of the USA by population in 2016. The hexagonal tiles are positioned to geographically echo the map of the USA. A color-coded legend states the population levels as below 1 million (beige), 1 to 5 million (orange), 5 to 20 million (pink) and above 20 million (hot pink). The chart is interactive, and the individual state data points are displayed upon hovering. Three states have a population of above 20 million: California (39.3 million), Texas (27.9 million) and Florida (20.6 million). The northern US region from Massachusetts in the Northwest to Illinois in the Midwest contains the highest concentration of states with a population of 5 to 20 million people. The southern US region from South Carolina in the Southeast to New Mexico in the Southwest contains the highest concentration of states with a population of 1 to 5 million people. 6 states have a population of less than 1 million people; these include Alaska, Delaware, Wyoming, North Dakota, South Dakota and Vermont. The state with the lowest population is Wyoming in the Northwest with 584,153 people.",
1406
+ "screenReaderSection":{
1407
+ "beforeChartFormat":"<h5>{chartTitle}</h5>""+""<div>{chartSubtitle}</div>""+""<div>{chartLongdesc}</div>""+""<div>{viewTableButton}</div>"
1408
+ },
1409
+ "point":{
1410
+ "valueDescriptionFormat":"{index}. {xDescription}, {point.value}."
1411
+ }
1412
+ },
1413
+ "title":{
1414
+ "text":"U.S. states by population in 2016"
1415
+ },
1416
+ "subtitle":{
1417
+ "text":"Source:<a href=\"https://simple.wikipedia.org/wiki/List_of_U.S._states_by_population\">Wikipedia</a>"
1418
+ },
1419
+ "xAxis":{
1420
+ "visible":False
1421
+ },
1422
+ "yAxis":{
1423
+ "visible":False
1424
+ },
1425
+ "colorAxis":{
1426
+ "dataClasses":[
1427
+ {
1428
+ "from":0,
1429
+ "to":1000000,
1430
+ "color":"#F9EDB3",
1431
+ "name":"< 1M"
1432
+ },
1433
+ {
1434
+ "from":1000000,
1435
+ "to":5000000,
1436
+ "color":"#FFC428",
1437
+ "name":"1M - 5M"
1438
+ },
1439
+ {
1440
+ "from":5000000,
1441
+ "to":20000000,
1442
+ "color":"#FF7987",
1443
+ "name":"5M - 20M"
1444
+ },
1445
+ {
1446
+ "from":20000000,
1447
+ "color":"#FF2371",
1448
+ "name":"> 20M"
1449
+ }
1450
+ ]
1451
+ },
1452
+ "tooltip":{
1453
+ "headerFormat":"",
1454
+ "pointFormat":"The population of <b> {point.name}</b> is <b>{point.value}</b>"
1455
+ },
1456
+ "plotOptions":{
1457
+ "series":{
1458
+ "dataLabels":{
1459
+ "enabled":True,
1460
+ "format":"{point.hc-a2}",
1461
+ "color":"#000000",
1462
+ "style":{
1463
+ "textOutline":False
1464
+ }
1465
+ }
1466
+ }
1467
+ },
1468
+ "series":[
1469
+ {
1470
+ "name":"",
1471
+ "data":[
1472
+ {
1473
+ "hc-a2":"AL",
1474
+ "name":"Alabama",
1475
+ "region":"South",
1476
+ "x":6,
1477
+ "y":7,
1478
+ "value":4849377
1479
+ },
1480
+ {
1481
+ "hc-a2":"AK",
1482
+ "name":"Alaska",
1483
+ "region":"West",
1484
+ "x":0,
1485
+ "y":0,
1486
+ "value":737732
1487
+ },
1488
+ {
1489
+ "hc-a2":"AZ",
1490
+ "name":"Arizona",
1491
+ "region":"West",
1492
+ "x":5,
1493
+ "y":3,
1494
+ "value":6745408
1495
+ },
1496
+ {
1497
+ "hc-a2":"AR",
1498
+ "name":"Arkansas",
1499
+ "region":"South",
1500
+ "x":5,
1501
+ "y":6,
1502
+ "value":2994079
1503
+ },
1504
+ {
1505
+ "hc-a2":"CA",
1506
+ "name":"California",
1507
+ "region":"West",
1508
+ "x":5,
1509
+ "y":2,
1510
+ "value":39250017
1511
+ },
1512
+ {
1513
+ "hc-a2":"CO",
1514
+ "name":"Colorado",
1515
+ "region":"West",
1516
+ "x":4,
1517
+ "y":3,
1518
+ "value":5540545
1519
+ },
1520
+ {
1521
+ "hc-a2":"CT",
1522
+ "name":"Connecticut",
1523
+ "region":"Northeast",
1524
+ "x":3,
1525
+ "y":11,
1526
+ "value":3596677
1527
+ },
1528
+ {
1529
+ "hc-a2":"DE",
1530
+ "name":"Delaware",
1531
+ "region":"South",
1532
+ "x":4,
1533
+ "y":9,
1534
+ "value":935614
1535
+ },
1536
+ {
1537
+ "hc-a2":"DC",
1538
+ "name":"District of Columbia",
1539
+ "region":"South",
1540
+ "x":4,
1541
+ "y":10,
1542
+ "value":7288000
1543
+ },
1544
+ {
1545
+ "hc-a2":"FL",
1546
+ "name":"Florida",
1547
+ "region":"South",
1548
+ "x":8,
1549
+ "y":8,
1550
+ "value":20612439
1551
+ },
1552
+ {
1553
+ "hc-a2":"GA",
1554
+ "name":"Georgia",
1555
+ "region":"South",
1556
+ "x":7,
1557
+ "y":8,
1558
+ "value":10310371
1559
+ },
1560
+ {
1561
+ "hc-a2":"HI",
1562
+ "name":"Hawaii",
1563
+ "region":"West",
1564
+ "x":8,
1565
+ "y":0,
1566
+ "value":1419561
1567
+ },
1568
+ {
1569
+ "hc-a2":"ID",
1570
+ "name":"Idaho",
1571
+ "region":"West",
1572
+ "x":3,
1573
+ "y":2,
1574
+ "value":1634464
1575
+ },
1576
+ {
1577
+ "hc-a2":"IL",
1578
+ "name":"Illinois",
1579
+ "region":"Midwest",
1580
+ "x":3,
1581
+ "y":6,
1582
+ "value":12801539
1583
+ },
1584
+ {
1585
+ "hc-a2":"IN",
1586
+ "name":"Indiana",
1587
+ "region":"Midwest",
1588
+ "x":3,
1589
+ "y":7,
1590
+ "value":6596855
1591
+ },
1592
+ {
1593
+ "hc-a2":"IA",
1594
+ "name":"Iowa",
1595
+ "region":"Midwest",
1596
+ "x":3,
1597
+ "y":5,
1598
+ "value":3107126
1599
+ },
1600
+ {
1601
+ "hc-a2":"KS",
1602
+ "name":"Kansas",
1603
+ "region":"Midwest",
1604
+ "x":5,
1605
+ "y":5,
1606
+ "value":2904021
1607
+ },
1608
+ {
1609
+ "hc-a2":"KY",
1610
+ "name":"Kentucky",
1611
+ "region":"South",
1612
+ "x":4,
1613
+ "y":6,
1614
+ "value":4413457
1615
+ },
1616
+ {
1617
+ "hc-a2":"LA",
1618
+ "name":"Louisiana",
1619
+ "region":"South",
1620
+ "x":6,
1621
+ "y":5,
1622
+ "value":4649676
1623
+ },
1624
+ {
1625
+ "hc-a2":"ME",
1626
+ "name":"Maine",
1627
+ "region":"Northeast",
1628
+ "x":0,
1629
+ "y":11,
1630
+ "value":1330089
1631
+ },
1632
+ {
1633
+ "hc-a2":"MD",
1634
+ "name":"Maryland",
1635
+ "region":"South",
1636
+ "x":4,
1637
+ "y":8,
1638
+ "value":6016447
1639
+ },
1640
+ {
1641
+ "hc-a2":"MA",
1642
+ "name":"Massachusetts",
1643
+ "region":"Northeast",
1644
+ "x":2,
1645
+ "y":10,
1646
+ "value":6811779
1647
+ },
1648
+ {
1649
+ "hc-a2":"MI",
1650
+ "name":"Michigan",
1651
+ "region":"Midwest",
1652
+ "x":2,
1653
+ "y":7,
1654
+ "value":9928301
1655
+ },
1656
+ {
1657
+ "hc-a2":"MN",
1658
+ "name":"Minnesota",
1659
+ "region":"Midwest",
1660
+ "x":2,
1661
+ "y":4,
1662
+ "value":5519952
1663
+ },
1664
+ {
1665
+ "hc-a2":"MS",
1666
+ "name":"Mississippi",
1667
+ "region":"South",
1668
+ "x":6,
1669
+ "y":6,
1670
+ "value":2984926
1671
+ },
1672
+ {
1673
+ "hc-a2":"MO",
1674
+ "name":"Missouri",
1675
+ "region":"Midwest",
1676
+ "x":4,
1677
+ "y":5,
1678
+ "value":6093000
1679
+ },
1680
+ {
1681
+ "hc-a2":"MT",
1682
+ "name":"Montana",
1683
+ "region":"West",
1684
+ "x":2,
1685
+ "y":2,
1686
+ "value":1023579
1687
+ },
1688
+ {
1689
+ "hc-a2":"NE",
1690
+ "name":"Nebraska",
1691
+ "region":"Midwest",
1692
+ "x":4,
1693
+ "y":4,
1694
+ "value":1881503
1695
+ },
1696
+ {
1697
+ "hc-a2":"NV",
1698
+ "name":"Nevada",
1699
+ "region":"West",
1700
+ "x":4,
1701
+ "y":2,
1702
+ "value":2839099
1703
+ },
1704
+ {
1705
+ "hc-a2":"NH",
1706
+ "name":"New Hampshire",
1707
+ "region":"Northeast",
1708
+ "x":1,
1709
+ "y":11,
1710
+ "value":1326813
1711
+ },
1712
+ {
1713
+ "hc-a2":"NJ",
1714
+ "name":"New Jersey",
1715
+ "region":"Northeast",
1716
+ "x":3,
1717
+ "y":10,
1718
+ "value":8944469
1719
+ },
1720
+ {
1721
+ "hc-a2":"NM",
1722
+ "name":"New Mexico",
1723
+ "region":"West",
1724
+ "x":6,
1725
+ "y":3,
1726
+ "value":2085572
1727
+ },
1728
+ {
1729
+ "hc-a2":"NY",
1730
+ "name":"New York",
1731
+ "region":"Northeast",
1732
+ "x":2,
1733
+ "y":9,
1734
+ "value":19745289
1735
+ },
1736
+ {
1737
+ "hc-a2":"NC",
1738
+ "name":"North Carolina",
1739
+ "region":"South",
1740
+ "x":5,
1741
+ "y":9,
1742
+ "value":10146788
1743
+ },
1744
+ {
1745
+ "hc-a2":"ND",
1746
+ "name":"North Dakota",
1747
+ "region":"Midwest",
1748
+ "x":2,
1749
+ "y":3,
1750
+ "value":739482
1751
+ },
1752
+ {
1753
+ "hc-a2":"OH",
1754
+ "name":"Ohio",
1755
+ "region":"Midwest",
1756
+ "x":3,
1757
+ "y":8,
1758
+ "value":11614373
1759
+ },
1760
+ {
1761
+ "hc-a2":"OK",
1762
+ "name":"Oklahoma",
1763
+ "region":"South",
1764
+ "x":6,
1765
+ "y":4,
1766
+ "value":3878051
1767
+ },
1768
+ {
1769
+ "hc-a2":"OR",
1770
+ "name":"Oregon",
1771
+ "region":"West",
1772
+ "x":4,
1773
+ "y":1,
1774
+ "value":3970239
1775
+ },
1776
+ {
1777
+ "hc-a2":"PA",
1778
+ "name":"Pennsylvania",
1779
+ "region":"Northeast",
1780
+ "x":3,
1781
+ "y":9,
1782
+ "value":12784227
1783
+ },
1784
+ {
1785
+ "hc-a2":"RI",
1786
+ "name":"Rhode Island",
1787
+ "region":"Northeast",
1788
+ "x":2,
1789
+ "y":11,
1790
+ "value":1055173
1791
+ },
1792
+ {
1793
+ "hc-a2":"SC",
1794
+ "name":"South Carolina",
1795
+ "region":"South",
1796
+ "x":6,
1797
+ "y":8,
1798
+ "value":4832482
1799
+ },
1800
+ {
1801
+ "hc-a2":"SD",
1802
+ "name":"South Dakota",
1803
+ "region":"Midwest",
1804
+ "x":3,
1805
+ "y":4,
1806
+ "value":853175
1807
+ },
1808
+ {
1809
+ "hc-a2":"TN",
1810
+ "name":"Tennessee",
1811
+ "region":"South",
1812
+ "x":5,
1813
+ "y":7,
1814
+ "value":6651194
1815
+ },
1816
+ {
1817
+ "hc-a2":"TX",
1818
+ "name":"Texas",
1819
+ "region":"South",
1820
+ "x":7,
1821
+ "y":4,
1822
+ "value":27862596
1823
+ },
1824
+ {
1825
+ "hc-a2":"UT",
1826
+ "name":"Utah",
1827
+ "region":"West",
1828
+ "x":5,
1829
+ "y":4,
1830
+ "value":2942902
1831
+ },
1832
+ {
1833
+ "hc-a2":"VT",
1834
+ "name":"Vermont",
1835
+ "region":"Northeast",
1836
+ "x":1,
1837
+ "y":10,
1838
+ "value":626011
1839
+ },
1840
+ {
1841
+ "hc-a2":"VA",
1842
+ "name":"Virginia",
1843
+ "region":"South",
1844
+ "x":5,
1845
+ "y":8,
1846
+ "value":8411808
1847
+ },
1848
+ {
1849
+ "hc-a2":"WA",
1850
+ "name":"Washington",
1851
+ "region":"West",
1852
+ "x":2,
1853
+ "y":1,
1854
+ "value":7288000
1855
+ },
1856
+ {
1857
+ "hc-a2":"WV",
1858
+ "name":"West Virginia",
1859
+ "region":"South",
1860
+ "x":4,
1861
+ "y":7,
1862
+ "value":1850326
1863
+ },
1864
+ {
1865
+ "hc-a2":"WI",
1866
+ "name":"Wisconsin",
1867
+ "region":"Midwest",
1868
+ "x":2,
1869
+ "y":5,
1870
+ "value":5778708
1871
+ },
1872
+ {
1873
+ "hc-a2":"WY",
1874
+ "name":"Wyoming",
1875
+ "region":"West",
1876
+ "x":3,
1877
+ "y":3,
1878
+ "value":584153
1879
+ }
1880
+ ]
1881
+ }
1882
+ ]
1883
+ }
1884
+ SAMPLE7={
1885
+ "chart":{
1886
+ "type":"pie"
1887
+ },
1888
+ "title":{
1889
+ "text":"Browser market shares. January, 2022"
1890
+ },
1891
+ "subtitle":{
1892
+ "text":"Click the slices to view versions. Source: <a href=\"http://statcounter.com\" target=\"_blank\">statcounter.com</a>"
1893
+ },
1894
+ "accessibility":{
1895
+ "announceNewData":{
1896
+ "enabled":True
1897
+ },
1898
+ "point":{
1899
+ "valueSuffix":"%"
1900
+ }
1901
+ },
1902
+ "plotOptions":{
1903
+ "series":{
1904
+ "dataLabels":{
1905
+ "enabled":True,
1906
+ "format":"{point.name}: {point.y:.1f}%"
1907
+ }
1908
+ }
1909
+ },
1910
+ "tooltip":{
1911
+ "headerFormat":"<span style=\"font-size:11px\">{series.name}</span><br>",
1912
+ "pointFormat":"<span style=\"color:{point.color}\">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>"
1913
+ },
1914
+ "series":[
1915
+ {
1916
+ "name":"Browsers",
1917
+ "colorByPoint":True,
1918
+ "data":[
1919
+ {
1920
+ "name":"Chrome",
1921
+ "y":61.04,
1922
+ "drilldown":"Chrome"
1923
+ },
1924
+ {
1925
+ "name":"Safari",
1926
+ "y":9.47,
1927
+ "drilldown":"Safari"
1928
+ },
1929
+ {
1930
+ "name":"Edge",
1931
+ "y":9.32,
1932
+ "drilldown":"Edge"
1933
+ },
1934
+ {
1935
+ "name":"Firefox",
1936
+ "y":8.15,
1937
+ "drilldown":"Firefox"
1938
+ },
1939
+ {
1940
+ "name":"Other",
1941
+ "y":11.02,
1942
+ "drilldown":"null"
1943
+ }
1944
+ ]
1945
+ }
1946
+ ],
1947
+ "drilldown":{
1948
+ "series":[
1949
+ {
1950
+ "name":"Chrome",
1951
+ "id":"Chrome",
1952
+ "data":[
1953
+ [
1954
+ "v97.0",
1955
+ 36.89
1956
+ ],
1957
+ [
1958
+ "v96.0",
1959
+ 18.16
1960
+ ],
1961
+ [
1962
+ "v95.0",
1963
+ 0.54
1964
+ ],
1965
+ [
1966
+ "v94.0",
1967
+ 0.7
1968
+ ],
1969
+ [
1970
+ "v93.0",
1971
+ 0.8
1972
+ ],
1973
+ [
1974
+ "v92.0",
1975
+ 0.41
1976
+ ],
1977
+ [
1978
+ "v91.0",
1979
+ 0.31
1980
+ ],
1981
+ [
1982
+ "v90.0",
1983
+ 0.13
1984
+ ],
1985
+ [
1986
+ "v89.0",
1987
+ 0.14
1988
+ ],
1989
+ [
1990
+ "v88.0",
1991
+ 0.1
1992
+ ],
1993
+ [
1994
+ "v87.0",
1995
+ 0.35
1996
+ ],
1997
+ [
1998
+ "v86.0",
1999
+ 0.17
2000
+ ],
2001
+ [
2002
+ "v85.0",
2003
+ 0.18
2004
+ ],
2005
+ [
2006
+ "v84.0",
2007
+ 0.17
2008
+ ],
2009
+ [
2010
+ "v83.0",
2011
+ 0.21
2012
+ ],
2013
+ [
2014
+ "v81.0",
2015
+ 0.1
2016
+ ],
2017
+ [
2018
+ "v80.0",
2019
+ 0.16
2020
+ ],
2021
+ [
2022
+ "v79.0",
2023
+ 0.43
2024
+ ],
2025
+ [
2026
+ "v78.0",
2027
+ 0.11
2028
+ ],
2029
+ [
2030
+ "v76.0",
2031
+ 0.16
2032
+ ],
2033
+ [
2034
+ "v75.0",
2035
+ 0.15
2036
+ ],
2037
+ [
2038
+ "v72.0",
2039
+ 0.14
2040
+ ],
2041
+ [
2042
+ "v70.0",
2043
+ 0.11
2044
+ ],
2045
+ [
2046
+ "v69.0",
2047
+ 0.13
2048
+ ],
2049
+ [
2050
+ "v56.0",
2051
+ 0.12
2052
+ ],
2053
+ [
2054
+ "v49.0",
2055
+ 0.17
2056
+ ]
2057
+ ]
2058
+ },
2059
+ {
2060
+ "name":"Safari",
2061
+ "id":"Safari",
2062
+ "data":[
2063
+ [
2064
+ "v15.3",
2065
+ 0.1
2066
+ ],
2067
+ [
2068
+ "v15.2",
2069
+ 2.01
2070
+ ],
2071
+ [
2072
+ "v15.1",
2073
+ 2.29
2074
+ ],
2075
+ [
2076
+ "v15.0",
2077
+ 0.49
2078
+ ],
2079
+ [
2080
+ "v14.1",
2081
+ 2.48
2082
+ ],
2083
+ [
2084
+ "v14.0",
2085
+ 0.64
2086
+ ],
2087
+ [
2088
+ "v13.1",
2089
+ 1.17
2090
+ ],
2091
+ [
2092
+ "v13.0",
2093
+ 0.13
2094
+ ],
2095
+ [
2096
+ "v12.1",
2097
+ 0.16
2098
+ ]
2099
+ ]
2100
+ },
2101
+ {
2102
+ "name":"Edge",
2103
+ "id":"Edge",
2104
+ "data":[
2105
+ [
2106
+ "v97",
2107
+ 6.62
2108
+ ],
2109
+ [
2110
+ "v96",
2111
+ 2.55
2112
+ ],
2113
+ [
2114
+ "v95",
2115
+ 0.15
2116
+ ]
2117
+ ]
2118
+ },
2119
+ {
2120
+ "name":"Firefox",
2121
+ "id":"Firefox",
2122
+ "data":[
2123
+ [
2124
+ "v96.0",
2125
+ 4.17
2126
+ ],
2127
+ [
2128
+ "v95.0",
2129
+ 3.33
2130
+ ],
2131
+ [
2132
+ "v94.0",
2133
+ 0.11
2134
+ ],
2135
+ [
2136
+ "v91.0",
2137
+ 0.23
2138
+ ],
2139
+ [
2140
+ "v78.0",
2141
+ 0.16
2142
+ ],
2143
+ [
2144
+ "v52.0",
2145
+ 0.15
2146
+ ]
2147
+ ]
2148
+ }
2149
+ ]
2150
+ }
2151
+ }
2152
+ SAMPLE8={
2153
+ "title":{
2154
+ "text":"Sales of petroleum products March, Norway",
2155
+ "align":"left"
2156
+ },
2157
+ "xAxis":{
2158
+ "categories":[
2159
+ "Jet fuel",
2160
+ "Duty-free diesel",
2161
+ "Petrol",
2162
+ "Diesel",
2163
+ "Gas oil"
2164
+ ]
2165
+ },
2166
+ "yAxis":{
2167
+ "title":{
2168
+ "text":"Million liter"
2169
+ }
2170
+ },
2171
+ "labels":{
2172
+ "items":[
2173
+ {
2174
+ "html":"Total liter",
2175
+ "style":{
2176
+ "left":"50px",
2177
+ "top":"18px",
2178
+ "color":"black"
2179
+ }
2180
+ }
2181
+ ]
2182
+ },
2183
+ "series":[
2184
+ {
2185
+ "type":"column",
2186
+ "name":"2020",
2187
+ "data":[
2188
+ 59,
2189
+ 83,
2190
+ 65,
2191
+ 228,
2192
+ 184
2193
+ ]
2194
+ },
2195
+ {
2196
+ "type":"column",
2197
+ "name":"2021",
2198
+ "data":[
2199
+ 24,
2200
+ 79,
2201
+ 72,
2202
+ 240,
2203
+ 167
2204
+ ]
2205
+ },
2206
+ {
2207
+ "type":"column",
2208
+ "name":"2022",
2209
+ "data":[
2210
+ 58,
2211
+ 88,
2212
+ 75,
2213
+ 250,
2214
+ 176
2215
+ ]
2216
+ },
2217
+ {
2218
+ "type":"spline",
2219
+ "name":"Average",
2220
+ "data":[
2221
+ 47,
2222
+ 83.33,
2223
+ 70.66,
2224
+ 239.33,
2225
+ 175.66
2226
+ ],
2227
+ "marker":{
2228
+ "lineWidth":2,
2229
+ "fillColor":"black",
2230
+ }
2231
+ },
2232
+ {
2233
+ "type":"pie",
2234
+ "name":"Liter",
2235
+ "data":[
2236
+ {
2237
+ "name":"2020",
2238
+ "y":619,
2239
+ "color": "#7cb4ec"
2240
+
2241
+ },
2242
+ {
2243
+ "name":"2021",
2244
+ "y":586,
2245
+ "color": "#434348"
2246
+ },
2247
+ {
2248
+ "name":"2022",
2249
+ "y":647,
2250
+ "color":"#90ed7d"
2251
+ }
2252
+ ],
2253
+ "center":[
2254
+ 80,
2255
+ 70
2256
+ ],
2257
+ "size":100,
2258
+ "showInLegend":False,
2259
+ "dataLabels":{
2260
+ "enabled":False
2261
+ }
2262
+ }
2263
+ ]
2264
+ }
2265
+ SAMPLE9={
2266
+ "chart":{
2267
+ "type":"solidgauge",
2268
+ "height":"90%"
2269
+ },
2270
+ "title":{
2271
+ "text":"Activity",
2272
+ "style":{
2273
+ "fontSize":"24px"
2274
+ }
2275
+ },
2276
+ "tooltip":{
2277
+ "borderWidth":0,
2278
+ "backgroundColor":"none",
2279
+ "shadow":False,
2280
+ "style":{
2281
+ "fontSize":"16px"
2282
+ },
2283
+ "valueSuffix":"%",
2284
+ "pointFormat":"{series.name}<br><span style=\"font-size:2em; color: {point.color}; font-weight: bold\">{point.y}</span>",
2285
+ "positioner":{
2286
+ "x":"50px",
2287
+ "y":100
2288
+ }
2289
+ },
2290
+ "pane":{
2291
+ "startAngle":0,
2292
+ "endAngle":360,
2293
+ "background":[
2294
+ {
2295
+ "radius":"112%",
2296
+ "innerRadius":"88%",
2297
+ "borderWidth":0
2298
+ },
2299
+ {
2300
+ "radius":"87%",
2301
+ "innerRadius":"63%",
2302
+ "borderWidth":0
2303
+ },
2304
+ {
2305
+ "radius":"62%",
2306
+ "innerRadius":"38%",
2307
+ "borderWidth":0
2308
+ }
2309
+ ]
2310
+ },
2311
+ "yAxis":{
2312
+ "min":0,
2313
+ "max":100,
2314
+ "lineWidth":0,
2315
+ "tickPositions":[
2316
+
2317
+ ]
2318
+ },
2319
+ "plotOptions":{
2320
+ "solidgauge":{
2321
+ "dataLabels":{
2322
+ "enabled":False
2323
+ },
2324
+ "linecap":"round",
2325
+ "stickyTracking":False,
2326
+ "rounded":True
2327
+ }
2328
+ },
2329
+ "series":[
2330
+ {
2331
+ "name":"Move",
2332
+ "data":[
2333
+ {
2334
+ "color":"lightgreen",
2335
+ "radius":"112%",
2336
+ "innerRadius":"88%",
2337
+ "y":80
2338
+ }
2339
+ ]
2340
+ },
2341
+ {
2342
+ "name":"Exercise",
2343
+ "data":[
2344
+ {
2345
+ "color":"red",
2346
+ "radius":"87%",
2347
+ "innerRadius":"63%",
2348
+ "y":65
2349
+ }
2350
+ ]
2351
+ },
2352
+ {
2353
+ "name":"Stand",
2354
+ "data":[
2355
+ {
2356
+ "color":"blue",
2357
+ "radius":"62%",
2358
+ "innerRadius":"38%",
2359
+ "y":50
2360
+ }
2361
+ ]
2362
+ }
2363
+ ]
2364
+ }
2365
+ SAMPLE10={
2366
+
2367
+ "chart": {
2368
+ "type": 'gauge',
2369
+ "plotBackgroundColor": "white",
2370
+ "plotBackgroundImage": "white",
2371
+ "plotBorderWidth": 0,
2372
+ "plotShadow": False,
2373
+ "height": '80%'
2374
+ },
2375
+
2376
+ "title": {
2377
+ "text": 'Speedometer'
2378
+ },
2379
+
2380
+ "pane": {
2381
+ "startAngle": -90,
2382
+ "endAngle": 89.9,
2383
+ "background": "null",
2384
+ "center": ['50%', '75%'],
2385
+ "size": '110%'
2386
+ },
2387
+
2388
+ "yAxis": {
2389
+ "min": 0,
2390
+ "max": 200,
2391
+ "tickPixelInterval": 72,
2392
+ "tickPosition": 'inside',
2393
+ "tickColor": '#FFFFFF',
2394
+ "tickLength": 20,
2395
+ "tickWidth": 2,
2396
+ "minorTickInterval": "null",
2397
+ "labels": {
2398
+ "distance": 20,
2399
+ "style": {
2400
+ "fontSize": '14px'
2401
+ }
2402
+ },
2403
+ "plotBands": [{
2404
+ "from": 0,
2405
+ "to": 120,
2406
+ "color": '#55BF3B',
2407
+ "thickness": 20
2408
+ }, {
2409
+ "from": 120,
2410
+ "to": 160,
2411
+ "color": '#DDDF0D',
2412
+ "thickness": 20
2413
+ }, {
2414
+ "from": 160,
2415
+ "to": 200,
2416
+ "color": '#DF5353',
2417
+ "thickness": 20
2418
+ }]
2419
+ },
2420
+
2421
+ "series": [{
2422
+ "name": 'Speed',
2423
+ "data": [80],
2424
+ "tooltip": {
2425
+ "valueSuffix": ' km/h'
2426
+ },
2427
+ "dataLabels": {
2428
+ "format": '{y} km/h',
2429
+ "borderWidth": 0,
2430
+ "color": '#333333',
2431
+ "style": {
2432
+ "fontSize": '16px'
2433
+ }
2434
+ },
2435
+ "dial": {
2436
+ "radius": '80%',
2437
+ "backgroundColor": 'gray',
2438
+ "baseWidth": 12,
2439
+ "baseLength": '0%',
2440
+ "rearLength": '0%'
2441
+ },
2442
+ "pivot": {
2443
+ "backgroundColor": 'gray',
2444
+ "radius": 6
2445
+ }
2446
+ }]
2447
+
2448
+ }
2449
+ SAMPLE11={
2450
+
2451
+ "title": {
2452
+ "text": 'Highcharts Dependency Wheel'
2453
+ },
2454
+
2455
+ "accessibility": {
2456
+ "point": {
2457
+ "valueDescriptionFormat": '{index}. From {point.from} to {point.to}: {point.weight}.'
2458
+ }
2459
+ },
2460
+
2461
+ "series": [{
2462
+ "keys": ['from', 'to', 'weight'],
2463
+ "data": [
2464
+ ['Brazil', 'Portugal', 5],
2465
+ ['Brazil', 'France', 1],
2466
+ ['Brazil', 'Spain', 1],
2467
+ ['Brazil', 'England', 1],
2468
+ ['Canada', 'Portugal', 1],
2469
+ ['Canada', 'France', 5],
2470
+ ['Canada', 'England', 1],
2471
+ ['Mexico', 'Portugal', 1],
2472
+ ['Mexico', 'France', 1],
2473
+ ['Mexico', 'Spain', 5],
2474
+ ['Mexico', 'England', 1],
2475
+ ['USA', 'Portugal', 1],
2476
+ ['USA', 'France', 1],
2477
+ ['USA', 'Spain', 1],
2478
+ ['USA', 'England', 5],
2479
+ ['Portugal', 'Angola', 2],
2480
+ ['Portugal', 'Senegal', 1],
2481
+ ['Portugal', 'Morocco', 1],
2482
+ ['Portugal', 'South Africa', 3],
2483
+ ['France', 'Angola', 1],
2484
+ ['France', 'Senegal', 3],
2485
+ ['France', 'Mali', 3],
2486
+ ['France', 'Morocco', 3],
2487
+ ['France', 'South Africa', 1],
2488
+ ['Spain', 'Senegal', 1],
2489
+ ['Spain', 'Morocco', 3],
2490
+ ['Spain', 'South Africa', 1],
2491
+ ['England', 'Angola', 1],
2492
+ ['England', 'Senegal', 1],
2493
+ ['England', 'Morocco', 2],
2494
+ ['England', 'South Africa', 7],
2495
+ ['South Africa', 'China', 5],
2496
+ ['South Africa', 'India', 1],
2497
+ ['South Africa', 'Japan', 3],
2498
+ ['Angola', 'China', 5],
2499
+ ['Angola', 'India', 1],
2500
+ ['Angola', 'Japan', 3],
2501
+ ['Senegal', 'China', 5],
2502
+ ['Senegal', 'India', 1],
2503
+ ['Senegal', 'Japan', 3],
2504
+ ['Mali', 'China', 5],
2505
+ ['Mali', 'India', 1],
2506
+ ['Mali', 'Japan', 3],
2507
+ ['Morocco', 'China', 5],
2508
+ ['Morocco', 'India', 1],
2509
+ ['Morocco', 'Japan', 3],
2510
+ ['Japan', 'Brazil', 1]
2511
+ ],
2512
+ "type": 'dependencywheel',
2513
+ "name": 'Dependency wheel series',
2514
+ "dataLabels": {
2515
+ "color": '#333',
2516
+ "style": {
2517
+ "textOutline": 'none'
2518
+ },
2519
+ "textPath": {
2520
+ "enabled": True,
2521
+ "attributes": {
2522
+ "dy": 5
2523
+ }
2524
+ },
2525
+ "distance": 10
2526
+ },
2527
+ "size": '95%'
2528
+ }]
2529
+
2530
+ }
2531
+ frontend_dir = (Path(__file__).parent / "frontend").absolute()
2532
+ _component_func = components.declare_component(
2533
+ "streamlit_highcharts", path=str(frontend_dir)
2534
+ )
2535
+
2536
+ def streamlit_highcharts(
2537
+ options=SAMPLE,
2538
+ height=410,
2539
+ key: Optional[str] = None,
2540
+ ):
2541
+ """
2542
+ Add a descriptive docstring
2543
+ """
2544
+ component_value = _component_func(
2545
+ options=options,key=key,height=height
2546
+ )
2547
+
2548
+ return component_value
2549
+
2550
+
2551
+ # def main():
2552
+ # st.write("## Example")
2553
+ # selSample=st.selectbox("Choose a sample",[SAMPLE,SAMPLE2,SAMPLE3,SAMPLE4,SAMPLE5,SAMPLE6,SAMPLE7,SAMPLE8,SAMPLE9,SAMPLE10],format_func=lambda x: str(x["title"]["text"])
2554
+ # )
2555
+ # value = streamlit_highcharts(selSample,640)
2556
+ # with st.expander("Show code...",expanded=False):
2557
+ # st.code(str(selSample).replace("},","},\r\n"),language="python")
2558
+
2559
+
2560
+
2561
+ # if __name__ == "__main__":
2562
+ # main()
st_hc/frontend/index.html ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>streamlit-highcharts</title>
8
+ <script src="https://code.highcharts.com/stock/highstock.js"></script>
9
+ <script src="https://code.highcharts.com/highcharts-more.js"></script>
10
+ <script src="https://code.highcharts.com/modules/heatmap.js"></script>
11
+ <script src="https://code.highcharts.com/modules/tilemap.js"></script>
12
+ <script src="https://code.highcharts.com/modules/streamgraph.js"></script>
13
+ <script src="https://code.highcharts.com/modules/solid-gauge.js"></script>
14
+ <script src="https://code.highcharts.com/modules/series-label.js"></script>
15
+ <script src="https://code.highcharts.com/modules/data.js"></script>
16
+ <script src="https://code.highcharts.com/modules/drilldown.js"></script>
17
+ <script src="https://code.highcharts.com/modules/sankey.js"></script>
18
+ <script src="https://code.highcharts.com/modules/dependency-wheel.js"></script>
19
+ <script src="https://code.highcharts.com/modules/annotations.js"></script>
20
+ <script src="https://code.highcharts.com/modules/exporting.js"></script>
21
+ <script src="https://code.highcharts.com/modules/export-data.js"></script>
22
+ <script src="https://code.highcharts.com/modules/accessibility.js"></script>
23
+ <script src="https://github.highcharts.com/modules/parallel-coordinates.js"></script>
24
+ <script src="https://code.highcharts.com/modules/draggable-points.js"></script>
25
+ <script src="https://code.highcharts.com/modules/exporting.js"></script>
26
+ <script src="https://code.highcharts.com/modules/export-data.js"></script>
27
+ <script src="./streamlit-component-lib.js"></script>
28
+ <script src="./main.js"></script>
29
+ <link rel="stylesheet" href="./style.css" />
30
+ </head>
31
+ <body>
32
+ <div id="root">
33
+ <div id="container" ></div>
34
+ </div>
35
+ </body>
36
+ </html>
st_hc/frontend/main.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function sendValue(value) {
2
+ Streamlit.setComponentValue(value)
3
+ }
4
+
5
+
6
+ function onRender(event) {
7
+ if (true) {
8
+ const {options,height} = event.detail.args
9
+ Streamlit.setFrameHeight(height+20)
10
+ document.getElementById("container").style.height=height+"px"
11
+ let c = Highcharts.chart('container', options);
12
+
13
+ let points = c.series[0].data.map((p) =>
14
+ ({ x: Math.round(p.x),
15
+ y: Math.round(p.y),
16
+ name:p.name} ));
17
+ sendValue(points);
18
+
19
+ console.log(c.series[0].data);
20
+
21
+ c.series[0].data.forEach((point, i) => {
22
+
23
+ point.graphic.element.onclick = () => {
24
+
25
+ let points = c.series[0].data.map((p) =>
26
+ ({ x: Math.round(p.x),
27
+ y: Math.round(p.y),
28
+ name:p.name} ));
29
+
30
+ console.log(points);
31
+ sendValue(points);
32
+
33
+ }
34
+ })
35
+ window.rendered = true
36
+ }
37
+ }
38
+
39
+ Streamlit.events.addEventListener(Streamlit.RENDER_EVENT, onRender)
40
+ Streamlit.setComponentReady()
st_hc/frontend/streamlit-component-lib.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // Borrowed minimalistic Streamlit API from Thiago
3
+ // https://discuss.streamlit.io/t/code-snippet-create-components-without-any-frontend-tooling-no-react-babel-webpack-etc/13064
4
+ function sendMessageToStreamlitClient(type, data) {
5
+ console.log(type, data)
6
+ const outData = Object.assign({
7
+ isStreamlitMessage: true,
8
+ type: type,
9
+ }, data);
10
+ window.parent.postMessage(outData, "*");
11
+ }
12
+
13
+ const Streamlit = {
14
+ setComponentReady: function() {
15
+ sendMessageToStreamlitClient("streamlit:componentReady", {apiVersion: 1});
16
+ },
17
+ setFrameHeight: function(height) {
18
+ sendMessageToStreamlitClient("streamlit:setFrameHeight", {height: height});
19
+ },
20
+ setComponentValue: function(value) {
21
+ sendMessageToStreamlitClient("streamlit:setComponentValue", {value: value});
22
+ },
23
+ RENDER_EVENT: "streamlit:render",
24
+ events: {
25
+ addEventListener: function(type, callback) {
26
+ window.addEventListener("message", function(event) {
27
+ if (event.data.type === type) {
28
+ event.detail = event.data
29
+ callback(event);
30
+ }
31
+ });
32
+ }
33
+ }
34
+ }
st_hc/frontend/style.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ text.highcharts-credits {
2
+ display: none;
3
+ }
4
+ .highcharts-exporting-group {
5
+ display: none;
6
+ }
7
+ div[class*="chartMenu"] {
8
+ display: none;
9
+ }