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 1.0.0-beta.3 to 1.0.0-beta.4

10

build/vega-view.js

@@ -1065,2 +1065,7 @@ (function (global, factory) {

fn.domain = function(name, group) {
var s = scale(name, (group || this).context);
return s ? s.domain() : [];
};
fn.bandwidth = function(name, group) {

@@ -1088,2 +1093,7 @@ var s = scale(name, (group || this).context);

fn.tuples = function(name) {
var data = this.context.data[name];
return data ? data.values.value : [];
};
fn.indata = function(name, field, value) {

@@ -1090,0 +1100,0 @@ var index = this.context.data[name]['index:' + field],

2

build/vega-view.min.js

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-scenegraph"),require("vega-util"),require("d3-array"),require("d3-format"),require("d3-time-format"),require("vega-runtime"),require("d3-color")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util","d3-array","d3-format","d3-time-format","vega-runtime","d3-color"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.d3,e.d3,e.vega,e.d3)}(this,function(e,n,t,i,r,a,o,u,s){"use strict";function c(e){n.Transform.call(this,null,e)}function h(e,n,t){return e.bounds_prev.clear().union(e.bounds),n(e.bounds.clear(),e,t)}function d(e){n.Transform.call(this,null,e)}function l(e){n.Transform.call(this,null,e)}function f(e){n.Transform.call(this,null,e)}function g(e,n,i){var r,a,o,u,s,c=n.items,h=Math.max(0,n.width||0),d=Math.max(0,n.height||0),l=(new t.Bounds).set(0,0,h,d),f=l.clone(),g=f.clone(),_=[];for(u=0,s=c.length;u<s;++u)switch(r=c[u],r.role){case Q:g.union(v(r,h,d));break;case $:_.push(r);break;case Z:case ee:l.union(r.bounds);default:f.union(r.bounds)}if(l.union(g),_.length)for(a={left:0,right:0,margin:i.legendMargin||8},g.union(f),u=0,s=_.length;u<s;++u)o=m(_[u],a,g,h,d),i.autosize===J?l.add(o.x1,0).add(o.x2,0):l.union(o);p(e,n,f,l.union(f),i)}function v(e,n,i){var r,a=e.items[0],o=a.datum,u=o.orient,s=o.grid?1:0,c=s+1,h=c+(o.domain?2:1),d=a.range,l=a.offset,f=a.position,g=a.minExtent,v=a.maxExtent,m=o.title&&a.items[h].items[0],p=a.titlePadding,_=m?m.fontSize+p:0,b=a.bounds,w=0,x=0;switch(b.clear().union(a.items[s].bounds).union(a.items[c].bounds),u){case"top":w=f||0,x=-l,r=Math.max(g,Math.min(v,-b.y1)),m&&(m.auto?(m.y=-(p+r),r+=_):b.union(m.bounds)),b.add(0,-r).add(d,0);break;case"left":w=-l,x=f||0,r=Math.max(g,Math.min(v,-b.x1)),m&&(m.auto?(m.x=-(p+r),r+=_):b.union(m.bounds)),b.add(-r,0).add(0,d);break;case"right":w=n+l,x=f||0,r=Math.max(g,Math.min(v,b.x2)),m&&(m.auto?(m.x=p+r,r+=_):b.union(m.bounds)),b.add(0,0).add(r,d);break;case"bottom":w=f||0,x=i+l,r=Math.max(g,Math.min(v,b.y2)),m&&(m.auto?(m.y=p+r,r+=_):b.union(m.bounds)),b.add(0,0).add(d,r)}return a.x=w+.5,a.y=x+.5,t.boundStroke(b.translate(w,x),a),a.mark.bounds.clear().union(b),b}function m(e,n,i,r,a){var o,u,s=e.items[0],c=s.datum,h=c.orient,d=s.offset,l=s.bounds.clear(),f=0,g=n[h]||0;switch(s.items.forEach(function(e){l.union(e.bounds)}),o=Math.round(l.width())+2*s.padding-1,u=Math.round(l.height())+2*s.padding-1,h){case"left":f-=o+d-Math.floor(i.x1),n.left+=u+n.margin;break;case"right":f+=d+Math.ceil(i.x2),n.right+=u+n.margin;break;case"top-left":f+=d,g+=d;break;case"top-right":f+=r-o-d,g+=d;break;case"bottom-left":f+=d,g+=a-u-d;break;case"bottom-right":f+=r-o-d,g+=a-u-d}return s.x=f,s.y=g,s.width=o,s.height=u,t.boundStroke(l.set(f,g,f+o,g+u),s),s.mark.bounds.clear().union(l),l}function p(e,n,t,i,r){var a=r.autosize,o=e._width,u=e._height;if(!(e._autosize<1)&&a){var s=Math.max(0,n.width||0),c=Math.max(0,Math.ceil(-i.x1)),h=Math.max(0,Math.ceil(i.x2-s)),d=Math.max(0,n.height||0),l=Math.max(0,Math.ceil(-i.y1)),f=Math.max(0,Math.ceil(i.y2-d));a===N?(o=s,u=d,c=0,l=0):a===J?(s=Math.max(0,o-c-h),d=Math.max(0,u-l-f)):a===K&&(o=s+c+h,u=d+l+f,n.width<0&&(s=t.width()),n.height<0&&(d=t.height())),e.autosize(o,u,s,d,[c,l])}}function _(e,n,t){var r={elements:null,set:null,update:function(n){e.signal(t.signal,n).run()}};return i.isString(n)&&(n=document.querySelector(n)),b(r,n,t,e.signal(t.signal)),e.on(e._signals[t.signal],null,function(){r.set(e.signal(t.signal))}),r}function b(e,n,t,i){var r=z("div",{class:te});r.appendChild(z("span",{class:ie},t.name||t.signal)),n.appendChild(r);var a=w;switch(t.type){case"checkbox":a=x;break;case"select":a=k;break;case"radio":a=y;break;case"range":a=M}a(e,r,t,i)}function w(e,n,t,i){var r=z("input");for(var a in t)"signal"!==a&&"element"!==a&&r.setAttribute(a,t[a]);r.setAttribute("name",t.signal),r.setAttribute("value",i),n.appendChild(r),r.addEventListener("input",function(){e.update(r.value)}),e.elements=[r],e.set=function(e){r.value=e}}function x(e,n,t,i){var r={type:"checkbox",name:t.signal};i&&(r.checked=!0);var a=z("input",r);n.appendChild(a),a.addEventListener("change",function(){e.update(a.checked)}),e.elements=[a],e.set=function(e){a.checked=!!e||null}}function k(e,n,t,i){var r=z("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};e===i&&(n.selected=!0),r.appendChild(z("option",n,e))}),n.appendChild(r),r.addEventListener("change",function(){e.update(t.options[r.selectedIndex])}),e.elements=[r],e.set=function(e){r.selectedIndex=t.options.indexOf(e)}}function y(e,n,t,i){var r=z("span",{class:re});n.appendChild(r),e.elements=t.options.map(function(n){var a=ae+t.signal+"-"+n,o={id:a,type:"radio",name:t.signal,value:n};n===i&&(o.checked=!0);var u=z("input",o);return u.addEventListener("change",function(){e.update(n)}),r.appendChild(u),r.appendChild(z("label",{for:a},n)),u}),e.set=function(n){for(var t=e.elements,i=0,r=t.length;i<r;++i)t[i].value===n&&(t[i].checked=!0)}}function M(e,n,t,i){i=void 0!==i?i:(+t.max+ +t.min)/2;var a=t.min||Math.min(0,+i)||0,o=t.max||Math.max(100,+i)||100,u=t.step||r.tickStep(a,o,100),s=z("input",{type:"range",value:i,name:t.signal,min:a,max:o,step:u}),c=z("label",{},+i);n.appendChild(s),n.appendChild(c),s.addEventListener("input",function(){c.innerText=s.value,e.update(+s.value)}),e.elements=[s],e.set=function(e){s.value=e,c.innerText=e}}function z(e,n,t){var i=document.createElement(e);for(var r in n)i.setAttribute(r,n[r]);return null!=t&&(i.innerText=t),i}function q(e){"undefined"!=typeof document&&document.body&&(document.body.style.cursor=e)}function E(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||e.error("Unrecognized data set: "+n),t[n]}function S(e){return E(this,e).values.value}function T(e,t){return this.pulse(E(this,e).input,n.changeset().insert(t))}function C(e,t){return this.pulse(E(this,e).input,n.changeset().remove(t))}function L(e){var n=e.padding();return Math.max(0,e._width+n.left+n.right)}function D(e){var n=e.padding();return Math.max(0,e._height+n.top+n.bottom)}function A(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}function R(e){var n=A(e);e._renderer.background(e._background),e._renderer.resize(L(e),D(e),n),e._handler.origin(n)}function O(e,n,t){function r(e){var t,i=o;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){i=t;break}return i&&i.mark&&i.mark.interactive?i:{}}function a(e){if(!e)return t;i.isString(e)&&(e=r(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}var o=n?"group"===n.mark.marktype?n:n.mark.group:null;return{view:i.constant(e),item:i.constant(n||{}),group:r,xy:a,x:function(e){return a(e)[0]},y:function(e){return a(e)[1]}}}function G(e){return e.item}function V(e){var n=e.item.mark.source;return n.source||n}function H(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function I(e){var n={};return function(t,i){var r=n[t]||(n[t]=e(t));return r(i)}}function U(e,n){var t=i.isString(e)?n.scales[e]:i.isObject(e)&&e.signal?n.signals[e.signal]:void 0;return t&&t.value}function j(){var e=Me();return e.pad=i.pad,e.truncate=i.truncate,e.rgb=s.rgb,e.lab=s.lab,e.hcl=s.hcl,e.hsl=s.hsl,e.gradient=t.scaleGradient,e.clampRange=function(e,n,t){var i,r=e[0],a=e[1];return a<r&&(i=a,a=r,r=i),i=a-r,[Math.min(Math.max(r,n),t-i),Math.min(Math.max(a,i),t)]},e.pinchDistance=function(){return"Math.sqrt(pow(event.touches[0].clientX - event.touches[1].clientX, 2) + pow(event.touches[0].clientY - event.touches[1].clientY, 2))"},e.pinchAngle=function(){return"Math.atan2(event.touches[1].clientY - event.touches[0].clientY,event.touches[1].clientX - event.touches[0].clientX)"},e.open=function(e,n){var t=this.context.dataflow;"undefined"!=typeof window&&window&&window.open?t.loader().sanitize(e,{context:"open",name:n}).then(function(e){window.open(e,n)}).catch(function(e){t.warn("Open url failed: "+e)}):t.warn("Open function can only be invoked in a browser.")},e.span=function(e){return e[e.length-1]-e[0]},e.range=function(e,n){var t=U(e,(n||this).context);return t&&t.range?t.range():[0,0]},e.bandwidth=function(e,n){var t=U(e,(n||this).context);return t&&t.bandwidth?t.bandwidth():0},e.scaleCopy=function(e,n){var t=U(e,(n||this).context);return t?t.copy():void 0},e.scale=function(e,n,t){var i=U(e,(t||this).context);return i?i(n):void 0},e.scaleInvert=function(e,n,t){var r=U(e,(t||this).context);return r?i.isArray(n)?(r.invertRange||r.invert)(n):(r.invert||r.invertExtent)(n):void 0},e.indata=function(e,n,t){var i=this.context.data[e]["index:"+n],r=i?i.value[t]:void 0;return r?r.count:r},e.inrange=function(e,n){var t,i=n[0],r=n[n.length-1];return i>r&&(t=i,i=r,r=t),i<=e&&e<=r},e.encode=function(e,n,t){if(e){var i=this.context.dataflow,r=e.mark.source;i.pulse(r,i.changeset().encode(e,n))}return void 0!==t?t:e},e.modify=function(e,n,t,r,a,o){var u,s,c=this.context.dataflow,h=this.context.data[e],d=h.input,l=h.changes,f=c.stamp();if(!(d.value.length||n||r))return 0;if((!l||l.stamp<f)&&(h.changes=l=c.changeset(),l.stamp=f,c.runAfter(function(){c.pulse(d,l).run()})),t&&l.remove(t===!0?i.truthy:t),n&&l.insert(n),r&&(u=function(e){for(s in r)if(e[s]!==r[s])return!1;return!0},d.value.filter(u).length?l.remove(u):l.insert(r)),a)for(s in o)l.modify(a,s,o[s]);return 1},e}function B(e,n){var t=e.add(null,function(t){e["_"+n]=t.size,e._autosize=e._resize=1},{size:e._signals[n]});return t.rank=0,t}function F(e,n,t,i,r){this.runAfter(function(a){var o=0;a._autosize=0,a.width()!==t&&(o=1,a.width(t),a._resizeWidth.skip(!0)),a.height()!==i&&(o=1,a.height(i),a._resizeHeight.skip(!0)),a._width!==e&&(a._resize=1,a._width=e),a._height!==n&&(a._resize=1,a._height=n),a._origin[0]===r[0]&&a._origin[1]===r[1]||(a._resize=1,a._origin=r),o&&a.run("enter")})}function P(e,i){i=i||{},n.Dataflow.call(this),this.loader(i.loader||this._loader),this.logLevel(i.logLevel||0),this._el=null,this._renderType=i.renderer||ve,this._scenegraph=new t.Scenegraph;var r=this._scenegraph.root;this._renderer=null,this._handler=(new t.CanvasHandler).scene(r),this._queue=null,this._eventListeners=[];var a=ze(this,e);this._runtime=a,this._signals=a.signals,this._bind=e.bindings,a.root&&a.root.set(r),r.source=a.data.root.input,this.pulse(a.data.root.input,this.changeset().insert(r.items)),this._background=a.background||null,this._width=this.width(),this._height=this.height(),this._origin=[0,0],this._resize=0,this._autosize=1,this._resizeWidth=B(this,"width"),this._resizeHeight=B(this,"height"),se(this)}var X=i.inherits(c,n.Transform);X.transform=function(e,n){var i,r=e.mark,a=t.Marks[r.marktype],o=a.bound,u=r.bounds;return r.bounds_prev.clear().union(u),a.nested?h(r,o):e.modified()?(u.clear(),r.items.forEach(function(e){u.union(h(e,o))})):(i=n.changed(n.REM),n.visit(n.ADD,function(e){u.union(h(e,o))}),n.visit(n.MOD,function(e){i=i||u.alignsWith(e.bounds),u.union(h(e,o))}),i&&(u.clear(),r.items.forEach(function(e){u.union(e.bounds)}))),n.modifies("bounds")};var Y=i.inherits(d,n.Transform);Y.transform=function(e,n){var i=this.value;i||(i=n.dataflow.scenegraph().mark(e.scenepath,e.markdef),i.source=this,this.value=i,i.group.context=e.scenepath.context);var r="group"===i.marktype?t.GroupItem:t.Item;return n.visit(n.ADD,function(e){r.call(e,i)}),i.items=n.source,n};var W=i.inherits(l,n.Transform);W.transform=function(e,n){var t=n.dataflow;if(n.changed(n.REM)&&t.enqueue(n.materialize(n.REM).rem),n.changed(n.ADD)&&t.enqueue(n.materialize(n.ADD).add),n.changed(n.MOD)&&t.enqueue(n.materialize(n.MOD).mod),n.fields&&n.fields.zindex){var i=n.source&&n.source[0];i&&(i.mark.zdirty=!0)}};var J="fit",K="pad",N="none",Q="axis",Z="frame",$="legend",ee="scope",ne=i.inherits(f,n.Transform);ne.transform=function(e,n){var t=n.dataflow;return e.mark.items.forEach(function(n){g(t,n,e)}),n};var te="vega-bind",ie="vega-bind-name",re="vega-bind-radio",ae="vega-option-",oe=function(e,n){return this._el?_(this,e||this._el,n):this.warn("Bind not supported for headless views."),this},ue="default",se=function(e){var n=e._signals.cursor;n||(e._signals.cursor=n=e.add({user:ue,item:null})),e.on(e.events("view","mousemove"),n,function(e,t){var r=n.value,a=r?i.isString(r)?r:r.user:ue,o=t.item&&t.item.cursor||null;return r&&a===r.user&&o==r.item?r:{user:a,item:o}}),e.add(null,function(e){var n=e.cursor,t=this.value;return i.isString(n)||(t=n.item,n=n.user),q(n&&n!==ue?n:t||n),t},{cursor:n})},ce=function(e,n,i){var r,a,o,u=e._renderer.element();return u&&(o=A(e),a=n.changedTouches?n.changedTouches[0]:n,r=t.point(a,u),r[0]-=o[0],r[1]-=o[1]),n.vega=O(e,i,r),n.item=i,n},he=function(e,t,i){var r,a=this,o=new n.EventStream(i),u=function(e,n){o.receive(ce(a,e,n)),a.run()};if("view"===e)return a._handler.on(t,u),o;"window"===e?"undefined"!=typeof window&&(r=[window]):"undefined"!=typeof document&&(r=document.querySelectorAll(e)),r||a.error("Can not resolve event source: "+e);for(var s=0,c=r.length;s<c;++s)r[s].addEventListener(t,u);return a._eventListeners.push({type:t,sources:r,handler:u}),o},de=function(e,n){return this.on(this.events("view","mouseover",G),V,H(e||"hover")),this.on(this.events("view","mouseout",G),V,H(n||"update")),this},le=function(){for(var e,n,t=this._eventListeners,i=t.length;--i>=0;)for(n=t[i],e=n.sources.length;--e>=0;)n.sources[e].removeEventListener(n.type,n.handler)},fe=function(e,n,t,i){return n=n||new i(e.loader()),n.initialize(t,L(e),D(e),A(e)).background(e._background)},ge=function(e,n,t,i){var r=(new i).scene(e.scenegraph().root).initialize(t,A(e),e);return n&&n.handlers().forEach(function(e){r.on(e.type,e.handler)}),r},ve="canvas",me="png",pe="svg",_e="none",be=function(e){var n=this,i=n._renderType,r=t.CanvasHandler,a=t.CanvasRenderer;return i===pe&&(r=t.SVGHandler,a=e?t.SVGRenderer:t.SVGStringRenderer),e?("string"==typeof e&&"undefined"!=typeof document&&(e=document.querySelector(e)),e.innerHTML="",n._el=e):n._el=null,n._renderer=i===_e?null:fe(n,n._renderer,e,a),n._handler=ge(n,n._handler,e,r),e&&n._bind&&n._bind.forEach(function(t){n.bind(t.element||e,t)}),n},we=function(e,n){return e.runAsync().then(function(){var i=n===pe?t.SVGStringRenderer:t.CanvasRenderer;return fe(e,null,null,i).renderAsync(e._scenegraph.root)})},xe=function(e){return e===me&&(e=ve),e!==pe&&e!==ve?Promise.reject("Unrecognized image type: "+e):we(this,e).then(function(n){return e===ve?n.canvas().toDataURL("image/png"):window.URL.createObjectURL(new Blob([n.svg()],{type:"image/svg+xml"}))})},ke=function(){return we(this,ve).then(function(e){return e.canvas()})},ye=function(){return we(this,pe).then(function(e){return e.svg()})},Me=function(){return{format:I(a.format),timeFormat:I(o.timeFormat),utcFormat:I(o.utcFormat)}},ze=function(e,t){return u.parse(t,u.context(e,n.transforms,j()))},qe=function(e){var n,t;if(arguments.length){t={skip:!0};for(n in e)this.signal(n,e[n],t);return this.run()}e={};for(n in this._signals)e[n]=this.signal(n);return e},Ee=i.inherits(P,n.Dataflow);Ee.run=function(e){n.Dataflow.prototype.run.call(this,e);var t=this._queue;return(this._resize||!t||t.length)&&(this.render(t),this._queue=[]),this},Ee.render=function(e){return this._renderer&&(this._resize&&(this._resize=0,R(this)),this._renderer.render(this._scenegraph.root,e)),this},Ee.enqueue=function(e){this._queue&&e&&e.length&&(this._queue=this._queue.concat(e))},Ee.signal=function(e,n,t){var i=this._signals[e];return 1===arguments.length?i?i.value:void 0:this.update(i,n,t)},Ee.scenegraph=function(){return this._scenegraph},Ee.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},Ee.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},Ee.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},Ee.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},Ee.renderer=function(e){return arguments.length?(e!==pe&&e!==_e&&(e=ve),e!==this._renderType&&(this._renderType=e,this._renderer&&(this._renderer=this._queue=null,this.initialize(this._el))),this):this._renderType},Ee.autosize=F,Ee.data=S,Ee.insert=T,Ee.remove=C,Ee.initialize=be,Ee.toImageURL=xe,Ee.toCanvas=ke,Ee.toSVG=ye,Ee.events=he,Ee.finalize=le,Ee.hover=de,Ee.bind=oe,Ee.state=qe,n.transform("Bound",c),n.transform("Mark",d),n.transform("Render",l),n.transform("ViewLayout",f),e.View=P,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-scenegraph"),require("vega-util"),require("d3-array"),require("d3-format"),require("d3-time-format"),require("vega-runtime"),require("d3-color")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util","d3-array","d3-format","d3-time-format","vega-runtime","d3-color"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.d3,e.d3,e.vega,e.d3)}(this,function(e,n,t,i,r,a,o,u,s){"use strict";function c(e){n.Transform.call(this,null,e)}function h(e,n,t){return e.bounds_prev.clear().union(e.bounds),n(e.bounds.clear(),e,t)}function d(e){n.Transform.call(this,null,e)}function l(e){n.Transform.call(this,null,e)}function f(e){n.Transform.call(this,null,e)}function g(e,n,i){var r,a,o,u,s,c=n.items,h=Math.max(0,n.width||0),d=Math.max(0,n.height||0),l=(new t.Bounds).set(0,0,h,d),f=l.clone(),g=f.clone(),_=[];for(u=0,s=c.length;u<s;++u)switch(r=c[u],r.role){case Q:g.union(v(r,h,d));break;case $:_.push(r);break;case Z:case ee:l.union(r.bounds);default:f.union(r.bounds)}if(l.union(g),_.length)for(a={left:0,right:0,margin:i.legendMargin||8},g.union(f),u=0,s=_.length;u<s;++u)o=m(_[u],a,g,h,d),i.autosize===J?l.add(o.x1,0).add(o.x2,0):l.union(o);p(e,n,f,l.union(f),i)}function v(e,n,i){var r,a=e.items[0],o=a.datum,u=o.orient,s=o.grid?1:0,c=s+1,h=c+(o.domain?2:1),d=a.range,l=a.offset,f=a.position,g=a.minExtent,v=a.maxExtent,m=o.title&&a.items[h].items[0],p=a.titlePadding,_=m?m.fontSize+p:0,b=a.bounds,w=0,x=0;switch(b.clear().union(a.items[s].bounds).union(a.items[c].bounds),u){case"top":w=f||0,x=-l,r=Math.max(g,Math.min(v,-b.y1)),m&&(m.auto?(m.y=-(p+r),r+=_):b.union(m.bounds)),b.add(0,-r).add(d,0);break;case"left":w=-l,x=f||0,r=Math.max(g,Math.min(v,-b.x1)),m&&(m.auto?(m.x=-(p+r),r+=_):b.union(m.bounds)),b.add(-r,0).add(0,d);break;case"right":w=n+l,x=f||0,r=Math.max(g,Math.min(v,b.x2)),m&&(m.auto?(m.x=p+r,r+=_):b.union(m.bounds)),b.add(0,0).add(r,d);break;case"bottom":w=f||0,x=i+l,r=Math.max(g,Math.min(v,b.y2)),m&&(m.auto?(m.y=p+r,r+=_):b.union(m.bounds)),b.add(0,0).add(d,r)}return a.x=w+.5,a.y=x+.5,t.boundStroke(b.translate(w,x),a),a.mark.bounds.clear().union(b),b}function m(e,n,i,r,a){var o,u,s=e.items[0],c=s.datum,h=c.orient,d=s.offset,l=s.bounds.clear(),f=0,g=n[h]||0;switch(s.items.forEach(function(e){l.union(e.bounds)}),o=Math.round(l.width())+2*s.padding-1,u=Math.round(l.height())+2*s.padding-1,h){case"left":f-=o+d-Math.floor(i.x1),n.left+=u+n.margin;break;case"right":f+=d+Math.ceil(i.x2),n.right+=u+n.margin;break;case"top-left":f+=d,g+=d;break;case"top-right":f+=r-o-d,g+=d;break;case"bottom-left":f+=d,g+=a-u-d;break;case"bottom-right":f+=r-o-d,g+=a-u-d}return s.x=f,s.y=g,s.width=o,s.height=u,t.boundStroke(l.set(f,g,f+o,g+u),s),s.mark.bounds.clear().union(l),l}function p(e,n,t,i,r){var a=r.autosize,o=e._width,u=e._height;if(!(e._autosize<1)&&a){var s=Math.max(0,n.width||0),c=Math.max(0,Math.ceil(-i.x1)),h=Math.max(0,Math.ceil(i.x2-s)),d=Math.max(0,n.height||0),l=Math.max(0,Math.ceil(-i.y1)),f=Math.max(0,Math.ceil(i.y2-d));a===N?(o=s,u=d,c=0,l=0):a===J?(s=Math.max(0,o-c-h),d=Math.max(0,u-l-f)):a===K&&(o=s+c+h,u=d+l+f,n.width<0&&(s=t.width()),n.height<0&&(d=t.height())),e.autosize(o,u,s,d,[c,l])}}function _(e,n,t){var r={elements:null,set:null,update:function(n){e.signal(t.signal,n).run()}};return i.isString(n)&&(n=document.querySelector(n)),b(r,n,t,e.signal(t.signal)),e.on(e._signals[t.signal],null,function(){r.set(e.signal(t.signal))}),r}function b(e,n,t,i){var r=z("div",{class:te});r.appendChild(z("span",{class:ie},t.name||t.signal)),n.appendChild(r);var a=w;switch(t.type){case"checkbox":a=x;break;case"select":a=k;break;case"radio":a=y;break;case"range":a=M}a(e,r,t,i)}function w(e,n,t,i){var r=z("input");for(var a in t)"signal"!==a&&"element"!==a&&r.setAttribute(a,t[a]);r.setAttribute("name",t.signal),r.setAttribute("value",i),n.appendChild(r),r.addEventListener("input",function(){e.update(r.value)}),e.elements=[r],e.set=function(e){r.value=e}}function x(e,n,t,i){var r={type:"checkbox",name:t.signal};i&&(r.checked=!0);var a=z("input",r);n.appendChild(a),a.addEventListener("change",function(){e.update(a.checked)}),e.elements=[a],e.set=function(e){a.checked=!!e||null}}function k(e,n,t,i){var r=z("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};e===i&&(n.selected=!0),r.appendChild(z("option",n,e))}),n.appendChild(r),r.addEventListener("change",function(){e.update(t.options[r.selectedIndex])}),e.elements=[r],e.set=function(e){r.selectedIndex=t.options.indexOf(e)}}function y(e,n,t,i){var r=z("span",{class:re});n.appendChild(r),e.elements=t.options.map(function(n){var a=ae+t.signal+"-"+n,o={id:a,type:"radio",name:t.signal,value:n};n===i&&(o.checked=!0);var u=z("input",o);return u.addEventListener("change",function(){e.update(n)}),r.appendChild(u),r.appendChild(z("label",{for:a},n)),u}),e.set=function(n){for(var t=e.elements,i=0,r=t.length;i<r;++i)t[i].value===n&&(t[i].checked=!0)}}function M(e,n,t,i){i=void 0!==i?i:(+t.max+ +t.min)/2;var a=t.min||Math.min(0,+i)||0,o=t.max||Math.max(100,+i)||100,u=t.step||r.tickStep(a,o,100),s=z("input",{type:"range",value:i,name:t.signal,min:a,max:o,step:u}),c=z("label",{},+i);n.appendChild(s),n.appendChild(c),s.addEventListener("input",function(){c.innerText=s.value,e.update(+s.value)}),e.elements=[s],e.set=function(e){s.value=e,c.innerText=e}}function z(e,n,t){var i=document.createElement(e);for(var r in n)i.setAttribute(r,n[r]);return null!=t&&(i.innerText=t),i}function q(e){"undefined"!=typeof document&&document.body&&(document.body.style.cursor=e)}function E(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||e.error("Unrecognized data set: "+n),t[n]}function S(e){return E(this,e).values.value}function T(e,t){return this.pulse(E(this,e).input,n.changeset().insert(t))}function C(e,t){return this.pulse(E(this,e).input,n.changeset().remove(t))}function L(e){var n=e.padding();return Math.max(0,e._width+n.left+n.right)}function D(e){var n=e.padding();return Math.max(0,e._height+n.top+n.bottom)}function A(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}function R(e){var n=A(e);e._renderer.background(e._background),e._renderer.resize(L(e),D(e),n),e._handler.origin(n)}function O(e,n,t){function r(e){var t,i=o;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){i=t;break}return i&&i.mark&&i.mark.interactive?i:{}}function a(e){if(!e)return t;i.isString(e)&&(e=r(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}var o=n?"group"===n.mark.marktype?n:n.mark.group:null;return{view:i.constant(e),item:i.constant(n||{}),group:r,xy:a,x:function(e){return a(e)[0]},y:function(e){return a(e)[1]}}}function G(e){return e.item}function V(e){var n=e.item.mark.source;return n.source||n}function H(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function I(e){var n={};return function(t,i){var r=n[t]||(n[t]=e(t));return r(i)}}function U(e,n){var t=i.isString(e)?n.scales[e]:i.isObject(e)&&e.signal?n.signals[e.signal]:void 0;return t&&t.value}function j(){var e=Me();return e.pad=i.pad,e.truncate=i.truncate,e.rgb=s.rgb,e.lab=s.lab,e.hcl=s.hcl,e.hsl=s.hsl,e.gradient=t.scaleGradient,e.clampRange=function(e,n,t){var i,r=e[0],a=e[1];return a<r&&(i=a,a=r,r=i),i=a-r,[Math.min(Math.max(r,n),t-i),Math.min(Math.max(a,i),t)]},e.pinchDistance=function(){return"Math.sqrt(pow(event.touches[0].clientX - event.touches[1].clientX, 2) + pow(event.touches[0].clientY - event.touches[1].clientY, 2))"},e.pinchAngle=function(){return"Math.atan2(event.touches[1].clientY - event.touches[0].clientY,event.touches[1].clientX - event.touches[0].clientX)"},e.open=function(e,n){var t=this.context.dataflow;"undefined"!=typeof window&&window&&window.open?t.loader().sanitize(e,{context:"open",name:n}).then(function(e){window.open(e,n)}).catch(function(e){t.warn("Open url failed: "+e)}):t.warn("Open function can only be invoked in a browser.")},e.span=function(e){return e[e.length-1]-e[0]},e.range=function(e,n){var t=U(e,(n||this).context);return t&&t.range?t.range():[0,0]},e.domain=function(e,n){var t=U(e,(n||this).context);return t?t.domain():[]},e.bandwidth=function(e,n){var t=U(e,(n||this).context);return t&&t.bandwidth?t.bandwidth():0},e.scaleCopy=function(e,n){var t=U(e,(n||this).context);return t?t.copy():void 0},e.scale=function(e,n,t){var i=U(e,(t||this).context);return i?i(n):void 0},e.scaleInvert=function(e,n,t){var r=U(e,(t||this).context);return r?i.isArray(n)?(r.invertRange||r.invert)(n):(r.invert||r.invertExtent)(n):void 0},e.tuples=function(e){var n=this.context.data[e];return n?n.values.value:[]},e.indata=function(e,n,t){var i=this.context.data[e]["index:"+n],r=i?i.value[t]:void 0;return r?r.count:r},e.inrange=function(e,n){var t,i=n[0],r=n[n.length-1];return i>r&&(t=i,i=r,r=t),i<=e&&e<=r},e.encode=function(e,n,t){if(e){var i=this.context.dataflow,r=e.mark.source;i.pulse(r,i.changeset().encode(e,n))}return void 0!==t?t:e},e.modify=function(e,n,t,r,a,o){var u,s,c=this.context.dataflow,h=this.context.data[e],d=h.input,l=h.changes,f=c.stamp();if(!(d.value.length||n||r))return 0;if((!l||l.stamp<f)&&(h.changes=l=c.changeset(),l.stamp=f,c.runAfter(function(){c.pulse(d,l).run()})),t&&l.remove(t===!0?i.truthy:t),n&&l.insert(n),r&&(u=function(e){for(s in r)if(e[s]!==r[s])return!1;return!0},d.value.filter(u).length?l.remove(u):l.insert(r)),a)for(s in o)l.modify(a,s,o[s]);return 1},e}function B(e,n){var t=e.add(null,function(t){e["_"+n]=t.size,e._autosize=e._resize=1},{size:e._signals[n]});return t.rank=0,t}function F(e,n,t,i,r){this.runAfter(function(a){var o=0;a._autosize=0,a.width()!==t&&(o=1,a.width(t),a._resizeWidth.skip(!0)),a.height()!==i&&(o=1,a.height(i),a._resizeHeight.skip(!0)),a._width!==e&&(a._resize=1,a._width=e),a._height!==n&&(a._resize=1,a._height=n),a._origin[0]===r[0]&&a._origin[1]===r[1]||(a._resize=1,a._origin=r),o&&a.run("enter")})}function P(e,i){i=i||{},n.Dataflow.call(this),this.loader(i.loader||this._loader),this.logLevel(i.logLevel||0),this._el=null,this._renderType=i.renderer||ve,this._scenegraph=new t.Scenegraph;var r=this._scenegraph.root;this._renderer=null,this._handler=(new t.CanvasHandler).scene(r),this._queue=null,this._eventListeners=[];var a=ze(this,e);this._runtime=a,this._signals=a.signals,this._bind=e.bindings,a.root&&a.root.set(r),r.source=a.data.root.input,this.pulse(a.data.root.input,this.changeset().insert(r.items)),this._background=a.background||null,this._width=this.width(),this._height=this.height(),this._origin=[0,0],this._resize=0,this._autosize=1,this._resizeWidth=B(this,"width"),this._resizeHeight=B(this,"height"),se(this)}var X=i.inherits(c,n.Transform);X.transform=function(e,n){var i,r=e.mark,a=t.Marks[r.marktype],o=a.bound,u=r.bounds;return r.bounds_prev.clear().union(u),a.nested?h(r,o):e.modified()?(u.clear(),r.items.forEach(function(e){u.union(h(e,o))})):(i=n.changed(n.REM),n.visit(n.ADD,function(e){u.union(h(e,o))}),n.visit(n.MOD,function(e){i=i||u.alignsWith(e.bounds),u.union(h(e,o))}),i&&(u.clear(),r.items.forEach(function(e){u.union(e.bounds)}))),n.modifies("bounds")};var Y=i.inherits(d,n.Transform);Y.transform=function(e,n){var i=this.value;i||(i=n.dataflow.scenegraph().mark(e.scenepath,e.markdef),i.source=this,this.value=i,i.group.context=e.scenepath.context);var r="group"===i.marktype?t.GroupItem:t.Item;return n.visit(n.ADD,function(e){r.call(e,i)}),i.items=n.source,n};var W=i.inherits(l,n.Transform);W.transform=function(e,n){var t=n.dataflow;if(n.changed(n.REM)&&t.enqueue(n.materialize(n.REM).rem),n.changed(n.ADD)&&t.enqueue(n.materialize(n.ADD).add),n.changed(n.MOD)&&t.enqueue(n.materialize(n.MOD).mod),n.fields&&n.fields.zindex){var i=n.source&&n.source[0];i&&(i.mark.zdirty=!0)}};var J="fit",K="pad",N="none",Q="axis",Z="frame",$="legend",ee="scope",ne=i.inherits(f,n.Transform);ne.transform=function(e,n){var t=n.dataflow;return e.mark.items.forEach(function(n){g(t,n,e)}),n};var te="vega-bind",ie="vega-bind-name",re="vega-bind-radio",ae="vega-option-",oe=function(e,n){return this._el?_(this,e||this._el,n):this.warn("Bind not supported for headless views."),this},ue="default",se=function(e){var n=e._signals.cursor;n||(e._signals.cursor=n=e.add({user:ue,item:null})),e.on(e.events("view","mousemove"),n,function(e,t){var r=n.value,a=r?i.isString(r)?r:r.user:ue,o=t.item&&t.item.cursor||null;return r&&a===r.user&&o==r.item?r:{user:a,item:o}}),e.add(null,function(e){var n=e.cursor,t=this.value;return i.isString(n)||(t=n.item,n=n.user),q(n&&n!==ue?n:t||n),t},{cursor:n})},ce=function(e,n,i){var r,a,o,u=e._renderer.element();return u&&(o=A(e),a=n.changedTouches?n.changedTouches[0]:n,r=t.point(a,u),r[0]-=o[0],r[1]-=o[1]),n.vega=O(e,i,r),n.item=i,n},he=function(e,t,i){var r,a=this,o=new n.EventStream(i),u=function(e,n){o.receive(ce(a,e,n)),a.run()};if("view"===e)return a._handler.on(t,u),o;"window"===e?"undefined"!=typeof window&&(r=[window]):"undefined"!=typeof document&&(r=document.querySelectorAll(e)),r||a.error("Can not resolve event source: "+e);for(var s=0,c=r.length;s<c;++s)r[s].addEventListener(t,u);return a._eventListeners.push({type:t,sources:r,handler:u}),o},de=function(e,n){return this.on(this.events("view","mouseover",G),V,H(e||"hover")),this.on(this.events("view","mouseout",G),V,H(n||"update")),this},le=function(){for(var e,n,t=this._eventListeners,i=t.length;--i>=0;)for(n=t[i],e=n.sources.length;--e>=0;)n.sources[e].removeEventListener(n.type,n.handler)},fe=function(e,n,t,i){return n=n||new i(e.loader()),n.initialize(t,L(e),D(e),A(e)).background(e._background)},ge=function(e,n,t,i){var r=(new i).scene(e.scenegraph().root).initialize(t,A(e),e);return n&&n.handlers().forEach(function(e){r.on(e.type,e.handler)}),r},ve="canvas",me="png",pe="svg",_e="none",be=function(e){var n=this,i=n._renderType,r=t.CanvasHandler,a=t.CanvasRenderer;return i===pe&&(r=t.SVGHandler,a=e?t.SVGRenderer:t.SVGStringRenderer),e?("string"==typeof e&&"undefined"!=typeof document&&(e=document.querySelector(e)),e.innerHTML="",n._el=e):n._el=null,n._renderer=i===_e?null:fe(n,n._renderer,e,a),n._handler=ge(n,n._handler,e,r),e&&n._bind&&n._bind.forEach(function(t){n.bind(t.element||e,t)}),n},we=function(e,n){return e.runAsync().then(function(){var i=n===pe?t.SVGStringRenderer:t.CanvasRenderer;return fe(e,null,null,i).renderAsync(e._scenegraph.root)})},xe=function(e){return e===me&&(e=ve),e!==pe&&e!==ve?Promise.reject("Unrecognized image type: "+e):we(this,e).then(function(n){return e===ve?n.canvas().toDataURL("image/png"):window.URL.createObjectURL(new Blob([n.svg()],{type:"image/svg+xml"}))})},ke=function(){return we(this,ve).then(function(e){return e.canvas()})},ye=function(){return we(this,pe).then(function(e){return e.svg()})},Me=function(){return{format:I(a.format),timeFormat:I(o.timeFormat),utcFormat:I(o.utcFormat)}},ze=function(e,t){return u.parse(t,u.context(e,n.transforms,j()))},qe=function(e){var n,t;if(arguments.length){t={skip:!0};for(n in e)this.signal(n,e[n],t);return this.run()}e={};for(n in this._signals)e[n]=this.signal(n);return e},Ee=i.inherits(P,n.Dataflow);Ee.run=function(e){n.Dataflow.prototype.run.call(this,e);var t=this._queue;return(this._resize||!t||t.length)&&(this.render(t),this._queue=[]),this},Ee.render=function(e){return this._renderer&&(this._resize&&(this._resize=0,R(this)),this._renderer.render(this._scenegraph.root,e)),this},Ee.enqueue=function(e){this._queue&&e&&e.length&&(this._queue=this._queue.concat(e))},Ee.signal=function(e,n,t){var i=this._signals[e];return 1===arguments.length?i?i.value:void 0:this.update(i,n,t)},Ee.scenegraph=function(){return this._scenegraph},Ee.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},Ee.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},Ee.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},Ee.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},Ee.renderer=function(e){return arguments.length?(e!==pe&&e!==_e&&(e=ve),e!==this._renderType&&(this._renderType=e,this._renderer&&(this._renderer=this._queue=null,this.initialize(this._el))),this):this._renderType},Ee.autosize=F,Ee.data=S,Ee.insert=T,Ee.remove=C,Ee.initialize=be,Ee.toImageURL=xe,Ee.toCanvas=ke,Ee.toSVG=ye,Ee.events=he,Ee.finalize=le,Ee.hover=de,Ee.bind=oe,Ee.state=qe,n.transform("Bound",c),n.transform("Mark",d),n.transform("Render",l),n.transform("ViewLayout",f),e.View=P,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "vega-view",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "View component and transforms for Vega visualizations.",

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

@@ -74,2 +74,7 @@ import formats from './formats';

fn.domain = function(name, group) {
var s = scale(name, (group || this).context);
return s ? s.domain() : [];
};
fn.bandwidth = function(name, group) {

@@ -97,2 +102,7 @@ var s = scale(name, (group || this).context);

fn.tuples = function(name) {
var data = this.context.data[name];
return data ? data.values.value : [];
};
fn.indata = function(name, field, value) {

@@ -99,0 +109,0 @@ var index = this.context.data[name]['index:' + field],

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