datamaps
datamaps copied to clipboard
Map Update Issue (V0.4.4)
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 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
See this example: https://jsfiddle.net/gmeroz/a3cc80xb/
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 thanks. Looks like a bug.
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.
I have just come across this problem too. Any guidance on this? Thanks, D
Yup same here. Only workaround AFAIK is to create a new map for each dataset, which is overkill and hard to maintain.
Bummer!