How to use the vega.compare function in vega

To help you get started, we’ve selected a few vega 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 / lyra / src / js / actions / bindChannel / parseMarks.ts View on Github external
map = parsed.map.marks[markId],
    max = channel + '2',
    cntr = channel + 'c',
    span = RECT_SPANS[channel],
    EXTENTS = Object.values(MARK_EXTENTS[channel]),
    props = getInVis(state, `marks.${markId}.encode.update`);

  let count = 0;

  // If we're binding a literal spatial property (i.e., not arrow manipulators),
  // bind only that property.
  if (property !== `${channel}+`) {
    // Ensure that only two spatial properties will be set. We sort them to
    // try our best guess for disabling "older" properties.
    EXTENTS.map(ext => extend({}, {ts: (map && map[ext.name]) || 0}, ext))
      .sort(compare('ts', 'descending'))
      .forEach((ext: any) => {
        const name = ext.name;
        if (name === property) {
          return;
        } else if (count >= 1) {
          dispatch(disableMarkVisual(name, markId));
        } else if (!props[name]._disabled) {
          ++count;
        }
      });

    def[property] = def[channel] || def[cntr] || def[property];
    return bindProperty(dispatch, parsed, def);
  }

  // Clean slate the rect spatial properties by disabling them all. Subsequent