How to use the vega-util.splitAccessPath 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 / build / src / util.js View on Github external
export function prefixGenerator(a) {
    const prefixes = new Set();
    for (const x of a) {
        const splitField = splitAccessPath(x);
        // Wrap every element other than the first in `[]`
        const wrappedWithAccessors = splitField.map((y, i) => (i === 0 ? y : `[${y}]`));
        const computedPrefixes = wrappedWithAccessors.map((_, i) => wrappedWithAccessors.slice(0, i + 1).join(''));
        computedPrefixes.forEach(y => prefixes.add(y));
    }
    return prefixes;
}
export function fieldIntersection(a, b) {
github vega / vega-lite / src / util.ts View on Github external
export function prefixGenerator(a: ReadonlySet): ReadonlySet {
  const prefixes = new Set();
  for (const x of a) {
    const splitField = splitAccessPath(x);
    // Wrap every element other than the first in `[]`
    const wrappedWithAccessors = splitField.map((y, i) => (i === 0 ? y : `[${y}]`));
    const computedPrefixes = wrappedWithAccessors.map((_, i) => wrappedWithAccessors.slice(0, i + 1).join(''));
    computedPrefixes.forEach(y => prefixes.add(y));
  }
  return prefixes;
}
github vega / vega / packages / vega-parser / src / parsers / encode / field.js View on Github external
field = ref.parent;
      object += '.datum';
    } else {
      field = ref.group;
    }
  } else if (ref.datum) {
    object = 'datum';
    field = ref.datum;
  } else {
    error('Invalid field reference: ' + stringValue(ref));
  }

  if (!ref.signal) {
    if (isString(field)) {
      fields[field] = 1; // TODO review field tracking?
      field = splitAccessPath(field).map(stringValue).join('][');
    } else {
      field = resolve(field, scope, params, fields);
    }
  }

  return object + '[' + field + ']';
}
github vega / vega-lite / build / src / util.js View on Github external
export function accessPathWithDatum(path, datum = 'datum') {
    const pieces = splitAccessPath(path);
    const prefixes = [];
    for (let i = 1; i <= pieces.length; i++) {
        const prefix = `[${pieces
            .slice(0, i)
            .map(stringValue)
            .join('][')}]`;
        prefixes.push(`${datum}${prefix}`);
    }
    return prefixes.join(' && ');
}
/**
github vega / vega-lite / build / src / util.js View on Github external
export function replacePathInField(path) {
    return `${splitAccessPath(path)
        .map(p => p.replace('.', '\\.'))
        .join('\\.')}`;
}
/**
github vega / vega-lite / build / src / util.js View on Github external
export function accessPathDepth(path) {
    if (!path) {
        return 0;
    }
    return splitAccessPath(path).length;
}
/**
github vega / vega-lite / src / util.ts View on Github external
export function accessPathWithDatum(path: string, datum = 'datum') {
  const pieces = splitAccessPath(path);
  const prefixes = [];
  for (let i = 1; i <= pieces.length; i++) {
    const prefix = `[${pieces
      .slice(0, i)
      .map(stringValue)
      .join('][')}]`;
    prefixes.push(`${datum}${prefix}`);
  }
  return prefixes.join(' && ');
}
github vega / vega-lite / build / src / util.js View on Github external
export function removePathFromField(path) {
    return `${splitAccessPath(path).join('.')}`;
}
/**
github vega / vega-lite / src / util.ts View on Github external
export function flatAccessWithDatum(path: string, datum: 'datum' | 'parent' | 'datum.datum' = 'datum') {
  return `${datum}[${stringValue(splitAccessPath(path).join('.'))}]`;
}