datamaps icon indicating copy to clipboard operation
datamaps copied to clipboard

Map Update Issue (V0.4.4)

Open kadishay opened this issue 9 years ago • 7 comments

When updating map values but failing to provide some of the values, updateChoropleth (with reset true) will select the previous values in the defaults function instead of moving to 0.

For example, I have a map with values in which a country expect val = x. I have two countries US (val = 100) and UK (val = 50). On my first view i see US with val = 100 and UK with val = 50. But after filtering my data i pass US with val = 10 and UK without val at all. In this case the map will update US to 10 but will not update UK which will still show 50. Reason: This was caused since defaults received no value in obj[prop] and fall back to source[prop]. Expected behaviour: UK should show 0.

Would appreciate any updates.

kadishay avatar Feb 09 '16 09:02 kadishay

@kadishay thanks for the report. Is there any way you could set up a repro on JSBin? This is a good starting point: http://jsbin.com/juwibuvedi/edit?html,js,output

markmarkoh avatar Feb 10 '16 17:02 markmarkoh

See this example: https://jsfiddle.net/gmeroz/a3cc80xb/

gmeroz avatar Feb 11 '16 21:02 gmeroz

The problem is on this code: //if it's an object, overriding the previous data if ( subunitData === Object(subunitData) ) { this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {});

The "defaults" function keeps old values if they do not exist in the new subunitData.

gmeroz avatar Feb 11 '16 22:02 gmeroz

@gmeroz thanks. Looks like a bug.

markmarkoh avatar Feb 12 '16 20:02 markmarkoh

This is still a problem. Is there a temporary fix for this issue? It now requires a really hacky solution to clear the data and then reload it.

dboekhout avatar Jan 16 '18 13:01 dboekhout

I have just come across this problem too. Any guidance on this? Thanks, D

DaveSimmons1234 avatar Jan 20 '19 17:01 DaveSimmons1234

Yup same here. Only workaround AFAIK is to create a new map for each dataset, which is overkill and hard to maintain.

Bummer!

alessandro-newzoo avatar Dec 10 '19 13:12 alessandro-newzoo