svgMap
svgMap copied to clipboard
Refresh problem with 3+ countries
I'm trying to apply data to the map, then using map.applyData(), which sort of works, but only when I have changed the data for 2 countries. If I do it for 3 or more, it simply doesn't redraw or update colors (something like that).
Try using the example below. Hover the mouse over Canada, nothing changes, but hover it over the US and it works. The only difference being one more country when hovering on Canada.
var map = new svgMap({
targetElementID: 'svgMap',
onGetTooltip: myCustomData,
data: {
data: {
applicable: {
name: 'Applicable',
format: '{0}',
thousandSeparator: ',',
thresholdMax: 1,
thresholdMin: 0
}
},
applyData: 'applicable',
values: {
AF: { applicable: 1 },
AL: { applicable: 1 },
SE: { applicable: 1 }
},
}
});
function myCustomData(tooltipDiv, countryID, countryValues) {
if (countryID === "CA") {
map.options.data.values["AF"].applicable = 0;
map.options.data.values["AL"].applicable = 0;
map.options.data.values["SE"].applicable = 0;
map.applyData(map.options.data);
}
if (countryID === "US") {
map.options.data.values["AF"].applicable = 0;
map.options.data.values["AL"].applicable = 0;
map.applyData(map.options.data);
}
return "Hello world!";
}