|
42 | 42 | 'Egypt': 'Middle East', 'Kuwait': 'Middle East', 'Qatar': 'Middle East', 'Iran': 'Middle East', |
43 | 43 | 'Israel': 'Middle East', 'Iraq': 'Middle East', 'Jordan': 'Middle East', 'Syria': 'Middle East', |
44 | 44 | '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', |
46 | 49 | }; |
47 | 50 |
|
48 | 51 | function getRegionColor(regionName) { |
|
200 | 203 | var region = getCountryRegion(d.properties.name); |
201 | 204 | return region ? getRegionColor(region) : COLOR_UNMATCHED; |
202 | 205 | }) |
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 | + }) |
205 | 213 | .attr('opacity', DEFAULT_OPACITY) |
206 | 214 | .attr('data-region', function (d) { |
207 | 215 | return getCountryRegion(d.properties.name) || ''; |
|
210 | 218 | .on('mouseenter', function (event, d) { |
211 | 219 | var name = d.properties.name; |
212 | 220 | 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 | + } |
214 | 230 |
|
215 | 231 | d3.select(this) |
216 | 232 | .attr('opacity', 1) |
217 | | - .attr('stroke', COLOR_HOVER_STROKE) |
218 | | - .attr('stroke-width', HOVER_STROKE_WIDTH) |
219 | 233 | .raise(); |
220 | 234 |
|
221 | 235 | countryPaths.each(function () { |
|
239 | 253 | window.showTooltip(buildTooltipHtml(region, count), event.pageX, event.pageY); |
240 | 254 | }) |
241 | 255 | .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 | + }); |
247 | 264 |
|
248 | 265 | window.hideTooltip(); |
249 | 266 | }); |
|
0 commit comments