From 58fb128a00f8329bf9d8156288d159dbdff147d7 Mon Sep 17 00:00:00 2001 From: Noam Eyal Date: Thu, 21 Feb 2019 17:15:19 +0000 Subject: [PATCH] Fix updateChoropleth Issues Allows numerical subunits in updateChoropleth and reloads subunits that had data previously but don't in the new data being passed to updateChoropleth. --- src/js/datamaps.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) {