diff --git a/static/js/analy_reports.js b/static/js/analy_reports.js index 5dba5b7..0a1e000 100644 --- a/static/js/analy_reports.js +++ b/static/js/analy_reports.js @@ -116,44 +116,47 @@ function getVisitorMapData(source) { return visitorMapDataset; } -var visitorMap; +var visitorMaps = []; function showVisitorMap(data, scope, containerid) { - $("visitorMap").html(""); - visitorMap = new Datamap({ - element: document.getElementById(containerid), - scope: scope, - responsive: true, - fills: {defaultFill: '#F5F5F5'}, - data: data, - geographyConfig: { - borderColor: '#DEDEDE', - highlightBorderWidth: 2, - // don't change color on mouse hover - highlightFillColor: function (geo) { - return geo['fillColor'] || '#E8F5E9'; - }, - // only change border - highlightBorderColor: '#00C853', - // show desired information in tooltip - popupTemplate: function (geo, data) { - // don't show tooltip if country don't present in dataset - if (!data) { - //return; + visitorMaps.push( + new Datamap({ + element: document.getElementById(containerid), + scope: scope, + responsive: true, + fills: {defaultFill: '#F5F5F5'}, + data: data, + geographyConfig: { + borderColor: '#DEDEDE', + highlightBorderWidth: 2, + // don't change color on mouse hover + highlightFillColor: function (geo) { + return geo['fillColor'] || '#E8F5E9'; + }, + // only change border + highlightBorderColor: '#00C853', + // show desired information in tooltip + popupTemplate: function (geo, data) { + // don't show tooltip if country don't present in dataset + if (!data) { + //return; + } + // tooltip content + return ['
', + '', geo.properties.name, '', + '
Visits: ', data.numberOfThings, '', + '
'].join(''); + } } - // tooltip content - return ['
', - '', geo.properties.name, '', - '
Visits: ', data.numberOfThings, '', - '
'].join(''); - } - } - }); + }) + ); } showVisitorMap(getVisitorMapData(visitorMap_Countries), 'world', 'visitorMapWorld'); showVisitorMap(getVisitorMapData(visitorMap_States), 'usa', 'visitorMapUSA'); $(window).on('resize', function () { - visitorMap.resize(); + visitorMaps.forEach(function (map) { + map.resize(); + }); }); \ No newline at end of file