From 7a0dbd014a5e88aeeea58db26910779e28d7e111 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 12 Jun 2023 15:53:33 +0200 Subject: [PATCH] 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. --- umap/static/umap/js/umap.layer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 24e005c2..54cdbe23 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -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] } } },