-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #750 from Avaiga/doc/update-third-party-components
3rd Party Components tip - From Sankey to Folium
- Loading branch information
Showing
5 changed files
with
350 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import tempfile | ||
import folium | ||
import pandas as pd | ||
from taipy.gui import Gui, get_user_content_url | ||
|
||
|
||
eco_footprints = pd.read_csv("footprint.csv") | ||
max_eco_footprint = eco_footprints["Ecological footprint"].max() | ||
political_countries_url = ( | ||
"http://geojson.xyz/naturalearth-3.3.0/ne_50m_admin_0_countries.geojson" | ||
) | ||
|
||
|
||
def folium_map(): | ||
# Create the folium map | ||
map = folium.Map(location=(30, 10), zoom_start=3, tiles="cartodb positron") | ||
folium.Choropleth( | ||
geo_data=political_countries_url, | ||
data=eco_footprints, | ||
columns=("Country/region", "Ecological footprint"), | ||
key_on="feature.properties.name", | ||
bins=(0, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, max_eco_footprint), | ||
fill_color="RdYlGn_r", | ||
fill_opacity=0.8, | ||
line_opacity=0.3, | ||
nan_fill_color="white", | ||
legend_name="Ecological footprint per capita", | ||
name="Countries by ecological footprint per capita", | ||
).add_to(map) | ||
folium.LayerControl().add_to(map) | ||
|
||
return map | ||
|
||
def expose_folium(map): | ||
with tempfile.NamedTemporaryFile(delete=False, suffix=".html") as temp_file: | ||
map.save(temp_file.name) | ||
with open(temp_file.name, "rb") as f: | ||
return f.read() | ||
|
||
|
||
uc_url = None | ||
|
||
def on_user_content(state, path: str, query: dict): | ||
return expose_folium(folium_map()) | ||
|
||
def on_init(state): | ||
state.uc_url = get_user_content_url(state, "val", {"name": "param"}) | ||
|
||
Gui("<|part|page={uc_url}|height=600px|>").run(port=2534, debug=True) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
191 changes: 191 additions & 0 deletions
191
docs/knowledge_base/tips/3rd_party_components/footprint.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
Rank,Country/region,Ecological footprint,Biocapacity,Biocapacity deficit or reserve,Population (millions),Total biocapacity deficit or reserve (gMha),Population (millions) for biocapacity to equal ecological footprint *(gha/person) | ||
0,World,2.75,1.63,-1.12,7753,-10400,2500 | ||
1,Luxembourg,15.82,1.68,-14.14,0.63,-7.35,0.055221 | ||
2,Aruba,11.88,0.57,-11.31,0.17,-1.13,0.004798 | ||
3,Qatar,10.8,1.24,-9.56,2.05,-19.60,0.23537 | ||
4,Australia,9.31,16.57,7.26,23.05,167.34,41.02454 | ||
5,United States,8.22,3.76,-4.46,329.5,-1416.05,145.2311 | ||
6,Canada,8.17,16.01,7.83,38,272.80,68.27275 | ||
7,Kuwait,8.13,0.55,-7.58,3.25,-24.64,0.219865 | ||
8,Singapore,7.97,0.05,-7.92,5.3,-41.98,0.03325 | ||
9,United Kingdom,7.93,0.56,-7.37,65.648,-483.83,4.635924 | ||
10,Trinidad and Tobago,7.92,1.56,-6.36,1.34,-8.52,0.263939 | ||
11,Montserrat,7.78,1.36,-6.42,0.005,-0.03,0.000874 | ||
12,Oman,7.52,1.92,-5.6,3.31,-18.54,0.845106 | ||
13,Bahrain,7.49,0.58,-6.91,1.32,-9.12,0.102216 | ||
14,Belgium,7.44,1.19,-6.25,11.6,-69.13,1.769005 | ||
15,Sweden,7.25,10.62,3.38,9.51,32.14,13.93051 | ||
16,Estonia,6.86,10.53,3.67,1.29,4.73,1.980131 | ||
17,Bahamas,6.84,9.55,2.71,0.37,1.00,0.516594 | ||
18,Latvia,6.29,9.55,3.26,2.06,6.72,3.127663 | ||
19,Israel,6.22,0.35,-5.87,9.1,-44.85,0.429904 | ||
20,Mongolia,6.08,15.66,9.58,2.8,26.82,7.211842 | ||
21,Austria,6.06,3.07,-3,8.46,-25.38,4.285842 | ||
22,Taiwan,5.93,1.0,-4.13,23.6,1.00,3.979764 | ||
22,Finland,5.87,13.44,7.57,5.41,40.95,12.38678 | ||
23,Lithuania,5.83,5.67,-0.17,3.03,-0.52,2.946844 | ||
24,Slovenia,5.81,2.35,-3.47,2.07,-7.18,0.837263 | ||
25,Switzerland,5.79,1.3,-4.48,8,-35.84,1.7962 | ||
26,Bermuda,5.77,0.13,-5.64,0.06,-0.34,0.001352 | ||
27,South Korea,5.69,0.68,-5.01,49,-245.49,5.855888 | ||
28,Russia,5.69,6.79,1.1,143.17,157.49,170.8479 | ||
29,Cayman Islands,5.65,0.32,-5.33,0.06,-0.32,0.003398 | ||
30,Saudi Arabia,5.61,0.5,-5.12,28.29,-144.84,2.52139 | ||
31,New Zealand,5.6,10.14,4.54,4.46,20.25,8.075786 | ||
32,Ireland,5.57,3.73,-1.83,4.58,-8.38,3.067038 | ||
33,Kazakhstan,5.55,3.41,-2.14,16.27,-34.82,9.996523 | ||
34,Denmark,5.51,4.78,-0.73,5.6,-4.09,4.858076 | ||
35,Turkmenistan,5.47,2.79,-2.68,5.17,-13.86,2.636984 | ||
36,Antigua and Barbuda,5.38,0.94,-4.44,0.09,-0.40,0.015725 | ||
37,Germany,5.3,2.27,-3.02,82.8,-250.06,35.4634 | ||
38,Netherlands,5.28,1.17,-4.11,16.71,-68.68,3.702784 | ||
39,Czech Republic,5.19,2.46,-2.73,10.66,-29.10,5.052717 | ||
40,France,5.14,3.11,-2.04,63.98,-130.52,38.71163 | ||
41,Belarus,5.09,3.64,-1.45,9.4,-13.63,6.7222 | ||
42,Japan,5.02,0.72,-4.3,127.25,-547.18,18.251 | ||
43,Norway,4.98,8.18,3.19,4.99,15.92,8.196426 | ||
44,Saint Kitts and Nevis,4.94,0.62,-4.31,0.05,-0.22,0.006275 | ||
45,United Arab Emirates,4.94,1.32,-3.62,6.30,-22.82,1.683401 | ||
46,Bhutan,4.84,5.27,0.43,0.74,0.32,0.805744 | ||
47,French Polynesia,4.73,1.37,-3.36,0.27,-0.91,0.078203 | ||
48,Italy,4.61,1.08,-3.53,60.92,-215.05,14.27193 | ||
49,Barbados,4.48,0.19,-4.29,0.28,-1.20,0.011875 | ||
50,Poland,4.44,2.08,-2.36,38.21,-90.18,17.90018 | ||
51,Greece,4.38,1.61,-2.77,11.12,-30.80,4.087489 | ||
52,Chile,4.36,3.63,-0.73,17.46,-12.75,14.53665 | ||
53,Suriname,4.25,89.33,85.08,0.54,45.94,11.35016 | ||
54,Cyprus,4.21,0.34,-3.87,1.13,-4.37,0.091259 | ||
55,Paraguay,4.16,10.52,6.36,6.69,42.55,16.91798 | ||
56,Brunei,4.06,2.87,-1.19,0.41,-0.49,0.289828 | ||
57,Slovakia,4.06,2.71,-1.35,5.45,-7.36,3.637808 | ||
58,Equatorial Guinea,3.97,4.4,0.44,0.74,0.33,0.820151 | ||
59,Croatia,3.92,2.8,-1.12,4.31,-4.83,3.078571 | ||
60,Portugal,3.88,1.51,-2.37,10.6,-25.12,4.125258 | ||
61,Lebanon,3.84,0.33,-3.51,4.65,-16.32,0.399609 | ||
62,Botswana,3.83,3.47,-0.35,2,-0.70,1.81201 | ||
63,Montenegro,3.78,3.24,-0.54,0.62,-0.33,0.531429 | ||
64,Malaysia,3.71,2.41,-1.3,29.24,-38.01,18.99418 | ||
65,Libya,3.69,0.7,-3,6.16,-18.48,1.168564 | ||
66,Spain,3.67,1.25,-2.42,46.76,-113.16,15.92643 | ||
67,Réunion,3.65,0.18,-3.47,0.86,-2.98,0.042411 | ||
68,New Caledonia,3.58,7.67,4.09,0.25,1.02,0.535615 | ||
69,Venezuela,3.57,2.78,-0.79,29.96,-23.67,23.3302 | ||
70,Mauritius,3.46,0.71,-2.75,1.24,-3.41,0.254451 | ||
71,China,3.38,0.94,-2.44,1402,-3435.62,391.5851 | ||
72,Turkey,3.33,1.52,-1.81,74,-133.94,33.77778 | ||
73,Bulgaria,3.32,2.86,-0.46,7.28,-3.35,6.271325 | ||
74,South Africa,3.31,1.15,-2.16,52.39,-113.16,18.20196 | ||
75,Macedonia,3.26,1.51,-1.75,2.11,-3.69,0.977331 | ||
76,Guadeloupe,3.23,0.45,-2.77,0.46,-1.27,0.064087 | ||
77,Argentina,3.14,6.92,3.78,41.09,155.32,90.55503 | ||
78,Bosnia and Herzegovina,3.12,1.63,-1.49,3.83,-5.71,2.000929 | ||
79,Brazil,3.11,9.08,5.97,198.66,1186.00,580.0105 | ||
80,Saint Vincent and the Grenadines,3.11,1.26,-1.85,0.11,-0.20,0.044566 | ||
81,Guyana,3.07,66.58,63.51,0.8,50.81,17.34984 | ||
82,Grenada,2.98,1.96,-1.01,0.1,-0.10,0.065772 | ||
83,Bolivia,2.96,16.73,13.77,10.5,144.59,59.34628 | ||
84,Nauru,2.94,0.19,-2.76,0.01,-0.03,0.000646 | ||
85,Hungary,2.92,2.17,-0.75,9.98,-7.49,7.416644 | ||
86,Uruguay,2.91,10.32,7.41,3.4,25.19,12.05773 | ||
87,Fiji,2.9,2.37,-0.52,0.88,-0.46,0.719172 | ||
88,Mexico,2.89,1.27,-1.62,120.85,-195.78,53.10709 | ||
89,British Virgin Islands,2.86,2.05,-0.81,0.03,-0.02,0.021503 | ||
90,Costa Rica,2.84,1.53,-1.31,4.8,-6.29,2.585915 | ||
91,Ukraine,2.84,2.27,-0.58,45.53,-26.41,36.39194 | ||
92,Iran,2.79,0.9,-1.89,76.42,-144.43,24.65161 | ||
93,Panama,2.79,2.94,0.15,3.8,0.57,4.004301 | ||
94,Samoa,2.77,1.93,-0.85,0.19,-0.16,0.132383 | ||
95,Romania,2.71,2.32,-0.39,21.76,-8.49,18.62849 | ||
96,Serbia,2.7,1.25,-1.44,9.55,-13.75,4.421296 | ||
97,Tonga,2.7,1.48,-1.22,0.1,-0.12,0.054815 | ||
98,Thailand,2.66,1.24,-1.42,66.78,-94.83,31.13053 | ||
99,Dominica,2.57,1.03,-1.54,0.07,-0.11,0.028054 | ||
100,Mauritania,2.54,4.48,1.93,3.8,7.33,6.702362 | ||
101,Cape Verde,2.52,0.62,-1.9,0.49,-0.93,0.120556 | ||
102,Namibia,2.48,6.88,4.4,2.26,9.94,6.269677 | ||
103,Saint Lucia,2.45,0.34,-2.1,0.18,-0.38,0.02498 | ||
104,French Guiana,2.34,111.35,109.01,0.24,26.16,11.42051 | ||
105,Tunisia,2.34,0.93,-1.4,10.88,-15.23,4.324103 | ||
106,Uzbekistan,2.32,0.92,-1.4,28.54,-39.96,11.31759 | ||
107,Azerbaijan,2.31,0.85,-1.46,9.31,-13.59,3.425758 | ||
108,Peru,2.28,3.97,1.69,29.99,50.68,52.21943 | ||
109,Armenia,2.23,0.89,-1.35,2.97,-4.01,1.185336 | ||
110,Albania,2.21,1.18,-1.03,3.16,-3.25,1.68724 | ||
111,Djibouti,2.19,0.77,-1.42,0.86,-1.22,0.302374 | ||
112,Ecuador,2.17,2.2,0.03,15.49,0.46,15.70415 | ||
113,Egypt,2.15,0.56,-1.59,80.72,-128.34,21.02474 | ||
114,Algeria,2.12,0.59,-1.53,38.48,-58.87,10.70906 | ||
115,Jordan,2.1,0.21,-1.89,7.01,-13.25,0.701 | ||
116,Martinique,2.08,0.39,-1.7,0.4,-0.68,0.075 | ||
117,El Salvador,2.07,0.61,-1.46,6.3,-9.20,1.856522 | ||
118,Wallis and Futuna,2.07,1.51,-0.56,0.01,-0.01,0.007295 | ||
119,Gabon,2.02,26.31,24.29,1.63,39.59,21.23035 | ||
120,Swaziland,2.01,0.88,-1.14,1.23,-1.40,0.538507 | ||
121,Ghana,1.97,1.35,-0.62,25.37,-15.73,17.38553 | ||
122,Cuba,1.95,0.76,-1.19,11.27,-13.41,4.39241 | ||
123,Kyrgyzstan,1.91,1.3,-0.61,5.47,-3.34,3.723037 | ||
124,Papua New Guinea,1.91,3.92,2.01,7.17,14.41,14.71539 | ||
125,Guatemala,1.89,0.99,-0.9,15.08,-13.57,7.899048 | ||
126,Jamaica,1.89,0.43,-1.46,2.77,-4.04,0.630212 | ||
127,Iraq,1.88,0.29,-1.59,32.78,-52.12,5.056489 | ||
128,Colombia,1.87,3.6,1.72,47.7,82.04,91.82888 | ||
129,Moldova,1.78,0.8,-0.98,3.51,-3.44,1.577528 | ||
130,Honduras,1.68,1.77,0.09,7.94,0.71,8.365357 | ||
131,Morocco,1.68,0.71,-0.96,32.52,-31.22,13.74357 | ||
132,Lesotho,1.66,0.78,-0.87,2.05,-1.78,0.963253 | ||
133,Vietnam,1.65,1,-0.65,90.8,-59.02,55.0303 | ||
134,Georgia,1.58,1.17,-0.41,4.36,-1.79,3.228608 | ||
135,Indonesia,1.58,1.26,-0.32,246.86,-79.00,196.863 | ||
136,Niger,1.56,1.24,-0.32,17.16,-5.49,13.64 | ||
137,Dominican Republic,1.53,0.56,-0.97,10.28,-9.97,3.762614 | ||
138,Guinea-Bissau,1.53,3.03,1.49,1.66,2.47,3.287451 | ||
139,Mali,1.53,1.58,0.05,14.85,0.74,15.33529 | ||
140,Syria,1.51,0.6,-0.91,21.89,-19.92,8.698013 | ||
141,Sao Tome and Principe,1.49,0.87,-0.61,0.19,-0.12,0.11094 | ||
142,Chad,1.46,2.03,0.57,12.45,7.10,17.31062 | ||
143,Myanmar,1.43,1.84,0.41,52.8,21.65,67.93846 | ||
144,Benin,1.41,0.88,-0.53,10.05,-5.33,6.27234 | ||
145,Guinea,1.41,2.09,0.68,11.45,7.79,16.97199 | ||
146,Nicaragua,1.39,2.25,0.87,5.99,5.21,9.696043 | ||
147,Zimbabwe,1.37,0.62,-0.75,13.72,-10.29,6.209051 | ||
148,Sri Lanka,1.32,0.44,-0.88,21.1,-18.57,7.033333 | ||
149,Tanzania,1.32,1.08,-0.24,47.78,-11.47,39.09273 | ||
150,Congo,1.29,10.91,9.63,4.34,41.97,36.70496 | ||
151,Solomon Islands,1.29,4.36,3.08,0.55,1.69,1.858915 | ||
152,Côte d'Ivoire,1.27,1.78,0.51,19.84,10.12,27.80724 | ||
153,Central African Republic,1.24,7.87,6.62,4.53,29.99,28.75089 | ||
154,Sierra Leone,1.24,1.24,0,5.98,0.00,5.98 | ||
155,Somalia,1.24,1.27,0.03,10.2,0.31,10.44677 | ||
156,Uganda,1.24,0.59,-0.66,36.35,-23.99,17.29556 | ||
157,Laos,1.22,1.62,0.4,6.65,2.66,8.830328 | ||
158,Burkina Faso,1.21,0.98,-0.22,16.46,-3.62,13.33124 | ||
159,Cambodia,1.21,1.09,-0.11,14.86,-1.63,13.38628 | ||
160,Liberia,1.21,2.57,1.35,4.19,5.66,8.899421 | ||
161,Senegal,1.21,1.05,-0.16,13.73,-2.20,11.91446 | ||
162,Cameroon,1.17,1.69,0.52,21.7,11.28,31.34444 | ||
163,North Korea,1.17,0.6,-0.57,24.76,-14.11,12.69744 | ||
164,India,1.16,0.45,-0.71,1380,-878.05,479.7504 | ||
165,Nigeria,1.16,0.7,-0.47,168.83,-79.35,101.8802 | ||
166,Togo,1.13,0.53,-0.6,6.64,-3.98,3.114336 | ||
167,Philippines,1.1,0.54,-0.56,96.71,-54.16,47.47582 | ||
168,Comoros,1.03,0.32,-0.7,0.72,-0.50,0.223689 | ||
169,Gambia,1.03,0.82,-0.21,1.79,-0.38,1.425049 | ||
170,Kenya,1.03,0.51,-0.52,43.18,-22.45,21.38039 | ||
171,Yemen,1.03,0.5,-0.53,23.85,-12.64,11.57767 | ||
172,Ethiopia,1.02,0.58,-0.44,91.73,-40.36,52.1602 | ||
173,Madagascar,0.99,2.63,1.64,22.29,36.56,59.21485 | ||
174,Zambia,0.99,2.23,1.24,14.08,17.46,31.71556 | ||
175,Nepal,0.98,0.59,-0.38,27.47,-10.44,16.53806 | ||
176,Angola,0.93,2.55,1.61,20.82,35.52,57.0871 | ||
177,Tajikistan,0.91,0.53,-0.38,8.01,-3.04,4.665165 | ||
178,Mozambique,0.87,2.06,1.19,25.2,29.99,59.66897 | ||
179,Rwanda,0.87,0.54,-0.32,11.46,-3.67,7.113103 | ||
180,Democratic Republic of the Congo,0.82,3.07,2.25,65.7,147.83,245.9744 | ||
181,Malawi,0.81,0.66,-0.15,15.91,-2.39,12.9637 | ||
182,Burundi,0.8,0.32,-0.48,9.85,-4.73,3.94 | ||
183,Afghanistan,0.79,0.5,-0.3,29.82,-8.95,18.87342 | ||
184,Pakistan,0.79,0.35,-0.44,179.16,-78.83,79.37468 | ||
185,Bangladesh,0.72,0.38,-0.35,154.7,-54.15,81.64722 | ||
186,Haiti,0.61,0.27,-0.34,10.17,-3.46,4.501475 | ||
187,Timor-Leste,0.48,1.78,1.3,1.11,1.44,4.11625 | ||
188,Eritrea,0.49,1.3,0.88,6.13,5.39,16.26327 |
Oops, something went wrong.