There is one more limit than the number of steps
Limits are steps boundaries, and first limit is always the lower value, and latest limit always the bigger.
This commit is contained in:
parent
bf116e8d93
commit
7a0dbd014a
1 changed files with 3 additions and 3 deletions
|
@ -138,16 +138,16 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
|
|||
)
|
||||
this.options.colors = chroma
|
||||
.scale(this.datalayer.options.choropleth.brewer || 'Blues')
|
||||
.colors(this.options.limits.length)
|
||||
.colors(this.options.limits.length - 1)
|
||||
},
|
||||
|
||||
getColor: function (feature) {
|
||||
if (!feature) return // FIXME shold not happen
|
||||
const featureValue = this._getValue(feature)
|
||||
// Find the bucket/step/limit that this value is less than and give it that color
|
||||
for (let i = 0; i < this.options.limits.length; i++) {
|
||||
for (let i = 1; i < this.options.limits.length; i++) {
|
||||
if (featureValue <= this.options.limits[i]) {
|
||||
return this.options.colors[i]
|
||||
return this.options.colors[i-1]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue