How to use the vega-util.array 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-dataflow / src / transforms / aggregate / Aggregate.js View on Github external
outputs = (this._outputs = []),
      inputMap = {};

  function inputVisit(get) {
    var fields = array(accessorFields(get)),
        i = 0, n = fields.length, f;
    for (; i
github vega / vega-lite / src / compile / mark / valueref.ts View on Github external
function add(fDef: TypedFieldDef | SecondaryFieldDef, channel: Channel) {
    const mainChannel = getMainRangeChannel(channel);

    const fieldDef: TypedFieldDef = isTypedFieldDef(fDef)
      ? fDef
      : {
          ...fDef,
          type: encoding[mainChannel].type // for secondary field def, copy type from main channel
        };

    const key = array(title(fieldDef, config, {allowDisabling: false})).join(', ');

    let value = text(fieldDef, config, expr).signal;

    if (channel === 'x' || channel === 'y') {
      const channel2 = channel === 'x' ? 'x2' : 'y2';
      const fieldDef2 = getFieldDef(encoding[channel2]);

      if (isBinned(fieldDef.bin) && fieldDef2) {
        const startField = vgField(fieldDef, {expr});
        const endField = vgField(fieldDef2, {expr});
        value = binFormatExpression(startField, endField, format(fieldDef), config);
        toSkip[channel2] = true;
      }
    }

    tooltipTuples.push({channel, key, value});
github vega / vega-lite / build / src / compile / mark / mixins.js View on Github external
function wrapAllFieldsInvalid(model, channel, valueRef) {
    const { config, mark } = model;
    if (config.invalidValues === 'hide' && valueRef && !isPathMark(mark)) {
        // For non-path marks, we have to exclude invalid values (null and NaN) for scales with continuous domains.
        // For path marks, we will use "defined" property and skip these values instead.
        const test = allFieldsInvalidPredicate(model, { invalid: true, channels: SCALE_CHANNELS });
        if (test) {
            return {
                [channel]: [
                    // prepend the invalid case
                    // TODO: support custom value
                    { test, value: null },
                    ...array(valueRef)
                ]
            };
        }
    }
    return valueRef ? { [channel]: valueRef } : {};
}
function markDefProperties(mark, ignore) {
github vega / vega / packages / vega-parser / src / parsers / data.js View on Github external
} else if (data.url) {
    // load data from external source
    if (hasSignal(data.url) || hasSignal(data.format)) {
      // if either url or format has signal, use dynamic loader
      output.push(load(scope, data));
      output.push(source = collect());
    } else {
      // otherwise, request load upon dataflow init
      output.push(source = collect({
        $request: data.url,
        $format: data.format
      }));
    }
  } else if (data.source) {
    // derives from one or more other data sets
    source = upstream = array(data.source).map(function(d) {
      return ref(scope.getData(d).output);
    });
    output.push(null); // populate later
  }

  // scan data transforms, add collectors as needed
  for (i=0, n=ops.length; i
github vega / vega-dataflow / src / layout / Force.js View on Github external
function setup(sim, _, init) {
  var f = array(_.forces), i, n, p;

  for (i=0, n=ForceParams.length; i
github vega / vega / packages / vega-parser / src / parsers / view.js View on Github external
function addSignals(scope, signals, config) {
  // signals defined in the spec take priority
  array(signals).forEach(_ => {
    if (!defined[_.name]) parseSignal(_, scope)
  });

  if (!config) return signals;
  const out = array(signals).slice();

  // add config signals if not already defined
  array(config).forEach(_ => {
    if (!scope.hasOwnSignal(_.name)) {
      parseSignal(_, scope);
      out.push(_);
    }
  });

  return out;
}
github vega / vega / packages / vega-functions / src / intersect.js View on Github external
function filter(opt) {
  let p = null;

  if (opt) {
    const types = array(opt.marktype),
          names = array(opt.markname);
    p = _ => (!types.length || types.some(t => _.marktype === t))
          && (!names.length || names.some(s => _.name === s));
  }

  return p;
}
github vega / vega / packages / vega-transforms / src / util / WindowState.js View on Github external
export default function WindowState(_) {
  let self = this,
      ops = array(_.ops),
      fields = array(_.fields),
      params = array(_.params),
      as = array(_.as),
      outputs = self.outputs = [],
      windows = self.windows = [],
      inputs = {},
      map = {},
      countOnly = true,
      counts = [],
      measures = [];

  function visitInputs(f) {
    array(accessorFields(f)).forEach(_ => inputs[_] = 1);
  }
  visitInputs(_.sort);