diff --git a/src/js/datamaps.js b/src/js/datamaps.js index 16b983c6..96be2399 100644 --- a/src/js/datamaps.js +++ b/src/js/datamaps.js @@ -1126,14 +1126,20 @@ // If it's an object, overriding the previous data if ( subunitData === Object(subunitData) ) { this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {}); - var geo = this.svg.select('.' + subunit).attr('data-info', JSON.stringify(this.options.data[subunit])); + var geo = this.svg.select('.' + CSS.escape(subunit)).attr('data-info', JSON.stringify(this.options.data[subunit])); } svg - .selectAll('.' + subunit) + .selectAll('.' + CSS.escape(subunit)) .transition() .style('fill', color); } } + + for (var existingSubunit in this.options.data) { + if(this.options.data.hasOwnProperty(existingSubunit) && !data.hasOwnProperty(existingSubunit)) { + map.options.data[existingSubunit] = {}; + } + } }; Datamap.prototype.updatePopup = function (element, d, options) {