How to use the vega.inherits 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 / transforms / manipulators / Line.js View on Github external
*
 * @description The LineManipulators calculates manipulators when a Line
 * mark instance is selected.
 * @extends Manipulators
 *
 * @param {Model} graph - A Vega model.
 *
 * @constructor
 */
export default function LineManipulators(params) {
  Manipulators.call(this, [], params);
}

LineManipulators.Definition = extend({}, Manipulators.Definition);

const prototype = inherits(LineManipulators, Manipulators);

prototype.handles = function(item) {
  const bounds = item.mark.bounds;
  const c = coords(bounds, 'handle');
  return [
    c.topLeft, c.topRight,
    c.bottomLeft, c.bottomRight
  ];
};

prototype.connectors = function(item) {
  const bounds = item.mark.bounds;
  const c = coords(bounds, 'connector');
  return [c.midCenter];
};
github vega / lyra / src / js / transforms / manipulators / Manipulators.js View on Github external
*/
export default function Manipulators(params) {
  Transform.call(this, [], params);
}

Manipulators.Definition = {
  metadata: {source: true, changes: true},
  params: [
    {name: 'lyra_id', type: 'number', required: true},
    {name: 'lyra_selected', required: true},
    {name: 'lyra_mode', required: true},
    {name: 'signals', array: true}
  ]
}

const prototype = inherits(Manipulators, Transform);

/**
 * The transform method is automatically called by Vega whenever the manipulator
 * coordinates need to be recalculated (e.g., when a new mark item is selected).
 * @param {Object} input - A Vega-Dataflow ChangeSet.
 * @returns {Object} output - A Vega-Dataflow ChangeSet.
 */
prototype.transform = function(_, pulse) {
  const cache = this.value || [];
  const out = pulse.fork(pulse.NO_FIELDS & pulse.NO_SOURCE);
  const lyraId = _.lyra_id;
  const item = _.lyra_selected;
  const mode = _.lyra_mode;
  const role = item.mark.role;
  const itemId = tupleid(item);
github vega / lyra / src / js / transforms / manipulators / Rect.js View on Github external
/**
 * @classdesc Represents the RectManipulators, a Vega data transformation operator.
 *
 * @description The RectManipulators calculates manipulators when a rect mark
 * instance is selected.
 * @extends Manipulators
 * @param {Model} graph - A Vega model.
 * @constructor
 */
export default function RectManipulators(params) {
  Manipulators.call(this, [], params);
}

RectManipulators.Definition = extend({}, Manipulators.Definition);

const prototype = inherits(RectManipulators, Manipulators);

prototype.handles = function(item) {
  const c = coords(item.bounds, 'handle');
  return Object.values(c).filter(x => x.key !== 'midCenter');
};

prototype.connectors = function(item) {
  return Object.values(coords(item.bounds, 'connector'));
};

prototype.channels = function(item) {
  var b = item.bounds,
      gb = item.mark.group.bounds,
      c = coords(b),
      tl = c.topLeft,
      tr = c.topRight,
github vega / lyra / src / js / transforms / manipulators / Symbol.js View on Github external
/**
 * @classdesc Represents the SymbolManipulators, a Vega data transformation operator.
 * @param {Model} graph - A Vega model.
 * @description The SymbolManipulators calculates manipulators when a symbol
 * mark instance is selected.
 * @extends Manipulators
 * @constructor
 */
export default function SymbolManipulators(params) {
  Manipulators.call(this, [], params);
}

SymbolManipulators.Definition = extend({}, Manipulators.Definition);

const prototype = inherits(SymbolManipulators, Manipulators);

prototype.handles = function(item) {
  var c = coords(item.bounds, 'handle');
  return [
    c.topLeft, c.topRight,
    c.bottomLeft, c.bottomRight
  ];
};

prototype.connectors = function(item) {
  var c = coords(item.bounds, 'connector');
  return [c.midCenter];
};

prototype.channels = function(item) {
  var b = item.bounds,
github vega / lyra / src / js / transforms / manipulators / Text.js View on Github external
* @classdesc Represents the TextManipulators, a Vega data transformation operator.
 *
 * @description The TextManipulators calculates manipulators when a text mark
 * instance is selected.
 * @extends Manipulators
 *
 * @constructor
 * @param {Object} graph - A Vega model.
 */
export default function TextManipulators(params) {
  Manipulators.call(this, [], params);
}

TextManipulators.Definition = extend({}, Manipulators.Definition);

const prototype = inherits(TextManipulators, Manipulators);

prototype.handles = function(item) {
  var c = coords(item.bounds, 'handle');
  return [
    c.topLeft,
    c.bottomRight
  ];
};

prototype.connectors = function(item) {
  var c = coords(item.bounds, 'connector');
  return [c.midCenter];
};

prototype.channels = function(item) {
  var b = item.bounds,
github omnisci / vega-transform-omnisci-core / index.js View on Github external
QueryCore.session = function(session) {
  if (session) {
    this._session = session;
    return this;
  }

  return this._session;
};

QueryCore.Definition = {
  type: "QueryCore",
  metadata: { changes: true, source: true },
  params: [{ name: "query", type: "string", required: true }]
};

const prototype = inherits(QueryCore, Transform);

prototype.transform = async function(_, pulse) {
    if (!QueryCore._session) {
    throw Error(
      "OmniSci Core session missing. Please assign it to the vega transform by calling `QueryCore.session(session).`"
    );
  }

  const result = await QueryCore._session.queryAsync(_.query);

  result.forEach(ingest);

  const out = pulse.fork(pulse.NO_FIELDS & pulse.NO_SOURCE);
  out.rem = this.value;
  this.value = out.add = out.source = result;
github vega / lyra / src / js / transforms / manipulators / Area.js View on Github external
*
 * @description The AreaManipulators calculates manipulators when a Area
 * mark instance is selected.
 * @extends Manipulators
 *
 * @param {Model} graph - A Vega model.
 *
 * @constructor
 */
export default function AreaManipulators(params) {
  Manipulators.call(this, [], params);
}

AreaManipulators.Definition = extend({}, Manipulators.Definition);

const prototype = inherits(AreaManipulators, Manipulators);

prototype.handles = function(item) {
  const bounds = item.mark.bounds;
  const c = coords(bounds, 'handle');
  return [
    c.topLeft, c.topRight,
    c.bottomLeft, c.bottomRight
  ];
};

prototype.connectors = function(item) {
  const bounds = item.mark.bounds;
  const c = coords(bounds, 'connector');
  return [c.midCenter];
};