How to use the vega-scenegraph.renderModule function in vega-scenegraph

To help you get started, we’ve selected a few vega-scenegraph examples, based on popular ways it is used in public projects.

github vega / vega-webgl-renderer / index.js View on Github external
import {CanvasHandler, renderModule} from 'vega-scenegraph';
import {default as WebGLRenderer} from './src/WebGLRenderer';

// Patch CanvasHandler
CanvasHandler.prototype.context = function() {
  return this._canvas.getContext('2d') || this._canvas._textCanvas.getContext('2d');
};

renderModule('webgl', {handler: CanvasHandler, renderer: WebGLRenderer});

export {WebGLRenderer};
github vega / vega / packages / vega-view / src / initialize.js View on Github external
export default function(el, elBind) {
  var view = this,
      type = view._renderType,
      config = view._eventConfig.bind,
      module = renderModule(type),
      Handler, Renderer;

  // containing dom element
  el = view._el = el ? lookup(view, el) : null;

  // select appropriate renderer & handler
  if (!module) view.error('Unrecognized renderer type: ' + type);
  Handler = module.handler || CanvasHandler;
  Renderer = (el ? module.renderer : module.headless);

  // initialize renderer and input handler
  view._renderer = !Renderer ? null
    : initializeRenderer(view, view._renderer, el, Renderer);
  view._handler = initializeHandler(view, view._handler, el, Handler);
  view._redraw = true;
github vega / vega / packages / vega-view / src / View.js View on Github external
prototype.renderer = function(type) {
  if (!arguments.length) return this._renderType;
  if (!renderModule(type)) error('Unrecognized renderer type: ' + type);
  if (type !== this._renderType) {
    this._renderType = type;
    this._resetRenderer();
  }
  return this;
};
github vega / vega-view / src / View.js View on Github external
prototype.renderer = function(type) {
  if (!arguments.length) return this._renderType;
  if (!renderModule(type)) error('Unrecognized renderer type: ' + type);
  if (type !== this._renderType) {
    this._renderType = type;
    if (this._renderer) {
      this._renderer = null;
      this.initialize(this._el);
    }
  }
  return this;
};
github vega / vega / packages / vega-view / src / render-headless.js View on Github external
export default async function(view, type, scaleFactor, opt) {
  const module = renderModule(type),
        ctr = module && module.headless;

  if (!ctr) error('Unrecognized renderer type: ' + type);

  await view.runAsync();
  return initializeRenderer(view, null, null, ctr, scaleFactor, opt)
    .renderAsync(view._scenegraph.root);
}
github vega / vega / packages / vega-view / src / View.js View on Github external
prototype.renderer = function(type) {
  if (!arguments.length) return this._renderType;
  if (!renderModule(type)) error('Unrecognized renderer type: ' + type);
  if (type !== this._renderType) {
    this._renderType = type;
    this._resetRenderer();
  }
  return this;
};