diff --git a/src/model/ColorLegend.js b/src/model/ColorLegend.js index e79015c9..25a13b0c 100644 --- a/src/model/ColorLegend.js +++ b/src/model/ColorLegend.js @@ -28,8 +28,17 @@ export default class ColorLegend { calculateLegend(decimals=0) { - const factor = Math.pow(10, decimals); + if ((this._max - this._min) === 0) { + let legend = []; + legend.unshift({ + color: this._spectrum[0], + value: 0 + }); + return legend; + } + + const factor = Math.pow(10, decimals); const nrOfColors = this._spectrum.length; const delta = (this._max - this._min) / nrOfColors;