Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function configureRangeStep(type, _, count) {
if (type !== Band && type !== Point) {
error('Only band and point scales support rangeStep.');
}
// calculate full range based on requested step size and padding
var outer = (_.paddingOuter != null ? _.paddingOuter : _.padding) || 0,
inner = type === Point ? 1
: ((_.paddingInner != null ? _.paddingInner : _.padding) || 0);
return [0, _.rangeStep * bandSpace(count, inner, outer)];
}
export function selectionVisitor(name, args, scope, params) {
if (args[0].type !== Literal) error('First argument to selection functions must be a string literal.');
const data = args[0].value,
op = args.length >= 2 && peek(args).value,
field = 'unit',
indexName = IndexPrefix + field,
dataName = DataPrefix + data;
// eslint-disable-next-line no-prototype-builtins
if (op === Intersect && !hasOwnProperty(params, indexName)) {
params[indexName] = scope.getData(data).indataRef(scope, field);
}
// eslint-disable-next-line no-prototype-builtins
if (!hasOwnProperty(params, dataName)) {
params[dataName] = scope.getData(data).tuplesRef();
}
export default function parse(def, data) {
var func = def[FUNCTION];
if (!Distributions.hasOwnProperty(func)) {
error('Unknown distribution function: ' + func);
}
var d = Distributions[func]();
for (var name in def) {
// if data field, extract values
if (name === FIELD) {
d.data((def.from || data()).map(def[name]));
}
// if distribution mixture, recurse to parse each definition
else if (name === DISTRIBUTIONS) {
d[name](def[name].map(function(_) { return parse(_, data); }));
}
// otherwise, simply set the parameter
function parseIndexParameter(def, spec, scope) {
if (!isString(spec.from)) {
error('Lookup "from" parameter must be a string literal.');
}
return scope.getData(spec.from).lookupRef(scope, spec.key);
}
ntile: function(field, num) {
num = +num;
if (!(num > 0)) error('ntile num must be greater than zero.');
let cume = WindowOps.cume_dist(),
next = cume.next;
return {
init: cume.init,
next: w => Math.ceil(num * next(w))
};
},
prototype.renderer = function(type) {
if (!arguments.length) return this._renderType;
if (!renderModule(type)) error('Unrecognized renderer type: ' + type);
if (type !== this._renderType) {
this._renderType = type;
if (this._renderer) {
this._renderer = null;
this.initialize(this._el);
}
}
return this;
};
x.method = function(_) {
if (Tiles.hasOwnProperty(_)) x.tile(Tiles[_]);
else error('Unrecognized Treemap layout method: ' + _);
};
return x;
function create(type) {
var constructor = projection((type || 'mercator').toLowerCase());
if (!constructor) error('Unrecognized projection type: ' + type);
return constructor();
}
function getValue(_) {
var m = _.method || Methods.value, v;
if (Methods[m] == null) {
error('Unrecognized imputation method: ' + m);
} else if (m === Methods.value) {
v = _.value !== undefined ? _.value : 0;
return function() { return v; };
} else {
return Methods[m];
}
}
function tuplesVisitor(name, args, scope, params) {
if (args[0].type !== Literal) error('First argument to tuples must be a string literal.');
var data = args[0].value,
dataName = tuplePrefix + data;
if (!params.hasOwnProperty(dataName)) {
params[dataName] = scope.getData(data).tuplesRef();
}
}