feat: colorize countries

WIP
This commit is contained in:
Gigi
2022-04-26 11:36:03 +02:00
parent 97e2675725
commit 5e411d88e0
2 changed files with 40 additions and 16 deletions

View File

@@ -100,7 +100,8 @@
"alpha3": "AUT",
"numeric": 40,
"latitude": 47.3333,
"longitude": 13.3333
"longitude": 13.3333,
"link": "https://einundzwanzig.space/meetups"
},
{
"country": "Azerbaijan",
@@ -631,7 +632,7 @@
"longitude": 9,
"city_name": "Munich",
"nb_visits": 456,
"href": "https://einundzwanzig.space/meetups"
"link": "https://einundzwanzig.space/meetups"
},
{
"country": "Ghana",

View File

@@ -42,7 +42,7 @@ jsplugins:
fill: '#333'
},
mouseenter: function (d, path) {
path.attr('fill', Math.random() < 0.5 ? '#c04' : '#04c');
path.attr('fill', Math.random() < 0.5 ? '#735000' : '#BBB');
},
mouseleave: function (d, path) {
path.animate({ fill: '#333' }, 1000);
@@ -58,6 +58,29 @@ jsplugins:
success: function (countries) {
var scale = kartograph.scale.sqrt(countries.concat([{ nb_visits: 0 }]), 'nb_visits').range([0, 60]);
var orangeCountries = countries.filter(function hasLink(c) {
var hasLink = c.link ? true : false;
return hasLink;
});
map.getLayer('countries').style('fill', function (data) {
console.log('gnaaa');
var germany = countries[0];
console.log(germany);
console.log('ORANGE COUNTRIES: ' + orangeCountries);
var orangeCountryCodes = orangeCountries.map(function(c) {
return c.alpha3;
});
console.log('ORANGE CODES: ' + orangeCountryCodes);
var isOrangeCountry = orangeCountryCodes.includes(data.iso)
return isOrangeCountry ? '#d00' : '#ccc';
});
map.addSymbols({
type: kartograph.Bubble,