How to use the vega-util.isString 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 / compile.ts View on Github external
function getTopLevelProperties(
  inputSpec: TopLevel,
  autosize: AutoSizeType | AutoSizeParams,
  config: Config,
  model: Model
) {
  const width = model.component.layoutSize.get('width');
  const height = model.component.layoutSize.get('height');
  if (autosize === undefined) {
    autosize = {type: 'pad'};
  } else if (isString(autosize)) {
    autosize = {type: autosize};
  }
  if (width && height && isFitType(autosize.type)) {
    if (width === 'step' && height === 'step') {
      log.warn(log.message.droppingFit());
      autosize.type = 'pad';
    } else if (width === 'step' || height === 'step') {
      // effectively XOR, because else if

      // get step dimension
      const sizeType = width === 'step' ? 'width' : 'height';
      // log that we're dropping fit for respective channel
      log.warn(log.message.droppingFit(getPositionScaleChannel(sizeType)));

      // setting type to inverse fit (so if we dropped fit-x, type is now fit-y)
      const inverseSizeType = sizeType === 'width' ? 'height' : 'width';
github vega / vega-lite / build / src / compile / data / lookup.js View on Github external
assemble() {
        let foreign;
        if (this.transform.from.fields) {
            // lookup a few fields and add create a flat output
            foreign = Object.assign({ values: this.transform.from.fields }, (this.transform.as ? { as: this.transform.as instanceof Array ? this.transform.as : [this.transform.as] } : {}));
        }
        else {
            // lookup full record and nest it
            let asName = this.transform.as;
            if (!isString(asName)) {
                log.warn(log.message.NO_FIELDS_NEEDS_AS);
                asName = '_lookup';
            }
            foreign = {
                as: [asName]
            };
        }
        return Object.assign({ type: 'lookup', from: this.secondary, key: this.transform.from.key, fields: [this.transform.lookup] }, foreign, (this.transform.default ? { default: this.transform.default } : {}));
    }
}
github vega / vega-lite / build / src / compile / mark / valueref.js View on Github external
export function fieldInvalidPredicate(field, invalid = true) {
    field = isString(field) ? field : vgField(field, { expr: 'datum' });
    const op = invalid ? '||' : '&&';
    const eq = invalid ? '===' : '!==';
    return `${field} ${eq} null ${op} ${invalid ? '' : '!'}isNaN(${field})`;
}
// TODO: we need to find a way to refactor these so that scaleName is a part of scale
github vega / vega / packages / vega-parser / src / DataScope.js View on Github external
function fieldKey(field) {
  return isString(field) ? field : null;
}
github vega / vega-embed / src / embed.ts View on Github external
async function loadOpts(opt: EmbedOptions, loader: Loader): Promise> {
  const config: Config = isString(opt.config) ? JSON.parse(await loader.load(opt.config)) : opt.config ?? {};
  const patch: PatchFunc | Operation[] = isString(opt.patch) ? JSON.parse(await loader.load(opt.patch)) : opt.patch;
  return {
    ...(opt as any),
    ...(patch ? { patch } : {}),
    ...(config ? { config } : {})
  };
}
github vega / vega-lite / src / compile / mark / encode / valueref.ts View on Github external
export function fieldInvalidPredicate(field: FieldName | FieldDef, invalid = true) {
  return fieldValidPredicate(isString(field) ? field : vgField(field, {expr: 'datum'}), !invalid);
}
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-lite / build / src / toplevelprops.js View on Github external
function _normalizeAutoSize(autosize) {
    return isString(autosize) ? { type: autosize } : autosize || {};
}
export function normalizeAutoSize(topLevelAutosize, configAutosize, isUnitOrLayer) {