Skip to content

Legend for threshold scale is wrong, suggestions for improvement #22

Description

@wahlatlas

As per the D3 api
https://github.com/mbostock/d3/wiki/Quantitative-Scales#threshold-scales
a threshold scale works like this

var t = d3.scale.threshold().domain([0, 1]).range(['a', 'b', 'c']); 
t(-1) === 'a';
t(0) === 'b';
t(0.5) === 'b';
t(1) === 'c';

However the mapmap.js legend puts a > (greater than) on the lower boundary of a class whereas that threshold is already included in that class (the class starts with the threshold value)

Related, see #11

For a given scale

scale: 'threshold',
domain: [450, 550, 650], 

the correct legend would be

threshold

Obviously this is a little convoluted (German statisticians like to phrase legends in the form of von 450 bis unter 550). Instead one could leave the boundary question ambiguous in using a minimalist legend like Mike Bostock once suggested in http://bl.ocks.org/mbostock/5144735

legend_alternative
If users wanted to find out exact values they always have .hoverInfo. The above legend has the added benefit of visually depicting the value distribution similar to a box-plot (alas the above image is not to scale, see it in action for various distributions at https://www.destatis.de/zensuskarte).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions