Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// else if a range scheme is defined, use that
else if (_.scheme) {
range = configureScheme(type, _, count);
if (isFunction(range)) {
if (scale.interpolator) {
return scale.interpolator(range);
} else {
error(`Scale type ${type} does not support interpolating color schemes.`);
}
}
}
// given a range array for an interpolating scale, convert to interpolator
if (range && isInterpolating(type)) {
return scale.interpolator(
interpolateColors(flip(range, _.reverse), _.interpolate, _.interpolateGamma)
);
}
// configure rounding / interpolation
if (range && _.interpolate && scale.interpolate) {
scale.interpolate(getInterpolate(_.interpolate, _.interpolateGamma));
} else if (isFunction(scale.round)) {
scale.round(round);
} else if (isFunction(scale.rangeRound)) {
scale.interpolate(round ? interpolateRound : interpolate);
}
if (range) scale.range(flip(range, _.reverse));
}
function configureScheme(type, _, count) {
var extent = _.schemeExtent,
name, scheme;
if (isArray(_.scheme)) {
scheme = interpolateColors(_.scheme, _.interpolate, _.interpolateGamma);
} else {
name = _.scheme.toLowerCase();
scheme = getScheme(name);
if (!scheme) error(`Unrecognized scheme name: ${_.scheme}`);
}
// determine size for potential discrete range
count = (type === Threshold) ? count + 1
: (type === BinOrdinal) ? count - 1
: (type === Quantile || type === Quantize) ? (+_.schemeCount || DEFAULT_COUNT)
: count;
// adjust and/or quantize scheme as appropriate
return isInterpolating(type) ? adjustScheme(scheme, extent, _.reverse)
: isFunction(scheme) ? quantizeInterpolator(adjustScheme(scheme, extent), count)
: type === Ordinal ? scheme : scheme.slice(0, count);