You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So for my map, I have set up an event so that when a country is clicked on the map, it redirects to the home page. But I only want this to happen when I have data for a country.
<script>
// example data from server
var series = [ ["USA", 10]];
...
new Datamap({element: document.getElementById('container1'),projection: 'mercator',fills: {defaultFill: '#F5F5F5'},data: dataset,geographyConfig: {borderColor: '#DEDEDE',highlightBorderWidth: 2,// don't change color on mouse hoverhighlightFillColor: function(geo){returngeo['fillColor']||'#F5F5F5';},// only change borderhighlightBorderColor: '#B7B7B7',done: function(datamap){datamap.svg.selectAll('.datamaps-subunit').on('click',function(geography){//alert(geography.properties.name);return[window.location.href="{{ url_for('home')}}"];});},// show desired information in tooltippopupTemplate: function(geo,data){// don't show tooltip if country don't present in datasetif(!data){return;}// tooltip contentreturn['<div class="hoverinfo">','<strong>',geo.properties.name,'</strong>',//'<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');}}});
</script>
My popupTemplate works, and only shows the countries name, if it exists, so that means the USA is the only one that shows when hovering. But in my done() function, all the countries redirect to the home page. How can I make it so only countries in my dataset can be redirected?
The text was updated successfully, but these errors were encountered:
So for my map, I have set up an event so that when a country is clicked on the map, it redirects to the home page. But I only want this to happen when I have data for a country.
My popupTemplate works, and only shows the countries name, if it exists, so that means the USA is the only one that shows when hovering. But in my done() function, all the countries redirect to the home page. How can I make it so only countries in my dataset can be redirected?
The text was updated successfully, but these errors were encountered: