Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function replaceRepeater(mapping: EncodingOrFacet, repeater: RepeaterValue): EncodingOrFacet {
const out: EncodingOrFacet = {};
for (const channel in mapping) {
if (hasOwnProperty(mapping, channel)) {
const channelDef: ChannelDef> | ChannelDef>[] = mapping[channel];
if (isArray(channelDef)) {
// array cannot have condition
out[channel] = channelDef.map(cd => replaceRepeaterInChannelDef(cd, repeater)).filter(cd => cd);
} else {
const cd = replaceRepeaterInChannelDef(channelDef, repeater);
if (cd !== undefined) {
out[channel] = cd;
}
}
}
}
return out;
}
export function getScale(name, scope, params, fields) {
var scaleName;
if (isString(name)) {
// direct scale lookup; add scale as parameter
scaleName = ScalePrefix + name;
if (!hasOwnProperty(params, scaleName)) {
params[scaleName] = scope.scaleRef(name);
}
scaleName = stringValue(scaleName);
} else {
// indirect scale lookup; add all scales as parameters
for (scaleName in scope.scales) {
params[ScalePrefix + scaleName] = scope.scaleRef(scaleName);
}
scaleName = stringValue(ScalePrefix) + '+'
+ (name.signal
? '(' + expression(name.signal, scope, params, fields) + ')'
: field(name, scope, params, fields));
}
return '_[' + scaleName + ']';
}
const allPropertiesShared = every(PROJECTION_PROPERTIES, prop => {
// neither has the property
if (!hasOwnProperty(first.explicit, prop) && !hasOwnProperty(second.explicit, prop)) {
return true;
}
// both have property and an equal value for property
if (
hasOwnProperty(first.explicit, prop) &&
hasOwnProperty(second.explicit, prop) &&
// some properties might be signals or objects and require hashing for comparison
stringify(first.get(prop)) === stringify(second.get(prop))
) {
return true;
}
return false;
});
function customSymbol(path) {
if (!hasOwnProperty(custom, path)) {
var parsed = pathParse(path);
custom[path] = {
draw: function(context, size) {
pathRender(context, parsed, 0, 0, Math.sqrt(size) / 2);
}
};
}
return custom[path];
}
export default function(data, schema, dateParse) {
schema = schema || {};
const reader = formats(schema.type || 'json');
if (!reader) error('Unknown data format type: ' + schema.type);
data = reader(data, schema);
if (schema.parse) parse(data, schema.parse, dateParse);
if (hasOwnProperty(data, 'columns')) delete data.columns;
return data;
}
export function isValidScaleType(type) {
return hasOwnProperty(scales, type);
}
export function extendEncode(encode, extra, skip) {
for (var name in extra) {
if (skip && hasOwnProperty(skip, name)) continue;
encode[name] = extend(encode[name] || {}, extra[name]);
}
return encode;
}
export function forEachSelection(
model: Model,
cb: (selCmpt: SelectionComponent, selCompiler: SelectionCompiler) => void | boolean
) {
const selections = model.component.selection;
if (selections) {
for (const name in selections) {
if (hasOwnProperty(selections, name)) {
const sel = selections[name];
const success = cb(sel, compilers[sel.type]);
if (success === true) break;
}
}
}
}
export function scale(name) {
var scales = this._runtime.scales;
if (!hasOwnProperty(scales, name)) {
error('Unrecognized scale or projection: ' + name);
}
return scales[name].value;
}