-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle undefined, empty and invalid field values correctly #23
Comments
I have added two new metadata fields, This is in the master branch now and also in the documentation, and will be in the next release. |
The
Now, as far as I can see, the On the other hand, in the Linz case, there is some data present (id, city, moredata), but vor the 'data' variable, no value is present. I can only guess that the way One could argue that the empty data fields should be edited with undefined values, but in larger datasets (e.g. Germany's 11 thousand municipalities) it is easy to overlook such cases and mapmap.js is probably aimed at people who don't analyse their data with R before (map)mapping it. |
Thanks for going into the details of this and for the (undeserved) compliment - personally I am not very happy with just accumulating "special" stuff in the metadata, and I currently believe things like the color scale should actually go into options to the symbolization function(s). But that is a slightly different topic and would go into a refactoring of the symbolization pipeline scheduled for v0.3. (#25) I absolutely agree with you that missing field values in the CSV file should be interpreted as I am not sure about these "special" values for numeric fields however - it feels a lot like a "hack" to overcome the limitations of CSV files. But I already learned from studying real world map legends (and when refactoring the legend generation code in mapmap recently) that actually legends often use "nested" scales even for simple choropleth maps, with a numeric/quantizing scale as the main scale, but a "higher-level" ordinal scale for mapping undefined values and possibly other special cases ("not applicable" "under investigation" etc.) - this goes beyond the current capabilities of d3 scales and therefore would need a refactoring of the scale code and probably our own scales implementation. |
Ok, I see why that 'special' value idea doesn't fit the d3 scale model. Let me nevertheless extend the undefined issue here
In the case of Salzburg the value of data '-' is not taken into consideration by mapmap.js, the fill for it is transparent and it doesn't influence the legend. However |
I see the point. I am currently following this approach: attempt to convert strings that strictly look like a number (no extra non-numeric characters, no This way, we could theoretically distinguish even 4 special cases:
I am tending to treat all four cases as I would never have thought this will get so complicated, and neither JS's barely existing and terribly fragile type system nor D3's quite limited and opaque scale model are helping, unfortunately. In the future we may need to provide our own, extended scale framework (quite sure about this) and may even think about adding type information / field converters to the metadata (not sure if I want to go down that route, though...) |
OK with the last commit all 4 cases (missing-, Please refer to #25 for future enhancements or open a new issue for more advance handling of special values. |
Yup, works like a charm now, just tested it. This is a very sensible solution, thanks so much and I can understand you want to devote your time on other aspects of mapmap. It might be nitpicking – and I am not even sure how important it is – but the legend for undefined values gets always drawn, once you've provided metadata for it, even if the current map doesn't contain undefined values. Will keep an eye on the new legend customization. |
You can hide the undefined legend cell if no undefined values are present through CSS: .legendCell.undefined[data-count="0"] {
display: none;
} :) It was a conscious decision to always output the legend cell for all classes defined in the metadata, as for maps where you can switch the visualized field it may be nicer to have all legend items available at all times for a more stable layout. This technique can be generally applied to legend cells btw., e.g. .legendCell[data-count="0"] {
opacity: 0.5;
} to fade out cells with no corresponding values as we did on this map. And don't stop the nitpicking, although, yes, it's a PITA to work on stuff like this I believe the basics are important for a successful library, and for me it's impossible to think about all use cases. Thanks for taking the time to test! |
This is very interesting and flexible what you can do here in css, I already successfully tried it out. Upon testing the latest commits for #23 I see an issue that undefined values seem to harm the Furthermore the histogram count seems to be off for undefined values, see the last example in
where you have 3 districts with no data but the histogram count shows 0 although the histogram bar seems quite right |
OK the problem in the mapmap-examples seems to be that I forgot to commit the latest mapmap version to be incuded in the examples repo - can you please check, this should work now. Regarding quantile scales, I consider quantile scales to be kind of unsupported, as they are intended to be fed some actual data as the domain: "the input domain is specified as a discrete set of values" (D3 docs), which will not have been loaded yet when you define the metadata. (This is also related to #12 - eventually we should support specifying the domain with a callback that will be called once the data is loaded to support such dynamic domains). But still I tried to set up a dummy quantile scale, passing it some hardcoded values in the domain, and it worked without problems even with the undefined values file, so can you check with the latest version from master? If you indeed have a testcase where the quantile scale doesn't work as expected, can you please post a test case, possibly in a new issue as this one is already getting quite long... You can post your test case as a pull request against the examples-repo if you want. |
This is all very good and you've fixed everyhing that I could wish for: The histogram count in Furthermore the |
In case data is not present for a given area, that area gets colored as if it belonged to the lowest class, which is wrong. This is different from missing value handling (#20). Imagine election results coming in during the vote count: The map must show where there is no data (yet), e.g. a grey or otherwise defined background color. "Missing value" on the other hand usually is an encoded value (e.g. -99) and indicates that for reasons within the data there will be no value.
See this example where I deliberately deleted a third of the data in the csv.
http://vis.uell.net/mapmap/test_026incomplete.html
The only way to find out is that the
.hoverInfo
tooltip stays empty.The text was updated successfully, but these errors were encountered: