Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// we can omit the domain as it is inferred from the `bins` property
return makeImplicit([]);
}
// ordinal bin scale takes domain from bin_range, ordered by bin start
// This is useful for both axis-based scale (x/y) and legend-based scale (other channels).
return makeImplicit([
{
// If sort by aggregation of a specified sort field, we need to use RAW table,
// so we can aggregate values for the scale independently from the main aggregation.
data: util.isBoolean(sort) ? model.requestDataName(MAIN) : model.requestDataName(RAW),
// Use range if we added it and the scale does not support computing a range as a signal.
field: model.vgField(channel, binRequiresRange(fieldDef, channel) ? {binSuffix: 'range'} : {}),
// we have to use a sort object if sort = true to make the sort correct by bin start
sort:
sort === true || !isObject(sort)
? {
field: model.vgField(channel, {}),
op: 'min' // min or max doesn't matter since we sort by the start of the bin range
}
: sort
}
]);
} else {
// continuous scales
const {bin} = fieldDef;
if (isBinning(bin)) {
const binSignal = getBinSignalName(model, fieldDef.field, bin);
return makeImplicit([
new SignalRefWrapper(() => {
const signal = model.getSignalName(binSignal);
return `[${signal}.start, ${signal}.stop]`;
function permit(view, key, type) {
const rule = view._eventConfig && view._eventConfig[key];
if (rule === false || (isObject(rule) && !rule[type])) {
view.warn(`Blocked ${key} ${type} event listener.`);
return false;
}
return true;
}
function toField(value) {
if (value && isFunction(value.toObject)) {
value = value.toObject();
}
return isString(value) ? field(value)
: isObject(value) && !isFunction(value)
? isFunction(value.accessor)
? accessor(value.accessor, value.fields, value.as)
: field(value.field, value.as)
: null;
}
compare: p => (value => {
let cmp = value;
if (cmp && isFunction(cmp.toObject)) {
cmp = cmp.toObject();
}
if (isString(cmp)) cmp = array(cmp);
if (isArray(cmp)) cmp = toCompareObject(cmp);
return isObject(cmp) && !isFunction(cmp)
? isFunction(cmp.accessor)
? accessor(cmp.accessor, cmp.fields)
: compare(cmp.fields, cmp.orders)
: error(`Unrecognized comparator value for parameter: ${p.name}.`);
}),
export default function(spec, config) {
spec = spec || config.padding;
return isObject(spec)
? {
top: number(spec.top),
bottom: number(spec.bottom),
left: number(spec.left),
right: number(spec.right)
}
: paddingObject(number(spec));
}
function scale(name, ctx) {
var s = isString(name) ? ctx.scales[name]
: isObject(name) && name.signal ? ctx.signals[name.signal]
: undefined;
return s && s.value;
}
function equal(a, b) {
return a === b || a !== a && b !== b ? true
: isArray(a) ? (
isArray(b) && a.length === b.length ? equalArray(a, b) : false
)
: isObject(a) && isObject(b) ? equalObject(a, b)
: false;
}
export default function json(data, format) {
const prop = (format && format.property) ? field(format.property) : identity;
return isObject(data) && !isBuffer(data)
? parseJSON(prop(data))
: prop(JSON.parse(data));
}
export function isStep(size: number | Step | 'container' | 'merged'): size is Step {
return isObject(size) && size['step'] !== undefined;
}