MCPcopy Index your code
hub / github.com/plotly/plotly.js / isValidScaleArray

Function isValidScaleArray

src/components/colorscale/scales.js:161–181  ·  view source on GitHub ↗
(scl)

Source from the content-addressed store, hash-verified

159
160
161function isValidScaleArray(scl) {
162 var highestVal = 0;
163
164 if(!Array.isArray(scl) || scl.length < 2) return false;
165
166 if(!scl[0] || !scl[scl.length - 1]) return false;
167
168 if(+scl[0][0] !== 0 || +scl[scl.length - 1][0] !== 1) return false;
169
170 for(var i = 0; i < scl.length; i++) {
171 var si = scl[i];
172
173 if(si.length !== 2 || +si[0] < highestVal || !tinycolor(si[1]).isValid()) {
174 return false;
175 }
176
177 highestVal = +si[0];
178 }
179
180 return true;
181}
182
183function isValidScale(scl) {
184 if(scales[scl] !== undefined) return true;

Callers 2

getScaleFunction · 0.70
isValidScaleFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…