fix: do not ask more classes than available values in choropleth

It actually does not make sense, and it's a sanity check: some
computation algorithms fail in this situation.
This commit is contained in:
Yohan Boniface 2024-01-22 11:09:30 +01:00
parent 7729035288
commit d696fe885f

View file

@ -194,6 +194,7 @@ L.U.Layer.Choropleth = L.FeatureGroup.extend({
let mode = this.datalayer.options.choropleth.mode, let mode = this.datalayer.options.choropleth.mode,
classes = +this.datalayer.options.choropleth.classes || 5, classes = +this.datalayer.options.choropleth.classes || 5,
breaks breaks
classes = Math.min(classes, values.length)
if (mode === 'manual') { if (mode === 'manual') {
const manualBreaks = this.datalayer.options.choropleth.breaks const manualBreaks = this.datalayer.options.choropleth.breaks
if (manualBreaks) { if (manualBreaks) {