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.0.1 to 5.1.0

8

build/vega-view.js

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

// initialize background color
view._background = ctx.background || null;
view._background = options.background || ctx.background || null;

@@ -1034,2 +1034,8 @@ // initialize event configuration

cursor(view);
// initialize hover proessing, if requested
if (options.hover) view.hover();
// initialize DOM container(s) and renderer
if (options.container) view.initialize(options.container, options.bind);
}

@@ -1036,0 +1042,0 @@

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-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,u){"use strict";var o="default";function l(e){var t=e._signals.cursor;t||(e._signals.cursor=t=e.add({user:o,item:null})),e.on(e.events("view","mousemove"),t,function(e,r){var i=t.value,a=i?n.isString(i)?i:i.user:o,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,r=e.cursor,i=this.value;return n.isString(r)||(i=r.item,r=r.user),t=r&&r!==o?r:i||r,"undefined"!=typeof document&&document.body&&(document.body.style.cursor=t),i},{cursor:t})}function d(e,t){var r=e._runtime.data;return r.hasOwnProperty(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=d(this,e);return i.modified=!0,this.pulse(i.input,r)}function c(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]]}function g(e,t,i){var a,s,u,o=e._renderer.canvas();return o&&(u=v(e),s=t.changedTouches?t.changedTouches[0]:t,(a=r.point(s,o))[0]-=u[0],a[1]-=u[1]),t.dataflow=e,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.item=i,t}var p="view",_="timer",m="window",y={trap:!1};function w(e){return e.item}function z(e){var n=e.item.mark.source;return n.source||n}function b(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function k(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 L="vega-bind",x="vega-bind-name",C="vega-bind-radio",S="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=k("div",{class:L});i.appendChild(k("span",{class:x},t.name||t.signal)),n.appendChild(i);var a=E;switch(t.input){case"checkbox":a=D;break;case"select":a=R;break;case"radio":a=T;break;case"range":a=O}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 E(e,n,t,r){var i=k("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 D(e,n,t,r){var i={type:"checkbox",name:t.signal};r&&(i.checked=!0);var a=k("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 R(e,n,t,r){var i=k("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};H(e,r)&&(n.selected=!0),i.appendChild(k("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(H(t.options[n],e))return void(i.selectedIndex=n)}}function T(e,n,t,r){var i=k("span",{class:C});n.appendChild(i),e.elements=t.options.map(function(n){var a=S+t.signal+"-"+n,s={id:a,type:"radio",name:t.signal,value:n};H(n,r)&&(s.checked=!0);var u=k("input",s);return u.addEventListener("change",function(){e.update(n)}),i.appendChild(u),i.appendChild(k("label",{for:a},n+"")),u}),e.set=function(n){for(var t=e.elements,r=0,i=t.length;r<i;++r)H(t[r].value,n)&&(t[r].checked=!0)}}function O(e,n,t,r){r=void 0!==r?r:(+t.max+ +t.min)/2;var a=t.min||Math.min(0,+r)||0,s=t.max||Math.max(100,+r)||100,u=t.step||i.tickStep(a,s,100),o=k("input",{type:"range",name:t.signal,min:a,max:s,step:u});o.value=r;var l=k("label",{},+r);function d(){l.textContent=o.value,e.update(+o.value)}n.appendChild(o),n.appendChild(l),o.addEventListener("input",d),o.addEventListener("change",d),e.elements=[o],e.set=function(e){o.value=e,l.textContent=e}}function H(e,n){return e===n||e+""==n+""}function U(e,n,t,r,i,a){return(n=n||new r(e.loader())).initialize(t,c(e),f(e),v(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 j(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 q(e,t,i,a){const s=r.renderModule(t),u=s&&s.headless;return u||n.error("Unrecognized renderer type: "+t),await e.runAsync(),U(e,null,null,u,i,a).renderAsync(e._scenegraph.root)}var W="width",V="height",G="padding",P={skip:!0};function B(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===G?r.left+r.right:0)}function I(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),this.loader(i.loader||this._loader),this.logLevel(i.logLevel||0),this._el=null,this._elBind=null,this._renderType=i.renderer||r.RenderType.Canvas,this._scenegraph=new r.Scenegraph;var u=this._scenegraph.root;this._renderer=null,this._tooltip=i.tooltip||J,this._redraw=!0,this._handler=(new r.CanvasHandler).scene(u),this._preventDefault=!1,this._timers=[],this._eventListeners=[],this._resizeListeners=[];var o,d,h=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=h,this._signals=h.signals,this._bind=(e.bindings||[]).map(function(e){return{state:null,param:n.extend({},e)}}),h.root&&h.root.set(u),u.source=h.data.root.input,this.pulse(h.data.root.input,this.changeset().insert(u.items)),this._background=h.background||null,this._eventConfig=(o=h.eventConfig,(d=(o=n.extend({},o)).defaults)&&(n.isArray(d.prevent)&&(d.prevent=n.toSet(d.prevent)),n.isArray(d.allow)&&(d.allow=n.toSet(d.allow))),o),this._width=this.width(),this._height=this.height(),this._viewWidth=B(this,this._width),this._viewHeight=I(this,this._height),this._origin=[0,0],this._resize=0,this._autosize=1,function(e){var n=e._signals,t=n[W],r=n[V],i=n[G];function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,function(n){e._width=n.size,e._viewWidth=B(e,n.size),a()},{size:t}),e._resizeHeight=e.add(null,function(n){e._height=n.size,e._viewHeight=I(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)}var Y=n.inherits(X,t.Dataflow);function Z(e,t){return e._signals.hasOwnProperty(t)?e._signals[t]:n.error("Unrecognized signal name: "+n.stringValue(t))}function $(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 ee(e,n,t,r){var i=$(t,r);return i||((i=M(this,function(){r(n,t.value)})).handler=r,e.on(t,null,i)),e}function ne(e,n,t){var r=$(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=v(i=this),s=c(i),u=f(i),i._renderer.background(i._background),i._renderer.resize(s,u,a),i._handler.origin(a),i._resizeListeners.forEach(function(e){try{e(s,u)}catch(e){i.error(e)}})),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(e){this.error(e)}var i,a,s,u;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 u=0;s._autosize=0,s.width()!==t&&(u=1,s.signal(W,t,P),s._resizeWidth.skip(!0)),s.height()!==r&&(u=1,s.signal(V,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),u&&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 ee(this,e,Z(this,e),n)},Y.removeSignalListener=function(e,n){return ne(this,Z(this,e),n)},Y.addDataListener=function(e,n){return ee(this,e,d(this,e).values,n)},Y.removeDataListener=function(e,n){return ne(this,d(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(u.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),u=function(t,r){a.runAsync(null,()=>{e===p&&function(e,n){var t=e._eventConfig.defaults,r=t&&t.prevent,i=t&&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(g(a,t,r))})};if(e===_)a.timer(u,n);else if(e===p)a.addEventListener(n,u,y);else if(e===m?"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&(i=document.querySelectorAll(e)),i){for(var o=0,l=i.length;o<l;++o)i[o].addEventListener(n,u);a._eventListeners.push({type:n,sources:i,handler:u})}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",w),z,b(e)),this.on(this.events("view","mouseout",w),z,b(n)),this},Y.data=function(e){return d(this,e).values.value},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 t.hasOwnProperty(e)||n.error("Unrecognized scale or projection: "+e),t[e].value},Y.initialize=function(e,n){var t,i,a=this,s=a._renderType,u=r.renderModule(s);return e=a._el=e?j(a,e):null,u||a.error("Unrecognized renderer type: "+s),t=u.handler||r.CanvasHandler,i=e?u.renderer:u.headless,a._renderer=i?U(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,v(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&&(n=n?a._elBind=j(a,n):e.appendChild(k("div",{class:"vega-bindings"})),a._bind.forEach(function(e){e.param.element&&(e.element=j(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 q(this,e,t);return e===r.RenderType.SVG?(a=i.svg(),s=new Blob([a],{type:"image/svg+xml"}),window.URL.createObjectURL(s)):i.canvas().toDataURL("image/png");var a,s},Y.toCanvas=async function(e,n){return(await q(this,r.RenderType.Canvas,e,n)).canvas()},Y.toSVG=async function(e){return(await q(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,r=e.cursor,i=this.value;return n.isString(r)||(i=r.item,r=r.user),t=r&&r!==u?r:i||r,"undefined"!=typeof document&&document.body&&(document.body.style.cursor=t),i},{cursor:t})}function h(e,t){var r=e._runtime.data;return r.hasOwnProperty(t)||n.error("Unrecognized data set: "+t),r[t]}function d(e,r){t.isChangeSet(r)||n.error("Second argument to changes must be a changeset.");var i=h(this,e);return i.modified=!0,this.pulse(i.input,r)}function c(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]]}function g(e,t,i){var a,s,o,u=e._renderer.canvas();return u&&(o=v(e),s=t.changedTouches?t.changedTouches[0]:t,(a=r.point(s,u))[0]-=o[0],a[1]-=o[1]),t.dataflow=e,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.item=i,t}var p="view",_="timer",m="window",y={trap:!1};function w(e){return e.item}function z(e){var n=e.item.mark.source;return n.source||n}function b(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function k(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 L="vega-bind",x="vega-bind-name",C="vega-bind-radio",S="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=k("div",{class:L});i.appendChild(k("span",{class:x},t.name||t.signal)),n.appendChild(i);var a=E;switch(t.input){case"checkbox":a=D;break;case"select":a=R;break;case"radio":a=T;break;case"range":a=O}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 E(e,n,t,r){var i=k("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 D(e,n,t,r){var i={type:"checkbox",name:t.signal};r&&(i.checked=!0);var a=k("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 R(e,n,t,r){var i=k("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};H(e,r)&&(n.selected=!0),i.appendChild(k("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(H(t.options[n],e))return void(i.selectedIndex=n)}}function T(e,n,t,r){var i=k("span",{class:C});n.appendChild(i),e.elements=t.options.map(function(n){var a=S+t.signal+"-"+n,s={id:a,type:"radio",name:t.signal,value:n};H(n,r)&&(s.checked=!0);var o=k("input",s);return o.addEventListener("change",function(){e.update(n)}),i.appendChild(o),i.appendChild(k("label",{for:a},n+"")),o}),e.set=function(n){for(var t=e.elements,r=0,i=t.length;r<i;++r)H(t[r].value,n)&&(t[r].checked=!0)}}function O(e,n,t,r){r=void 0!==r?r:(+t.max+ +t.min)/2;var a=t.min||Math.min(0,+r)||0,s=t.max||Math.max(100,+r)||100,o=t.step||i.tickStep(a,s,100),u=k("input",{type:"range",name:t.signal,min:a,max:s,step:o});u.value=r;var l=k("label",{},+r);function h(){l.textContent=u.value,e.update(+u.value)}n.appendChild(u),n.appendChild(l),u.addEventListener("input",h),u.addEventListener("change",h),e.elements=[u],e.set=function(e){u.value=e,l.textContent=e}}function H(e,n){return e===n||e+""==n+""}function U(e,n,t,r,i,a){return(n=n||new r(e.loader())).initialize(t,c(e),f(e),v(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 j(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 q(e,t,i,a){const s=r.renderModule(t),o=s&&s.headless;return o||n.error("Unrecognized renderer type: "+t),await e.runAsync(),U(e,null,null,o,i,a).renderAsync(e._scenegraph.root)}var W="width",V="height",G="padding",P={skip:!0};function B(e,n){var t=e.autosize(),r=e.padding();return n-(t&&t.contains===G?r.left+r.right:0)}function I(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),this.loader(i.loader||this._loader),this.logLevel(i.logLevel||0),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=[];var u,h,d=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=d,this._signals=d.signals,this._bind=(e.bindings||[]).map(function(e){return{state:null,param:n.extend({},e)}}),d.root&&d.root.set(o),o.source=d.data.root.input,this.pulse(d.data.root.input,this.changeset().insert(o.items)),this._background=i.background||d.background||null,this._eventConfig=(u=d.eventConfig,(h=(u=n.extend({},u)).defaults)&&(n.isArray(h.prevent)&&(h.prevent=n.toSet(h.prevent)),n.isArray(h.allow)&&(h.allow=n.toSet(h.allow))),u),this._width=this.width(),this._height=this.height(),this._viewWidth=B(this,this._width),this._viewHeight=I(this,this._height),this._origin=[0,0],this._resize=0,this._autosize=1,function(e){var n=e._signals,t=n[W],r=n[V],i=n[G];function a(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,function(n){e._width=n.size,e._viewWidth=B(e,n.size),a()},{size:t}),e._resizeHeight=e.add(null,function(n){e._height=n.size,e._viewHeight=I(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 e._signals.hasOwnProperty(t)?e._signals[t]:n.error("Unrecognized signal name: "+n.stringValue(t))}function $(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 ee(e,n,t,r){var i=$(t,r);return i||((i=M(this,function(){r(n,t.value)})).handler=r,e.on(t,null,i)),e}function ne(e,n,t){var r=$(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=v(i=this),s=c(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(W,t,P),s._resizeWidth.skip(!0)),s.height()!==r&&(o=1,s.signal(V,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 ee(this,e,Z(this,e),n)},Y.removeSignalListener=function(e,n){return ne(this,Z(this,e),n)},Y.addDataListener=function(e,n){return ee(this,e,h(this,e).values,n)},Y.removeDataListener=function(e,n){return ne(this,h(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&&t.prevent,i=t&&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(g(a,t,r))})};if(e===_)a.timer(o,n);else if(e===p)a.addEventListener(n,o,y);else if(e===m?"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&(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",w),z,b(e)),this.on(this.events("view","mouseout",w),z,b(n)),this},Y.data=function(e){return h(this,e).values.value},Y.change=d,Y.insert=function(e,n){return d.call(this,e,t.changeset().insert(n))},Y.remove=function(e,n){return d.call(this,e,t.changeset().remove(n))},Y.scale=function(e){var t=this._runtime.scales;return t.hasOwnProperty(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=r.renderModule(s);return e=a._el=e?j(a,e):null,o||a.error("Unrecognized renderer type: "+s),t=o.handler||r.CanvasHandler,i=e?o.renderer:o.headless,a._renderer=i?U(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,v(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&&(n=n?a._elBind=j(a,n):e.appendChild(k("div",{class:"vega-bindings"})),a._bind.forEach(function(e){e.param.element&&(e.element=j(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 q(this,e,t);return e===r.RenderType.SVG?(a=i.svg(),s=new Blob([a],{type:"image/svg+xml"}),window.URL.createObjectURL(s)):i.canvas().toDataURL("image/png");var a,s},Y.toCanvas=async function(e,n){return(await q(this,r.RenderType.Canvas,e,n)).canvas()},Y.toSVG=async function(e){return(await q(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.0.1",
"version": "5.1.0",
"description": "View component and transforms for Vega visualizations.",

@@ -33,3 +33,4 @@ "keywords": [

"vega-util": "^1.8.0"
}
},
"gitHead": "a34555f5474d42a4599dd958895b8e44d3fda0fe"
}

@@ -80,3 +80,3 @@ import cursor from './cursor';

// initialize background color
view._background = ctx.background || null;
view._background = options.background || ctx.background || null;

@@ -98,2 +98,8 @@ // initialize event configuration

cursor(view);
// initialize hover proessing, if requested
if (options.hover) view.hover();
// initialize DOM container(s) and renderer
if (options.container) view.initialize(options.container, options.bind);
}

@@ -100,0 +106,0 @@

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