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 5.3.1 to 5.3.2

4

build/vega-view.js

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

(global = global || self, factory(global.vega = {}, global.vega, global.vega, global.vega, global.d3, global.vega, global.vega, global.d3));
}(this, function (exports, vegaUtil, vegaDataflow, vegaScenegraph, d3Array, vegaFunctions, vegaRuntime, d3Timer) { 'use strict';
}(this, (function (exports, vegaUtil, vegaDataflow, vegaScenegraph, d3Array, vegaFunctions, vegaRuntime, d3Timer) { 'use strict';

@@ -1326,2 +1326,2 @@ var Default = 'default';

}));
})));

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

@@ -26,11 +26,11 @@ "keywords": [

"dependencies": {
"d3-array": "^2.3.1",
"d3-array": "^2.3.3",
"d3-timer": "^1.0.9",
"vega-dataflow": "^5.2.1",
"vega-functions": "^5.3.1",
"vega-runtime": "^5.0.1",
"vega-scenegraph": "^4.2.0",
"vega-util": "^1.11.0"
"vega-dataflow": "^5.4.1",
"vega-functions": "^5.5.0",
"vega-runtime": "^5.0.2",
"vega-scenegraph": "^4.4.0",
"vega-util": "^1.12.0"
},
"gitHead": "965ec4a8e44ed880591ec0b41fd07cfcd59306ef"
"gitHead": "8180e8ca9379dec7f1722ce0ebd2aa01083be7b2"
}
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