Skip to content

Commit e28c938

Browse files
committed
Constrain color values within bounds of cmin/cmax
1 parent 9dd98d9 commit e28c938

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/colorscale/make_scale_function.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var d3 = require('d3');
1313
var tinycolor = require('tinycolor2');
1414
var isNumeric = require('fast-isnumeric');
1515

16+
var Lib = require('../../lib');
1617
var Color = require('../color');
1718

1819

@@ -34,7 +35,10 @@ module.exports = function makeScaleFunction(scl, cmin, cmax) {
3435
.range(range);
3536

3637
return function(v) {
37-
if(isNumeric(v)) return sclFunc(v);
38+
if(isNumeric(v)) {
39+
var sclVal = Lib.constrain(v, cmin, cmax);
40+
return sclFunc(sclVal);
41+
}
3842
else if(tinycolor(v).isValid()) return v;
3943
else return Color.defaultLine;
4044
};

0 commit comments

Comments
 (0)