Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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};
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;
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;
};
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;
};
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);
}
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;
};