Skip to content

Commit 320729e

Browse files
committed
fix(geo-map): remove intra-region borders, fill Argentina gap, Africa no-data tooltip
1 parent b468da7 commit 320729e

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

docs/js/visualizations/geo-map.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@
4242
'Egypt': 'Middle East', 'Kuwait': 'Middle East', 'Qatar': 'Middle East', 'Iran': 'Middle East',
4343
'Israel': 'Middle East', 'Iraq': 'Middle East', 'Jordan': 'Middle East', 'Syria': 'Middle East',
4444
'Brazil': 'South America', 'Argentina': 'South America', 'Peru': 'South America',
45-
'Chile': 'South America', 'Colombia': 'South America',
45+
'Chile': 'South America', 'Colombia': 'South America', 'Venezuela': 'South America',
46+
'Ecuador': 'South America', 'Bolivia': 'South America', 'Paraguay': 'South America',
47+
'Uruguay': 'South America', 'Guyana': 'South America', 'Suriname': 'South America',
48+
'Falkland Is.': 'South America', 'Fr. S. Antarctic Lands': 'South America',
4649
};
4750

4851
function getRegionColor(regionName) {
@@ -200,8 +203,13 @@
200203
var region = getCountryRegion(d.properties.name);
201204
return region ? getRegionColor(region) : COLOR_UNMATCHED;
202205
})
203-
.attr('stroke', COLOR_BORDER)
204-
.attr('stroke-width', 0.5)
206+
.attr('stroke', function (d) {
207+
var region = getCountryRegion(d.properties.name);
208+
return region ? getRegionColor(region) : COLOR_BORDER;
209+
})
210+
.attr('stroke-width', function (d) {
211+
return getCountryRegion(d.properties.name) ? 0.3 : 0.5;
212+
})
205213
.attr('opacity', DEFAULT_OPACITY)
206214
.attr('data-region', function (d) {
207215
return getCountryRegion(d.properties.name) || '';
@@ -210,12 +218,18 @@
210218
.on('mouseenter', function (event, d) {
211219
var name = d.properties.name;
212220
var region = getCountryRegion(name);
213-
if (!region) return;
221+
222+
if (!region) {
223+
window.showTooltip(
224+
'<div class="tooltip-title" style="color:#666">No data</div>' +
225+
'<div class="tooltip-row"><span class="tooltip-label" style="color:#666">Insufficient perfume data for this region</span></div>',
226+
event.pageX, event.pageY
227+
);
228+
return;
229+
}
214230

215231
d3.select(this)
216232
.attr('opacity', 1)
217-
.attr('stroke', COLOR_HOVER_STROKE)
218-
.attr('stroke-width', HOVER_STROKE_WIDTH)
219233
.raise();
220234

221235
countryPaths.each(function () {
@@ -239,11 +253,14 @@
239253
window.showTooltip(buildTooltipHtml(region, count), event.pageX, event.pageY);
240254
})
241255
.on('mouseleave', function () {
242-
countryPaths
243-
.transition().duration(200)
244-
.attr('opacity', DEFAULT_OPACITY)
245-
.attr('stroke', COLOR_BORDER)
246-
.attr('stroke-width', 0.5);
256+
countryPaths.each(function () {
257+
var el = d3.select(this);
258+
var r = el.attr('data-region');
259+
el.transition().duration(200)
260+
.attr('opacity', DEFAULT_OPACITY)
261+
.attr('stroke', r ? getRegionColor(r) : COLOR_BORDER)
262+
.attr('stroke-width', r ? 0.3 : 0.5);
263+
});
247264

248265
window.hideTooltip();
249266
});

0 commit comments

Comments
 (0)