MCPcopy Index your code
hub / github.com/microsoft/SandDance / View

Function View

docs/app/js/sanddance-app.js:142437–142489  ·  view source on GitHub ↗

* Create a new View instance from a Vega dataflow runtime specification. * The generated View will not immediately be ready for display. Callers * should also invoke the initialize method (e.g., to set the parent * DOM element in browser-based deployment) and then invoke the run * method to eval

(spec, options)

Source from the content-addressed store, hash-verified

142435 * @constructor
142436 * @param {object} spec - The Vega dataflow runtime specification.
142437 */ function View(spec, options) {
142438 const view = this;
142439 options = options || {};
142440 (0, _vegaDataflow.Dataflow).call(view);
142441 if (options.loader) view.loader(options.loader);
142442 if (options.logger) view.logger(options.logger);
142443 if (options.logLevel != null) view.logLevel(options.logLevel);
142444 if (options.locale || spec.locale) {
142445 const loc = (0, _vegaUtil.extend)({}, spec.locale, options.locale);
142446 view.locale((0, _vegaFormat.locale)(loc.number, loc.time));
142447 }
142448 view._el = null;
142449 view._elBind = null;
142450 view._renderType = options.renderer || (0, _vegaScenegraph.RenderType).Canvas;
142451 view._scenegraph = new (0, _vegaScenegraph.Scenegraph)();
142452 const root = view._scenegraph.root; // initialize renderer, handler and event management
142453 view._renderer = null;
142454 view._tooltip = options.tooltip || defaultTooltip, view._redraw = true;
142455 view._handler = new (0, _vegaScenegraph.CanvasHandler)().scene(root);
142456 view._globalCursor = false;
142457 view._preventDefault = false;
142458 view._timers = [];
142459 view._eventListeners = [];
142460 view._resizeListeners = []; // initialize event configuration
142461 view._eventConfig = initializeEventConfig(spec.eventConfig);
142462 view.globalCursor(view._eventConfig.globalCursor); // initialize dataflow graph
142463 const ctx = runtime(view, spec, options.expr);
142464 view._runtime = ctx;
142465 view._signals = ctx.signals;
142466 view._bind = (spec.bindings || []).map((_)=>({
142467 state: null,
142468 param: (0, _vegaUtil.extend)({}, _)
142469 })); // initialize scenegraph
142470 if (ctx.root) ctx.root.set(root);
142471 root.source = ctx.data.root.input;
142472 view.pulse(ctx.data.root.input, view.changeset().insert(root.items)); // initialize view size
142473 view._width = view.width();
142474 view._height = view.height();
142475 view._viewWidth = viewWidth(view, view._width);
142476 view._viewHeight = viewHeight(view, view._height);
142477 view._origin = [
142478 0,
142479 0
142480 ];
142481 view._resize = 0;
142482 view._autosize = 1;
142483 initializeResize(view); // initialize background color
142484 background(view); // initialize cursor
142485 cursor(view); // initialize view description
142486 view.description(spec.description); // initialize hover proessing, if requested
142487 if (options.hover) view.hover(); // initialize DOM container(s) and renderer
142488 if (options.container) view.initialize(options.container, options.bind);
142489}
142490function lookupSignal(view, name) {
142491 return (0, _vegaUtil.hasOwnProperty)(view._signals, name) ? view._signals[name] : (0, _vegaUtil.error)("Unrecognized signal name: " + (0, _vegaUtil.stringValue)(name));
142492}

Callers

nothing calls this directly

Calls 9

initializeEventConfigFunction · 0.70
runtimeFunction · 0.70
viewWidthFunction · 0.70
viewHeightFunction · 0.70
initializeResizeFunction · 0.70
backgroundFunction · 0.70
cursorFunction · 0.70
initializeMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected