How to use the vega-util.hasOwnProperty 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 / repeater.ts View on Github external
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;
}
github vega / vega / packages / vega-parser / src / parsers / encode / scale.js View on Github external
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 + ']';
}
github vega / vega-lite / src / compile / projection / parse.ts View on Github external
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;
  });
github vega / vega / packages / vega-scenegraph / src / path / symbols.js View on Github external
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];
}
github vega / vega / packages / vega-loader / src / read.js View on Github external
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;
}
github vega / vega / packages / vega-scale / src / scales.js View on Github external
export function isValidScaleType(type) {
  return hasOwnProperty(scales, type);
}
github vega / vega / packages / vega-parser / src / parsers / encode / encode-util.js View on Github external
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;
}
github vega / vega-lite / src / compile / selection / index.ts View on Github external
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;
      }
    }
  }
}
github vega / vega / packages / vega-view / src / scale.js View on Github external
export function scale(name) {
  var scales = this._runtime.scales;
  if (!hasOwnProperty(scales, name)) {
    error('Unrecognized scale or projection: ' + name);
  }
  return scales[name].value;
}