If you want to define manual class breaks with the ramp()
function it seems you're out of luck; as far as I can tell this is not working as intended. For example, here I try to supply different colors for values that fall within user specified ranges
Code:
#layer{
[dominant_origin = "Puerto-Rican"]{
polygon-fill: ramp([relative_dom], (#004c6d, #3d708f, #6996b3, #94bed9, #c1e7ff), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "South American"]{
polygon-fill: ramp([relative_dom], (#ff0000, #ff5d38, #ff8b67, #ffb297, #ffd8cb), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "Central American"]{
polygon-fill: ramp([relative_dom], (#00ff00, #6cfb53, #97f67e, #b7f0a3, #d1eac7), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "Dominican"]{
polygon-fill: ramp([relative_dom], (#ffff00, #fcf853, #f8f17b, #f1eb9d, #e9e4bd), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "Mexican"]{
polygon-fill: ramp([relative_dom], (#7f00ff, #a451ff, #c181ff, #daaeff, #efdbff), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "Other"]{
polygon-fill: ramp([relative_dom], (#000000, #363636, #6a6a6a, #a4a4a4, #e2e2e2), (.2, .4, .6, .8, 1), "<=");
}
[dominant_origin = "Cuban"]{
polygon-fill: ramp([relative_dom], (#e6550d, #f17940, #f99a6b, #feba98, #ffd9c6), (.2, .4, .6, .8, 1), "<=");
}
}
if you console.log() the event on a metaDatachange you get this:
_buckets: Array(5)
0: {min: null, max: 0.2, value: "#004c6d"}
1: {min: 0.2, max: 0.4, value: "#3d708f"}
2: {min: 0.4, max: 0.6, value: "#6996b3"}
3: {min: 0.6, max: 0.8, value: "#94bed9"}
4: {min: 0.8, max: undefined, value: "#c1e7ff"}
If you console.log()
bucket.min
and bucket.max
you'll get:
null
undefined
This is an issue for a few reasons. First you're getting nulls and undefined values for min and max in the first and last bins. Second, the class breaks are not explicit. Lastly, the last value supplied in the filter is ignored.
I know in a previous issue it was suggested to use the "<" mapping instead, but the result is exactly the same.