How to use the vega-util.isObject function in vega-util

To help you get started, we’ve selected a few vega-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vega / vega-lite / src / compile / scale / domain.ts View on Github external
// 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]`;
github vega / vega / packages / vega-view / src / events.js View on Github external
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;
}
github vega / dataflow-api / src / parameters.js View on Github external
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;
}
github vega / dataflow-api / src / parameters.js View on Github external
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}.`);
  }),
github vega / vega / packages / vega-parser / src / parsers / padding.js View on Github external
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));
}
github vega / vega / src / view / runtime.js View on Github external
function scale(name, ctx) {
  var s = isString(name) ? ctx.scales[name]
    : isObject(name) && name.signal ? ctx.signals[name.signal]
    : undefined;
  return s && s.value;
}
github vega / vega / packages / vega-functions / src / modify.js View on Github external
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;
}
github vega / vega / packages / vega-loader / src / formats / json.js View on Github external
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));
}
github vega / vega-lite / src / spec / base.ts View on Github external
export function isStep(size: number | Step | 'container' | 'merged'): size is Step {
  return isObject(size) && size['step'] !== undefined;
}