Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseScaleRange(spec, scope, params) {
var range = spec.range,
config = scope.config.range;
if (range.signal) {
return scope.signalRef(range.signal);
} else if (isString(range)) {
if (config && config.hasOwnProperty(range)) {
spec = extend({}, spec, {range: config[range]});
return parseScaleRange(spec, scope, params);
} else if (range === 'width') {
range = [0, {signal: 'width'}]
} else if (range === 'height') {
range = isDiscrete(spec.type)
? [0, {signal: 'height'}]
: [{signal: 'height'}, 0]
} else {
error('Unrecognized scale range value: ' + stringValue(range));
}
} else if (range.scheme) {
params.scheme = isArray(range.scheme)
? parseArray(range.scheme, scope)
: parseLiteral(range.scheme, scope);
if (range.extent) params.schemeExtent = parseArray(range.extent, scope);
if (range.count) params.schemeCount = parseLiteral(range.count, scope);
return;
} else if (range.step) {
params.rangeStep = parseLiteral(range.step, scope);
return;
} else if (isDiscrete(spec.type) && !isArray(range)) {
? [0, {signal: 'height'}]
: [{signal: 'height'}, 0]
} else {
error('Unrecognized scale range value: ' + stringValue(range));
}
} else if (range.scheme) {
params.scheme = isArray(range.scheme)
? parseArray(range.scheme, scope)
: parseLiteral(range.scheme, scope);
if (range.extent) params.schemeExtent = parseArray(range.extent, scope);
if (range.count) params.schemeCount = parseLiteral(range.count, scope);
return;
} else if (range.step) {
params.rangeStep = parseLiteral(range.step, scope);
return;
} else if (isDiscrete(spec.type) && !isArray(range)) {
return parseScaleDomain(range, spec, scope);
} else if (!isArray(range)) {
error('Unsupported range type: ' + stringValue(range));
}
return range.map(v => (isArray(v) ? parseArray : parseLiteral)(v, scope));
}
function singularDomain(domain, spec, scope) {
var data = scope.getData(domain.data);
if (!data) dataLookupError(domain.data);
return isDiscrete(spec.type)
? data.valuesRef(scope, domain.field, parseSort(domain.sort, false))
: isQuantile(spec.type) ? data.domainRef(scope, domain.field)
: data.extentRef(scope, domain.field);
}
function multipleDomain(domain, spec, scope) {
var data = domain.data,
fields = domain.fields.reduce(function(dom, d) {
d = isString(d) ? {data: data, field: d}
: (isArray(d) || d.signal) ? fieldRef(d, scope)
: d;
dom.push(d);
return dom;
}, []);
return (isDiscrete(spec.type) ? ordinalMultipleDomain
: isQuantile(spec.type) ? quantileMultipleDomain
: numericMultipleDomain)(domain, scope, fields);
}