Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-view

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-view - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

20

build/vega-view.js

@@ -588,3 +588,3 @@ (function (global, factory) {

var initializeHandler = function(view, prevHandler, el, constructor) {
var handler = new constructor(view.loader(), view.tooltip())
var handler = new constructor(view.loader(), tooltip(view))
.scene(view.scenegraph().root)

@@ -602,2 +602,20 @@ .initialize(el, offset(view), view);

// wrap tooltip handler to trap errors
function tooltip(view) {
var handler = view.tooltip(),
tooltip = null;
if (handler) {
tooltip = function() {
try {
handler.apply(this, arguments);
} catch (error) {
view.error(error);
}
};
}
return tooltip;
}
var initialize = function(el, elBind) {

@@ -604,0 +622,0 @@ var view = this,

2

build/vega-view.min.js

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-util"),require("vega-dataflow"),require("vega-scenegraph"),require("d3-array"),require("vega-parser"),require("vega-runtime")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-scenegraph","d3-array","vega-parser","vega-runtime"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega)}(this,function(e,o,c,h,l,i,a){"use strict";var s="default",u=function(e){var a=e._signals.cursor;a||(e._signals.cursor=a=e.add({user:s,item:null})),e.on(e.events("view","mousemove"),a,function(e,n){var t=a.value,r=t?o.isString(t)?t:t.user:s,i=n.item&&n.item.cursor||null;return t&&r===t.user&&i==t.item?t:{user:r,item:i}}),e.add(null,function(e){var n,t=e.cursor,r=this.value;return o.isString(t)||(r=t.item,t=t.user),n=t&&t!==s?t:r||t,"undefined"!=typeof document&&document.body&&(document.body.style.cursor=n),r},{cursor:a})};function r(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||o.error("Unrecognized data set: "+n),t[n]}function t(e,n){c.isChangeSet(n)||o.error("Second argument to changes must be a changeset.");var t=r(this,e);return t.modified=!0,this.pulse(t.input,n)}function d(e){var n=e.padding();return Math.max(0,e._viewWidth+n.left+n.right)}function f(e){var n=e.padding();return Math.max(0,e._viewHeight+n.top+n.bottom)}function v(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}var g=function(e,n,t){var r,i,a,s=e._renderer.scene();return s&&(a=v(e),i=n.changedTouches?n.changedTouches[0]:n,(r=h.point(i,s))[0]-=a[0],r[1]-=a[1]),n.dataflow=e,n.vega=function(e,r,t){var i=r?"group"===r.mark.marktype?r:r.mark.group:null;function a(e){var n,t=i;if(e)for(n=r;n;n=n.mark.group)if(n.mark.name===e){t=n;break}return t&&t.mark&&t.mark.interactive?t:{}}function n(e){if(!e)return t;o.isString(e)&&(e=a(e));for(var n=t.slice();e;)n[0]-=e.x||0,n[1]-=e.y||0,e=e.mark&&e.mark.group;return n}return{view:o.constant(e),item:o.constant(r||{}),group:a,xy:n,x:function(e){return n(e)[0]},y:function(e){return n(e)[1]}}}(e,t,r),n.item=t,n};var p="view",_="window";function m(e){return e.item}function y(e){var n=e.item.mark.source;return n.source||n}function w(t){return function(e,n){return n.vega.view().changeset().encode(n.item,t)}}var z=function(e,n,t){var r=document.createElement(e);for(var i in n)r.setAttribute(i,n[i]);return null!=t&&(r.textContent=t),r},b="vega-bind",k="vega-bind-name",n="vega-bind-radio",L="vega-option-",x=function(n,e,t){if(e){var r=t.param,i=t.state;return i||(i=t.state={elements:null,active:!1,set:null,update:function(e){i.source=!0,n.signal(r.signal,e).run()}},r.debounce&&(i.update=o.debounce(r.debounce,i.update))),function(e,n,t,r){var i=z("div",{class:b});i.appendChild(z("span",{class:k},t.name||t.signal)),n.appendChild(i);var a=C;switch(t.input){case"checkbox":a=S;break;case"select":a=E;break;case"radio":a=T;break;case"range":a=A}a(e,i,t,r)}(i,e,r,n.signal(r.signal)),i.active||(n.on(n._signals[r.signal],null,function(){i.source?i.source=!1:i.set(n.signal(r.signal))}),i.active=!0),i}};function C(e,n,t,r){var i=z("input");for(var a in t)"signal"!==a&&"element"!==a&&i.setAttribute("input"===a?"type":a,t[a]);i.setAttribute("name",t.signal),i.value=r,n.appendChild(i),i.addEventListener("input",function(){e.update(i.value)}),e.elements=[i],e.set=function(e){i.value=e}}function S(e,n,t,r){var i={type:"checkbox",name:t.signal};r&&(i.checked=!0);var a=z("input",i);n.appendChild(a),a.addEventListener("change",function(){e.update(a.checked)}),e.elements=[a],e.set=function(e){a.checked=!!e||null}}function E(e,n,r,t){var i=z("select",{name:r.signal});r.options.forEach(function(e){var n={value:e};R(e,t)&&(n.selected=!0),i.appendChild(z("option",n,e+""))}),n.appendChild(i),i.addEventListener("change",function(){e.update(r.options[i.selectedIndex])}),e.elements=[i],e.set=function(e){for(var n=0,t=r.options.length;n<t;++n)if(R(r.options[n],e))return void(i.selectedIndex=n)}}function T(i,e,a,s){var o=z("span",{class:n});e.appendChild(o),i.elements=a.options.map(function(e){var n=L+a.signal+"-"+e,t={id:n,type:"radio",name:a.signal,value:e};R(e,s)&&(t.checked=!0);var r=z("input",t);return r.addEventListener("change",function(){i.update(e)}),o.appendChild(r),o.appendChild(z("label",{for:n},e+"")),r}),i.set=function(e){for(var n=i.elements,t=0,r=n.length;t<r;++t)R(n[t].value,e)&&(n[t].checked=!0)}}function A(e,n,t,r){r=void 0!==r?r:(+t.max+ +t.min)/2;var i=t.min||Math.min(0,+r)||0,a=t.max||Math.max(100,+r)||100,s=t.step||l.tickStep(i,a,100),o=z("input",{type:"range",name:t.signal,min:i,max:a,step:s});o.value=r;var u=z("label",{},+r);function d(){u.textContent=o.value,e.update(+o.value)}n.appendChild(o),n.appendChild(u),o.addEventListener("input",d),o.addEventListener("change",d),e.elements=[o],e.set=function(e){o.value=e,u.textContent=e}}function R(e,n){return e===n||e+""==n+""}var D=function(e,n,t,r,i){return(n=n||new r(e.loader())).initialize(t,d(e),f(e),v(e),i).background(e._background)};function H(n,t){if("string"==typeof t){if("undefined"==typeof document)return n.error("DOM document instance not found."),null;if(!(t=document.querySelector(t)))return n.error("Signal bind element not found: "+t),null}if(t)try{t.innerHTML=""}catch(e){t=null,n.error(e)}return t}var O=function(e,n,t){var r=h.renderModule(n),i=r&&r.headless;return i?e.runAsync().then(function(){return D(e,null,null,i,t).renderAsync(e._scenegraph.root)}):Promise.reject("Unrecognized renderer type: "+n)};var j=function(e,n,t){var r=t||i.functionContext;return a.parse(n,a.context(e,c.transforms,r))},M="width",U="height",q="padding",W={skip:!0};function V(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===q?r.left+r.right:0)}function P(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===q?r.top+r.bottom:0)}function G(e,n){return n.modified&&o.isArray(n.input.value)&&e.indexOf("_:vega:_")}function I(e,n){return!("parent"===e||n instanceof c.transforms.proxy)}var B=function(e,n,t,r){var i,a;e.element().setAttribute("title",null==(i=r)?"":o.isArray(i)?N(i):o.isObject(i)&&!o.isDate(i)?(a=i,Object.keys(a).map(function(e){var n=a[e];return e+": "+(o.isArray(n)?N(n):F(n))}).join("\n")):i+"")};function N(e){return"["+e.map(F).join(", ")+"]"}function F(e){return o.isArray(e)?"[…]":o.isObject(e)&&!o.isDate(e)?"{…}":e}function J(e,n){var t=this;n=n||{},c.Dataflow.call(t),t.loader(n.loader||t._loader),t.logLevel(n.logLevel||0),t._el=null,t._renderType=n.renderer||h.RenderType.Canvas,t._scenegraph=new h.Scenegraph;var r=t._scenegraph.root;t._renderer=null,t._tooltip=n.tooltip||B,t._redraw=!0,t._handler=(new h.CanvasHandler).scene(r),t._preventDefault=!1,t._eventListeners=[],t._resizeListeners=[];var i,a,s=j(t,e,n.functions);t._runtime=s,t._signals=s.signals,t._bind=(e.bindings||[]).map(function(e){return{state:null,param:o.extend({},e)}}),s.root&&s.root.set(r),r.source=s.data.root.input,t.pulse(s.data.root.input,t.changeset().insert(r.items)),t._background=s.background||null,t._eventConfig=(i=s.eventConfig,(a=(i=o.extend({},i)).defaults)&&(o.isArray(a.prevent)&&(a.prevent=o.toSet(a.prevent)),o.isArray(a.allow)&&(a.allow=o.toSet(a.allow))),i),t._width=t.width(),t._height=t.height(),t._viewWidth=V(t,t._width),t._viewHeight=P(t,t._height),t._origin=[0,0],t._resize=0,t._autosize=1,function(n){var e=n._signals,t=e[M],r=e[U],i=e[q];function a(){n._autosize=n._resize=1}n._resizeWidth=n.add(null,function(e){n._width=e.size,n._viewWidth=V(n,e.size),a()},{size:t}),n._resizeHeight=n.add(null,function(e){n._height=e.size,n._viewHeight=P(n,e.size),a()},{size:r});var s=n.add(null,a,{pad:i});n._resizeWidth.rank=t.rank+1,n._resizeHeight.rank=r.rank+1,s.rank=i.rank+1}(t),u(t)}var K=o.inherits(J,c.Dataflow);function Q(e,n){return e._signals.hasOwnProperty(n)?e._signals[n]:o.error("Unrecognized signal name: "+o.stringValue(n))}function X(e,t){var n=(e._targets||[]).filter(function(e){var n=e._update;return n&&n.handler===t});return n.length?n[0]:null}K.run=function(e){if(c.Dataflow.prototype.run.call(this,e),this._redraw||this._resize)try{this.render()}catch(e){this.error(e)}return this},K.render=function(){var e,n,t,r;return this._renderer&&(this._resize&&(this._resize=0,n=v(e=this),t=d(e),r=f(e),e._renderer.background(e._background),e._renderer.resize(t,r,n),e._handler.origin(n),e._resizeListeners.forEach(function(e){e(t,r)})),this._renderer.render(this._scenegraph.root)),this._redraw=!1,this},K.dirty=function(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},K.container=function(){return this._el},K.scenegraph=function(){return this._scenegraph},K.origin=function(){return this._origin.slice()},K.signal=function(e,n,t){var r=Q(this,e);return 1===arguments.length?r.value:this.update(r,n,t)},K.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},K.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},K.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},K.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},K.autosize=function(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},K.renderer=function(e){return arguments.length?(h.renderModule(e)||o.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},K.tooltip=function(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},K.loader=function(e){return arguments.length?(e!==this._loader&&(c.Dataflow.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},K.resize=function(){return this._autosize=1,this},K._resetRenderer=function(){this._renderer&&(this._renderer=null,this.initialize(this._el))},K._resizeView=function(t,r,i,a,s,o){this.runAfter(function(e){var n=0;e._autosize=0,e.width()!==i&&(n=1,e.signal(M,i,W),e._resizeWidth.skip(!0)),e.height()!==a&&(n=1,e.signal(U,a,W),e._resizeHeight.skip(!0)),e._viewWidth!==t&&(e._resize=1,e._viewWidth=t),e._viewHeight!==r&&(e._resize=1,e._viewHeight=r),e._origin[0]===s[0]&&e._origin[1]===s[1]||(e._resize=1,e._origin=s),n&&e.run("enter"),o&&e.runAfter(function(){e.resize()})},!1,1)},K.addEventListener=function(e,n){return this._handler.on(e,n),this},K.removeEventListener=function(e,n){return this._handler.off(e,n),this},K.addResizeListener=function(e){var n=this._resizeListeners;return n.indexOf(e)<0&&n.push(e),this},K.removeResizeListener=function(e){var n=this._resizeListeners,t=n.indexOf(e);return 0<=t&&n.splice(t,1),this},K.addSignalListener=function(e,n){var t=Q(this,e),r=X(t,n);return r||((r=function(){n(e,t.value)}).handler=n,this.on(t,null,r)),this},K.removeSignalListener=function(e,n){var t=Q(this,e),r=X(t,n);return r&&t._targets.remove(r),this},K.preventDefault=function(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},K.tooltipHandler=function(e){var n=this._handler;return arguments.length?(n.handleTooltip=e||h.Handler.prototype.handleTooltip,this):n.handleTooltip},K.events=function(o,u,e){var n,d=this,l=new c.EventStream(e),t=function(e,n){var t,r,i,a,s;o!==p||(r=u,i=(t=d)._eventConfig.defaults,a=i&&i.prevent,s=i&&i.allow,!1===a||!0===s||!0!==a&&!1!==s&&(a?!a[r]:s?s[r]:!t.preventDefault()))||e.preventDefault();try{l.receive(g(d,e,n))}catch(e){d.error(e)}finally{d.run()}};if(o===p)return d.addEventListener(u,t),l;if(o===_?"undefined"!=typeof window&&(n=[window]):"undefined"!=typeof document&&(n=document.querySelectorAll(o)),!n)return d.warn("Can not resolve event source: "+o),l;for(var r=0,i=n.length;r<i;++r)n[r].addEventListener(u,t);return d._eventListeners.push({type:u,sources:n,handler:t}),l},K.finalize=function(){for(var e,n,t=this._eventListeners,r=t.length;0<=--r;)for(e=(n=t[r]).sources.length;0<=--e;)n.sources[e].removeEventListener(n.type,n.handler)},K.hover=function(e,n){return n=[n||"update",(e=[e||"hover"])[0]],this.on(this.events("view","mouseover",m),y,w(e)),this.on(this.events("view","mouseout",m),y,w(n)),this},K.data=function(e){return r(this,e).values.value},K.change=t,K.insert=function(e,n){return t.call(this,e,c.changeset().insert(n))},K.remove=function(e,n){return t.call(this,e,c.changeset().remove(n))},K.initialize=function(e,n){var t,r,i,a,s,o,u=this,d=u._renderType,l=h.renderModule(d);return e=u._el=e?H(u,e):null,l||u.error("Unrecognized renderer type: "+d),t=l.handler||h.CanvasHandler,r=e?l.renderer:l.headless,u._renderer=r?D(u,u._renderer,e,r):null,u._handler=(a=(i=u)._handler,s=e,o=new t(i.loader(),i.tooltip()).scene(i.scenegraph().root).initialize(s,v(i),i),a&&a.handlers().forEach(function(e){o.on(e.type,e.handler)}),o),u._redraw=!0,e&&(n=n?H(u,n):e.appendChild(z("div",{class:"vega-bindings"})),u._bind.forEach(function(e){e.param.element&&(e.element=H(u,e.param.element))}),u._bind.forEach(function(e){x(u,e.element||n,e)})),u},K.toImageURL=function(r,e){return r!==h.RenderType.Canvas&&r!==h.RenderType.SVG&&r!==h.RenderType.PNG?Promise.reject("Unrecognized image type: "+r):O(this,r,e).then(function(e){return r===h.RenderType.SVG?(n=e.svg(),t=new Blob([n],{type:"image/svg+xml"}),window.URL.createObjectURL(t)):e.canvas().toDataURL("image/png");var n,t})},K.toCanvas=function(e){return O(this,h.RenderType.Canvas,e).then(function(e){return e.canvas()})},K.toSVG=function(e){return O(this,h.RenderType.SVG,e).then(function(e){return e.svg()})},K.getState=function(e){return this._runtime.getState(e||{data:G,signals:I,recurse:!0})},K.setState=function(e){var n=this;return n.runAfter(function(){n._trigger=!1,n._runtime.setState(e),n.run().runAfter(function(){n._trigger=!0})}),this},e.View=J,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-util"),require("vega-dataflow"),require("vega-scenegraph"),require("d3-array"),require("vega-parser"),require("vega-runtime")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-scenegraph","d3-array","vega-parser","vega-runtime"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega)}(this,function(e,o,c,v,l,i,a){"use strict";var s="default",u=function(e){var a=e._signals.cursor;a||(e._signals.cursor=a=e.add({user:s,item:null})),e.on(e.events("view","mousemove"),a,function(e,n){var t=a.value,r=t?o.isString(t)?t:t.user:s,i=n.item&&n.item.cursor||null;return t&&r===t.user&&i==t.item?t:{user:r,item:i}}),e.add(null,function(e){var n,t=e.cursor,r=this.value;return o.isString(t)||(r=t.item,t=t.user),n=t&&t!==s?t:r||t,"undefined"!=typeof document&&document.body&&(document.body.style.cursor=n),r},{cursor:a})};function r(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||o.error("Unrecognized data set: "+n),t[n]}function t(e,n){c.isChangeSet(n)||o.error("Second argument to changes must be a changeset.");var t=r(this,e);return t.modified=!0,this.pulse(t.input,n)}function d(e){var n=e.padding();return Math.max(0,e._viewWidth+n.left+n.right)}function h(e){var n=e.padding();return Math.max(0,e._viewHeight+n.top+n.bottom)}function g(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}var f=function(e,n,t){var r,i,a,s=e._renderer.scene();return s&&(a=g(e),i=n.changedTouches?n.changedTouches[0]:n,(r=v.point(i,s))[0]-=a[0],r[1]-=a[1]),n.dataflow=e,n.vega=function(e,r,t){var i=r?"group"===r.mark.marktype?r:r.mark.group:null;function a(e){var n,t=i;if(e)for(n=r;n;n=n.mark.group)if(n.mark.name===e){t=n;break}return t&&t.mark&&t.mark.interactive?t:{}}function n(e){if(!e)return t;o.isString(e)&&(e=a(e));for(var n=t.slice();e;)n[0]-=e.x||0,n[1]-=e.y||0,e=e.mark&&e.mark.group;return n}return{view:o.constant(e),item:o.constant(r||{}),group:a,xy:n,x:function(e){return n(e)[0]},y:function(e){return n(e)[1]}}}(e,t,r),n.item=t,n};var p="view",_="window";function m(e){return e.item}function y(e){var n=e.item.mark.source;return n.source||n}function w(t){return function(e,n){return n.vega.view().changeset().encode(n.item,t)}}var z=function(e,n,t){var r=document.createElement(e);for(var i in n)r.setAttribute(i,n[i]);return null!=t&&(r.textContent=t),r},b="vega-bind",k="vega-bind-name",n="vega-bind-radio",L="vega-option-",x=function(n,e,t){if(e){var r=t.param,i=t.state;return i||(i=t.state={elements:null,active:!1,set:null,update:function(e){i.source=!0,n.signal(r.signal,e).run()}},r.debounce&&(i.update=o.debounce(r.debounce,i.update))),function(e,n,t,r){var i=z("div",{class:b});i.appendChild(z("span",{class:k},t.name||t.signal)),n.appendChild(i);var a=C;switch(t.input){case"checkbox":a=S;break;case"select":a=E;break;case"radio":a=T;break;case"range":a=A}a(e,i,t,r)}(i,e,r,n.signal(r.signal)),i.active||(n.on(n._signals[r.signal],null,function(){i.source?i.source=!1:i.set(n.signal(r.signal))}),i.active=!0),i}};function C(e,n,t,r){var i=z("input");for(var a in t)"signal"!==a&&"element"!==a&&i.setAttribute("input"===a?"type":a,t[a]);i.setAttribute("name",t.signal),i.value=r,n.appendChild(i),i.addEventListener("input",function(){e.update(i.value)}),e.elements=[i],e.set=function(e){i.value=e}}function S(e,n,t,r){var i={type:"checkbox",name:t.signal};r&&(i.checked=!0);var a=z("input",i);n.appendChild(a),a.addEventListener("change",function(){e.update(a.checked)}),e.elements=[a],e.set=function(e){a.checked=!!e||null}}function E(e,n,r,t){var i=z("select",{name:r.signal});r.options.forEach(function(e){var n={value:e};R(e,t)&&(n.selected=!0),i.appendChild(z("option",n,e+""))}),n.appendChild(i),i.addEventListener("change",function(){e.update(r.options[i.selectedIndex])}),e.elements=[i],e.set=function(e){for(var n=0,t=r.options.length;n<t;++n)if(R(r.options[n],e))return void(i.selectedIndex=n)}}function T(i,e,a,s){var o=z("span",{class:n});e.appendChild(o),i.elements=a.options.map(function(e){var n=L+a.signal+"-"+e,t={id:n,type:"radio",name:a.signal,value:e};R(e,s)&&(t.checked=!0);var r=z("input",t);return r.addEventListener("change",function(){i.update(e)}),o.appendChild(r),o.appendChild(z("label",{for:n},e+"")),r}),i.set=function(e){for(var n=i.elements,t=0,r=n.length;t<r;++t)R(n[t].value,e)&&(n[t].checked=!0)}}function A(e,n,t,r){r=void 0!==r?r:(+t.max+ +t.min)/2;var i=t.min||Math.min(0,+r)||0,a=t.max||Math.max(100,+r)||100,s=t.step||l.tickStep(i,a,100),o=z("input",{type:"range",name:t.signal,min:i,max:a,step:s});o.value=r;var u=z("label",{},+r);function d(){u.textContent=o.value,e.update(+o.value)}n.appendChild(o),n.appendChild(u),o.addEventListener("input",d),o.addEventListener("change",d),e.elements=[o],e.set=function(e){o.value=e,u.textContent=e}}function R(e,n){return e===n||e+""==n+""}var D=function(e,n,t,r,i){return(n=n||new r(e.loader())).initialize(t,d(e),h(e),g(e),i).background(e._background)};function H(n,t){if("string"==typeof t){if("undefined"==typeof document)return n.error("DOM document instance not found."),null;if(!(t=document.querySelector(t)))return n.error("Signal bind element not found: "+t),null}if(t)try{t.innerHTML=""}catch(e){t=null,n.error(e)}return t}var O=function(e,n,t){var r=v.renderModule(n),i=r&&r.headless;return i?e.runAsync().then(function(){return D(e,null,null,i,t).renderAsync(e._scenegraph.root)}):Promise.reject("Unrecognized renderer type: "+n)};var j=function(e,n,t){var r=t||i.functionContext;return a.parse(n,a.context(e,c.transforms,r))},M="width",U="height",q="padding",W={skip:!0};function V(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===q?r.left+r.right:0)}function P(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===q?r.top+r.bottom:0)}function G(e,n){return n.modified&&o.isArray(n.input.value)&&e.indexOf("_:vega:_")}function I(e,n){return!("parent"===e||n instanceof c.transforms.proxy)}var B=function(e,n,t,r){var i,a;e.element().setAttribute("title",null==(i=r)?"":o.isArray(i)?N(i):o.isObject(i)&&!o.isDate(i)?(a=i,Object.keys(a).map(function(e){var n=a[e];return e+": "+(o.isArray(n)?N(n):F(n))}).join("\n")):i+"")};function N(e){return"["+e.map(F).join(", ")+"]"}function F(e){return o.isArray(e)?"[…]":o.isObject(e)&&!o.isDate(e)?"{…}":e}function J(e,n){var t=this;n=n||{},c.Dataflow.call(t),t.loader(n.loader||t._loader),t.logLevel(n.logLevel||0),t._el=null,t._renderType=n.renderer||v.RenderType.Canvas,t._scenegraph=new v.Scenegraph;var r=t._scenegraph.root;t._renderer=null,t._tooltip=n.tooltip||B,t._redraw=!0,t._handler=(new v.CanvasHandler).scene(r),t._preventDefault=!1,t._eventListeners=[],t._resizeListeners=[];var i,a,s=j(t,e,n.functions);t._runtime=s,t._signals=s.signals,t._bind=(e.bindings||[]).map(function(e){return{state:null,param:o.extend({},e)}}),s.root&&s.root.set(r),r.source=s.data.root.input,t.pulse(s.data.root.input,t.changeset().insert(r.items)),t._background=s.background||null,t._eventConfig=(i=s.eventConfig,(a=(i=o.extend({},i)).defaults)&&(o.isArray(a.prevent)&&(a.prevent=o.toSet(a.prevent)),o.isArray(a.allow)&&(a.allow=o.toSet(a.allow))),i),t._width=t.width(),t._height=t.height(),t._viewWidth=V(t,t._width),t._viewHeight=P(t,t._height),t._origin=[0,0],t._resize=0,t._autosize=1,function(n){var e=n._signals,t=e[M],r=e[U],i=e[q];function a(){n._autosize=n._resize=1}n._resizeWidth=n.add(null,function(e){n._width=e.size,n._viewWidth=V(n,e.size),a()},{size:t}),n._resizeHeight=n.add(null,function(e){n._height=e.size,n._viewHeight=P(n,e.size),a()},{size:r});var s=n.add(null,a,{pad:i});n._resizeWidth.rank=t.rank+1,n._resizeHeight.rank=r.rank+1,s.rank=i.rank+1}(t),u(t)}var K=o.inherits(J,c.Dataflow);function Q(e,n){return e._signals.hasOwnProperty(n)?e._signals[n]:o.error("Unrecognized signal name: "+o.stringValue(n))}function X(e,t){var n=(e._targets||[]).filter(function(e){var n=e._update;return n&&n.handler===t});return n.length?n[0]:null}K.run=function(e){if(c.Dataflow.prototype.run.call(this,e),this._redraw||this._resize)try{this.render()}catch(e){this.error(e)}return this},K.render=function(){var e,n,t,r;return this._renderer&&(this._resize&&(this._resize=0,n=g(e=this),t=d(e),r=h(e),e._renderer.background(e._background),e._renderer.resize(t,r,n),e._handler.origin(n),e._resizeListeners.forEach(function(e){e(t,r)})),this._renderer.render(this._scenegraph.root)),this._redraw=!1,this},K.dirty=function(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},K.container=function(){return this._el},K.scenegraph=function(){return this._scenegraph},K.origin=function(){return this._origin.slice()},K.signal=function(e,n,t){var r=Q(this,e);return 1===arguments.length?r.value:this.update(r,n,t)},K.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},K.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},K.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},K.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},K.autosize=function(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},K.renderer=function(e){return arguments.length?(v.renderModule(e)||o.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},K.tooltip=function(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},K.loader=function(e){return arguments.length?(e!==this._loader&&(c.Dataflow.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},K.resize=function(){return this._autosize=1,this},K._resetRenderer=function(){this._renderer&&(this._renderer=null,this.initialize(this._el))},K._resizeView=function(t,r,i,a,s,o){this.runAfter(function(e){var n=0;e._autosize=0,e.width()!==i&&(n=1,e.signal(M,i,W),e._resizeWidth.skip(!0)),e.height()!==a&&(n=1,e.signal(U,a,W),e._resizeHeight.skip(!0)),e._viewWidth!==t&&(e._resize=1,e._viewWidth=t),e._viewHeight!==r&&(e._resize=1,e._viewHeight=r),e._origin[0]===s[0]&&e._origin[1]===s[1]||(e._resize=1,e._origin=s),n&&e.run("enter"),o&&e.runAfter(function(){e.resize()})},!1,1)},K.addEventListener=function(e,n){return this._handler.on(e,n),this},K.removeEventListener=function(e,n){return this._handler.off(e,n),this},K.addResizeListener=function(e){var n=this._resizeListeners;return n.indexOf(e)<0&&n.push(e),this},K.removeResizeListener=function(e){var n=this._resizeListeners,t=n.indexOf(e);return 0<=t&&n.splice(t,1),this},K.addSignalListener=function(e,n){var t=Q(this,e),r=X(t,n);return r||((r=function(){n(e,t.value)}).handler=n,this.on(t,null,r)),this},K.removeSignalListener=function(e,n){var t=Q(this,e),r=X(t,n);return r&&t._targets.remove(r),this},K.preventDefault=function(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},K.tooltipHandler=function(e){var n=this._handler;return arguments.length?(n.handleTooltip=e||v.Handler.prototype.handleTooltip,this):n.handleTooltip},K.events=function(o,u,e){var n,d=this,l=new c.EventStream(e),t=function(e,n){var t,r,i,a,s;o!==p||(r=u,i=(t=d)._eventConfig.defaults,a=i&&i.prevent,s=i&&i.allow,!1===a||!0===s||!0!==a&&!1!==s&&(a?!a[r]:s?s[r]:!t.preventDefault()))||e.preventDefault();try{l.receive(f(d,e,n))}catch(e){d.error(e)}finally{d.run()}};if(o===p)return d.addEventListener(u,t),l;if(o===_?"undefined"!=typeof window&&(n=[window]):"undefined"!=typeof document&&(n=document.querySelectorAll(o)),!n)return d.warn("Can not resolve event source: "+o),l;for(var r=0,i=n.length;r<i;++r)n[r].addEventListener(u,t);return d._eventListeners.push({type:u,sources:n,handler:t}),l},K.finalize=function(){for(var e,n,t=this._eventListeners,r=t.length;0<=--r;)for(e=(n=t[r]).sources.length;0<=--e;)n.sources[e].removeEventListener(n.type,n.handler)},K.hover=function(e,n){return n=[n||"update",(e=[e||"hover"])[0]],this.on(this.events("view","mouseover",m),y,w(e)),this.on(this.events("view","mouseout",m),y,w(n)),this},K.data=function(e){return r(this,e).values.value},K.change=t,K.insert=function(e,n){return t.call(this,e,c.changeset().insert(n))},K.remove=function(e,n){return t.call(this,e,c.changeset().remove(n))},K.initialize=function(e,n){var t,r,i,a,s,o,u,d,l,c=this,h=c._renderType,f=v.renderModule(h);return e=c._el=e?H(c,e):null,f||c.error("Unrecognized renderer type: "+h),t=f.handler||v.CanvasHandler,r=e?f.renderer:f.headless,c._renderer=r?D(c,c._renderer,e,r):null,c._handler=(a=(i=c)._handler,s=e,o=new t(i.loader(),(u=i,d=u.tooltip(),l=null,d&&(l=function(){try{d.apply(this,arguments)}catch(e){u.error(e)}}),l)).scene(i.scenegraph().root).initialize(s,g(i),i),a&&a.handlers().forEach(function(e){o.on(e.type,e.handler)}),o),c._redraw=!0,e&&(n=n?H(c,n):e.appendChild(z("div",{class:"vega-bindings"})),c._bind.forEach(function(e){e.param.element&&(e.element=H(c,e.param.element))}),c._bind.forEach(function(e){x(c,e.element||n,e)})),c},K.toImageURL=function(r,e){return r!==v.RenderType.Canvas&&r!==v.RenderType.SVG&&r!==v.RenderType.PNG?Promise.reject("Unrecognized image type: "+r):O(this,r,e).then(function(e){return r===v.RenderType.SVG?(n=e.svg(),t=new Blob([n],{type:"image/svg+xml"}),window.URL.createObjectURL(t)):e.canvas().toDataURL("image/png");var n,t})},K.toCanvas=function(e){return O(this,v.RenderType.Canvas,e).then(function(e){return e.canvas()})},K.toSVG=function(e){return O(this,v.RenderType.SVG,e).then(function(e){return e.svg()})},K.getState=function(e){return this._runtime.getState(e||{data:G,signals:I,recurse:!0})},K.setState=function(e){var n=this;return n.runAfter(function(){n._trigger=!1,n._runtime.setState(e),n.run().runAfter(function(){n._trigger=!0})}),this},e.View=J,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "vega-view",
"version": "2.3.1",
"version": "2.3.2",
"description": "View component and transforms for Vega visualizations.",

@@ -5,0 +5,0 @@ "keywords": [

import {offset} from './render-size';
export default function(view, prevHandler, el, constructor) {
var handler = new constructor(view.loader(), view.tooltip())
var handler = new constructor(view.loader(), tooltip(view))
.scene(view.scenegraph().root)

@@ -16,1 +16,19 @@ .initialize(el, offset(view), view);

}
// wrap tooltip handler to trap errors
function tooltip(view) {
var handler = view.tooltip(),
tooltip = null;
if (handler) {
tooltip = function() {
try {
handler.apply(this, arguments);
} catch (error) {
view.error(error);
}
};
}
return tooltip;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc