Comparing version 1.0.0-beta.14 to 1.0.0-beta.15
@@ -201,3 +201,3 @@ (function (global, factory) { | ||
flow = {left: 0, right: 0, margin: _.legendMargin || 8}; | ||
axisBounds.union(markBounds); | ||
axisBounds.union(viewBounds); // see vega/vega#694 | ||
@@ -204,0 +204,0 @@ for (i=0, n=legends.length; i<n; ++i) { |
@@ -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("vega-parser"),require("vega-runtime")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util","d3-array","vega-parser","vega-runtime"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega)}(this,function(e,n,t,r,i,a,s){"use strict";function o(e){n.Transform.call(this,null,e)}function u(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 h(e){n.Transform.call(this,null,e)}function c(e){n.Transform.call(this,null,e)}function l(e,n,r){var i,a,s,o,u,d=n.items,h=Math.max(0,n.width||0),c=Math.max(0,n.height||0),l=(new t.Bounds).set(0,0,h,c),f=l.clone(),p=f.clone(),_=[];for(o=0,u=d.length;o<u;++o)switch(i=d[o],i.role){case K:p.union(g(i,h,c));break;case X:_.push(i);break;case Q:case Y:l.union(i.bounds);default:f.union(i.bounds)}if(l.union(p),_.length)for(a={left:0,right:0,margin:r.legendMargin||8},p.union(f),o=0,u=_.length;o<u;++o)s=m(_[o],a,p,h,c),r.autosize===N?l.add(s.x1,0).add(s.x2,0):l.union(s);v(e,n,f,l.union(f),r)}function f(e){var n=+e.grid;return[e.tick?n++:-1,e.label?n++:-1,n+ +e.domain]}function g(e,n,r){var i,a,s=e.items[0],o=s.datum,u=o.orient,d=f(o),h=s.range,c=s.offset,l=s.position,g=s.minExtent,m=s.maxExtent,v=o.title&&s.items[d[2]].items[0],p=s.titlePadding,_=v?v.fontSize+p:0,b=s.bounds,y=0,k=0;switch(b.clear(),(i=d[0])>-1&&b.union(s.items[i].bounds),(i=d[1])>-1&&b.union(s.items[i].bounds),u){case"top":y=l||0,k=-c,a=Math.max(g,Math.min(m,-b.y1)),v&&(v.auto?(v.y=-(p+a),a+=_):b.union(v.bounds)),b.add(0,-a).add(h,0);break;case"left":y=-c,k=l||0,a=Math.max(g,Math.min(m,-b.x1)),v&&(v.auto?(v.x=-(p+a),a+=_):b.union(v.bounds)),b.add(-a,0).add(0,h);break;case"right":y=n+c,k=l||0,a=Math.max(g,Math.min(m,b.x2)),v&&(v.auto?(v.x=p+a,a+=_):b.union(v.bounds)),b.add(0,0).add(a,h);break;case"bottom":y=l||0,k=r+c,a=Math.max(g,Math.min(m,b.y2)),v&&(v.auto?(v.y=p+a,a+=_):b.union(v.bounds)),b.add(0,0).add(h,a)}return s.x=y+.5,s.y=k+.5,t.boundStroke(b.translate(y,k),s),s.mark.bounds.clear().union(b),b}function m(e,n,r,i,a){var s,o,u=e.items[0],d=u.datum,h=d.orient,c=u.offset,l=u.bounds.clear(),f=0,g=n[h]||0;switch(u.items.forEach(function(e){l.union(e.bounds)}),s=Math.round(l.width())+2*u.padding-1,o=Math.round(l.height())+2*u.padding-1,h){case"left":f-=s+c-Math.floor(r.x1),n.left+=o+n.margin;break;case"right":f+=c+Math.ceil(r.x2),n.right+=o+n.margin;break;case"top-left":f+=c,g+=c;break;case"top-right":f+=i-s-c,g+=c;break;case"bottom-left":f+=c,g+=a-o-c;break;case"bottom-right":f+=i-s-c,g+=a-o-c}return u.x=f,u.y=g,u.width=s,u.height=o,t.boundStroke(l.set(f,g,f+s,g+o),u),u.mark.bounds.clear().union(l),l}function v(e,n,t,r,i){var a=i.autosize,s=e._width,o=e._height;if(!(e._autosize<1)&&a){var u=Math.max(0,n.width||0),d=Math.max(0,Math.ceil(-r.x1)),h=Math.max(0,Math.ceil(r.x2-u)),c=Math.max(0,n.height||0),l=Math.max(0,Math.ceil(-r.y1)),f=Math.max(0,Math.ceil(r.y2-c));a===J?(s=u,o=c,d=0,l=0):a===N?(u=Math.max(0,s-d-h),c=Math.max(0,o-l-f)):a===F&&(s=u+d+h,o=c+l+f,n.width<0&&(u=t.width()),n.height<0&&(c=t.height())),e.autosize(s,o,u,c,[d,l])}}function p(e){"undefined"!=typeof document&&document.body&&(document.body.style.cursor=e)}function _(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||e.error("Unrecognized data set: "+n),t[n]}function b(e){return _(this,e).values.value}function y(e,t){return n.isChangeSet(t)||this.error("Second argument to changes must be a changeset."),this.pulse(_(this,e).input,t)}function k(e,t){return this.pulse(_(this,e).input,n.changeset().insert(t))}function x(e,t){return this.pulse(_(this,e).input,n.changeset().remove(t))}function w(e){var n=e.padding();return Math.max(0,e._width+n.left+n.right)}function M(e){var n=e.padding();return Math.max(0,e._height+n.top+n.bottom)}function z(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}function C(e){var n=z(e);e._renderer.background(e._background),e._renderer.resize(w(e),M(e),n),e._handler.origin(n)}function T(e,n,t){function i(e){var t,r=s;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){r=t;break}return r&&r.mark&&r.mark.interactive?r:{}}function a(e){if(!e)return t;r.isString(e)&&(e=i(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 s=n?"group"===n.mark.marktype?n:n.mark.group:null;return{view:r.constant(e),item:r.constant(n||{}),group:i,xy:a,x:function(e){return a(e)[0]},y:function(e){return a(e)[1]}}}function E(e){return e.item}function q(e){var n=e.item.mark.source;return n.source||n}function S(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function L(e,n,t,r){var i=V("div",{class:ae});i.appendChild(V("span",{class:se},t.name||t.signal)),n.appendChild(i);var a=D;switch(t.type){case"checkbox":a=R;break;case"select":a=A;break;case"radio":a=U;break;case"range":a=O}a(e,i,t,r)}function D(e,n,t,r){var i=V("input");for(var a in t)"signal"!==a&&"element"!==a&&i.setAttribute(a,t[a]);i.setAttribute("name",t.signal),i.setAttribute("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=V("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 A(e,n,t,r){var i=V("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};e===r&&(n.selected=!0),i.appendChild(V("option",n,e))}),n.appendChild(i),i.addEventListener("change",function(){e.update(t.options[i.selectedIndex])}),e.elements=[i],e.set=function(e){i.selectedIndex=t.options.indexOf(e)}}function U(e,n,t,r){var i=V("span",{class:oe});n.appendChild(i),e.elements=t.options.map(function(n){var a=ue+t.signal+"-"+n,s={id:a,type:"radio",name:t.signal,value:n};n===r&&(s.checked=!0);var o=V("input",s);return o.addEventListener("change",function(){e.update(n)}),i.appendChild(o),i.appendChild(V("label",{for:a},n)),o}),e.set=function(n){for(var t=e.elements,r=0,i=t.length;r<i;++r)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=V("input",{type:"range",value:r,name:t.signal,min:a,max:s,step:o}),d=V("label",{},+r);n.appendChild(u),n.appendChild(d),u.addEventListener("input",function(){d.textContent=u.value,e.update(+u.value)}),e.elements=[u],e.set=function(e){u.value=e,d.textContent=e}}function V(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}function G(e,n){var t=new Blob([e],{type:n});return window.URL.createObjectURL(t)}function P(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 j(e,n,t,r,i){this.runAfter(function(a){var s=0;a._autosize=0,a.width()!==t&&(s=1,a.width(t),a._resizeWidth.skip(!0)),a.height()!==r&&(s=1,a.height(r),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]===i[0]&&a._origin[1]===i[1]||(a._resize=1,a._origin=i),s&&a.run("enter")})}function H(e,r){r=r||{},n.Dataflow.call(this),this.loader(r.loader||this._loader),this.logLevel(r.logLevel||0),this._el=null,this._renderType=r.renderer||t.RenderType.Canvas,this._scenegraph=new t.Scenegraph;var i=this._scenegraph.root;this._renderer=null,this._handler=(new t.CanvasHandler).scene(i),this._queue=null,this._eventListeners=[];var a=pe(this,e,r.functions);this._runtime=a,this._signals=a.signals,this._bind=(e.bindings||[]).map(function(e){return{state:null,param:e}}),a.root&&a.root.set(i),i.source=a.data.root.input,this.pulse(a.data.root.input,this.changeset().insert(i.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=P(this,"width"),this._resizeHeight=P(this,"height"),ee(this)}var I=r.inherits(o,n.Transform);I.transform=function(e,n){var r,i=e.mark,a=t.Marks[i.marktype],s=a.bound,o=i.bounds;return i.bounds_prev.clear().union(o),a.nested?u(i,s):e.modified()?(o.clear(),i.items.forEach(function(e){o.union(u(e,s))})):(r=n.changed(n.REM),n.visit(n.ADD,function(e){o.union(u(e,s))}),n.visit(n.MOD,function(e){r=r||o.alignsWith(e.bounds),o.union(u(e,s))}),r&&(o.clear(),i.items.forEach(function(e){o.union(e.bounds)}))),n.modifies("bounds")};var B=r.inherits(d,n.Transform);B.transform=function(e,n){var r,i,a=this.value;a||(a=n.dataflow.scenegraph().mark(e.scenepath,e.markdef),a.source=this,this.value=a,i=e.scenepath.context,r=a.group,r.context=i,i.group||(i.group=r));var s="group"===a.marktype?t.GroupItem:t.Item;return n.visit(n.ADD,function(e){s.call(e,a)}),a.items=n.source,n};var W=r.inherits(h,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 r=n.source&&n.source[0];r&&(r.mark.zdirty=!0)}};var N="fit",F="pad",J="none",K="axis",Q="frame",X="legend",Y="scope",Z=r.inherits(c,n.Transform);Z.transform=function(e,n){var t=n.dataflow;return e.mark.items.forEach(function(n){l(t,n,e)}),n};var $="default",ee=function(e){var n=e._signals.cursor;n||(e._signals.cursor=n=e.add({user:$,item:null})),e.on(e.events("view","mousemove"),n,function(e,t){var i=n.value,a=i?r.isString(i)?i:i.user:$,s=t.item&&t.item.cursor||null;return i&&a===i.user&&s==i.item?i:{user:a,item:s}}),e.add(null,function(e){var n=e.cursor,t=this.value;return r.isString(n)||(t=n.item,n=n.user),p(n&&n!==$?n:t||n),t},{cursor:n})},ne=function(e,n,r){var i,a,s,o=e._renderer.element();return o&&(s=z(e),a=n.changedTouches?n.changedTouches[0]:n,i=t.point(a,o),i[0]-=s[0],i[1]-=s[1]),n.vega=T(e,r,i),n.item=r,n},te=function(e,t,r){var i,a=this,s=new n.EventStream(r),o=function(e,n){s.receive(ne(a,e,n)),a.run()};if("view"===e)return a._handler.on(t,o),s;if("window"===e?"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&(i=document.querySelectorAll(e)),!i)return a.warn("Can not resolve event source: "+e),s;for(var u=0,d=i.length;u<d;++u)i[u].addEventListener(t,o);return a._eventListeners.push({type:t,sources:i,handler:o}),s},re=function(e,n){return this.on(this.events("view","mouseover",E),q,S(e||"hover")),this.on(this.events("view","mouseout",E),q,S(n||"update")),this},ie=function(){for(var e,n,t=this._eventListeners,r=t.length;--r>=0;)for(n=t[r],e=n.sources.length;--e>=0;)n.sources[e].removeEventListener(n.type,n.handler)},ae="vega-bind",se="vega-bind-name",oe="vega-bind-radio",ue="vega-option-",de=function(e,n,t){var i=t.param,a=t.state||(t.state={elements:null,set:null,update:function(n){e.signal(i.signal,n).run()},active:!1});return r.isString(n)&&(n=document.querySelector(n)),L(a,n,i,e.signal(i.signal)),a.active||(e.on(e._signals[i.signal],null,function(){a.set(e.signal(i.signal))}),a.active=!0),a},he=function(e,n,t,r){return n=n||new r(e.loader()),n.initialize(t,w(e),M(e),z(e)).background(e._background)},ce=function(e,n,t,r){var i=(new r).scene(e.scenegraph().root).initialize(t,z(e),e);return n&&n.handlers().forEach(function(e){i.on(e.type,e.handler)}),i},le=function(e){var n,r,i=this,a=i._renderType,s=t.renderModule(a);return e?("string"==typeof e&&"undefined"!=typeof document&&(e=document.querySelector(e)),e.innerHTML="",i._el=e):i._el=null,s||i.error("Unrecognized renderer type: "+a),n=s.handler||t.CanvasHandler,r=i._el?s.renderer:s.headless,i._renderer=r?he(i,i._renderer,e,r):null,i._handler=ce(i,i._handler,e,n),e&&i._bind.forEach(function(n){de(i,n.param.element||e,n)}),i},fe=function(e,n){var r=t.renderModule(n);return r&&r.headless?e.runAsync().then(function(){return he(e,null,null,r.headless).renderAsync(e._scenegraph.root)}):Promise.reject("Unrecognized renderer type: "+n)},ge=function(e){return e!==t.RenderType.Canvas&&e!==t.RenderType.SVG&&e!==t.RenderType.PNG?Promise.reject("Unrecognized image type: "+e):fe(this,e).then(function(n){return e===t.RenderType.SVG?G(n.svg(),"image/svg+xml"):n.canvas().toDataURL("image/png")})},me=function(){return fe(this,t.RenderType.CANVAS).then(function(e){return e.canvas()})},ve=function(){return fe(this,t.RenderType.SVG).then(function(e){return e.svg()})},pe=function(e,t,r){var i=r||a.functionContext;return s.parse(t,s.context(e,n.transforms,i))},_e=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},be=r.inherits(H,n.Dataflow);be.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},be.render=function(e){return this._renderer&&(this._resize&&(this._resize=0,C(this)),this._renderer.render(this._scenegraph.root,e)),this},be.enqueue=function(e){this._queue&&e&&e.length&&(this._queue=this._queue.concat(e))},be.signal=function(e,n,t){var r=this._signals[e];return 1===arguments.length?r?r.value:void 0:this.update(r,n,t)},be.scenegraph=function(){return this._scenegraph},be.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},be.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},be.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},be.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},be.renderer=function(e){return arguments.length?(t.renderModule(e)||this.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._renderer&&(this._renderer=this._queue=null,this.initialize(this._el))),this):this._renderType},be.autosize=j,be.data=b,be.change=y,be.insert=k,be.remove=x,be.initialize=le,be.toImageURL=ge,be.toCanvas=me,be.toSVG=ve,be.events=te,be.finalize=ie,be.hover=re,be.state=_e,n.transform("Bound",o),n.transform("Mark",d),n.transform("Render",h),n.transform("ViewLayout",c),e.View=H,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("vega-parser"),require("vega-runtime")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-scenegraph","vega-util","d3-array","vega-parser","vega-runtime"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.vega,e.vega)}(this,function(e,n,t,r,i,a,s){"use strict";function o(e){n.Transform.call(this,null,e)}function u(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 h(e){n.Transform.call(this,null,e)}function c(e){n.Transform.call(this,null,e)}function l(e,n,r){var i,a,s,o,u,d=n.items,h=Math.max(0,n.width||0),c=Math.max(0,n.height||0),l=(new t.Bounds).set(0,0,h,c),f=l.clone(),p=f.clone(),_=[];for(o=0,u=d.length;o<u;++o)switch(i=d[o],i.role){case K:p.union(g(i,h,c));break;case X:_.push(i);break;case Q:case Y:l.union(i.bounds);default:f.union(i.bounds)}if(l.union(p),_.length)for(a={left:0,right:0,margin:r.legendMargin||8},p.union(l),o=0,u=_.length;o<u;++o)s=m(_[o],a,p,h,c),r.autosize===N?l.add(s.x1,0).add(s.x2,0):l.union(s);v(e,n,f,l.union(f),r)}function f(e){var n=+e.grid;return[e.tick?n++:-1,e.label?n++:-1,n+ +e.domain]}function g(e,n,r){var i,a,s=e.items[0],o=s.datum,u=o.orient,d=f(o),h=s.range,c=s.offset,l=s.position,g=s.minExtent,m=s.maxExtent,v=o.title&&s.items[d[2]].items[0],p=s.titlePadding,_=v?v.fontSize+p:0,b=s.bounds,y=0,k=0;switch(b.clear(),(i=d[0])>-1&&b.union(s.items[i].bounds),(i=d[1])>-1&&b.union(s.items[i].bounds),u){case"top":y=l||0,k=-c,a=Math.max(g,Math.min(m,-b.y1)),v&&(v.auto?(v.y=-(p+a),a+=_):b.union(v.bounds)),b.add(0,-a).add(h,0);break;case"left":y=-c,k=l||0,a=Math.max(g,Math.min(m,-b.x1)),v&&(v.auto?(v.x=-(p+a),a+=_):b.union(v.bounds)),b.add(-a,0).add(0,h);break;case"right":y=n+c,k=l||0,a=Math.max(g,Math.min(m,b.x2)),v&&(v.auto?(v.x=p+a,a+=_):b.union(v.bounds)),b.add(0,0).add(a,h);break;case"bottom":y=l||0,k=r+c,a=Math.max(g,Math.min(m,b.y2)),v&&(v.auto?(v.y=p+a,a+=_):b.union(v.bounds)),b.add(0,0).add(h,a)}return s.x=y+.5,s.y=k+.5,t.boundStroke(b.translate(y,k),s),s.mark.bounds.clear().union(b),b}function m(e,n,r,i,a){var s,o,u=e.items[0],d=u.datum,h=d.orient,c=u.offset,l=u.bounds.clear(),f=0,g=n[h]||0;switch(u.items.forEach(function(e){l.union(e.bounds)}),s=Math.round(l.width())+2*u.padding-1,o=Math.round(l.height())+2*u.padding-1,h){case"left":f-=s+c-Math.floor(r.x1),n.left+=o+n.margin;break;case"right":f+=c+Math.ceil(r.x2),n.right+=o+n.margin;break;case"top-left":f+=c,g+=c;break;case"top-right":f+=i-s-c,g+=c;break;case"bottom-left":f+=c,g+=a-o-c;break;case"bottom-right":f+=i-s-c,g+=a-o-c}return u.x=f,u.y=g,u.width=s,u.height=o,t.boundStroke(l.set(f,g,f+s,g+o),u),u.mark.bounds.clear().union(l),l}function v(e,n,t,r,i){var a=i.autosize,s=e._width,o=e._height;if(!(e._autosize<1)&&a){var u=Math.max(0,n.width||0),d=Math.max(0,Math.ceil(-r.x1)),h=Math.max(0,Math.ceil(r.x2-u)),c=Math.max(0,n.height||0),l=Math.max(0,Math.ceil(-r.y1)),f=Math.max(0,Math.ceil(r.y2-c));a===J?(s=u,o=c,d=0,l=0):a===N?(u=Math.max(0,s-d-h),c=Math.max(0,o-l-f)):a===F&&(s=u+d+h,o=c+l+f,n.width<0&&(u=t.width()),n.height<0&&(c=t.height())),e.autosize(s,o,u,c,[d,l])}}function p(e){"undefined"!=typeof document&&document.body&&(document.body.style.cursor=e)}function _(e,n){var t=e._runtime.data;return t.hasOwnProperty(n)||e.error("Unrecognized data set: "+n),t[n]}function b(e){return _(this,e).values.value}function y(e,t){return n.isChangeSet(t)||this.error("Second argument to changes must be a changeset."),this.pulse(_(this,e).input,t)}function k(e,t){return this.pulse(_(this,e).input,n.changeset().insert(t))}function x(e,t){return this.pulse(_(this,e).input,n.changeset().remove(t))}function w(e){var n=e.padding();return Math.max(0,e._width+n.left+n.right)}function M(e){var n=e.padding();return Math.max(0,e._height+n.top+n.bottom)}function z(e){var n=e.padding(),t=e._origin;return[n.left+t[0],n.top+t[1]]}function C(e){var n=z(e);e._renderer.background(e._background),e._renderer.resize(w(e),M(e),n),e._handler.origin(n)}function T(e,n,t){function i(e){var t,r=s;if(e)for(t=n;t;t=t.mark.group)if(t.mark.name===e){r=t;break}return r&&r.mark&&r.mark.interactive?r:{}}function a(e){if(!e)return t;r.isString(e)&&(e=i(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 s=n?"group"===n.mark.marktype?n:n.mark.group:null;return{view:r.constant(e),item:r.constant(n||{}),group:i,xy:a,x:function(e){return a(e)[0]},y:function(e){return a(e)[1]}}}function E(e){return e.item}function q(e){var n=e.item.mark.source;return n.source||n}function S(e){return function(n,t){return t.vega.view().changeset().encode(t.item,e)}}function L(e,n,t,r){var i=V("div",{class:ae});i.appendChild(V("span",{class:se},t.name||t.signal)),n.appendChild(i);var a=D;switch(t.type){case"checkbox":a=R;break;case"select":a=A;break;case"radio":a=U;break;case"range":a=O}a(e,i,t,r)}function D(e,n,t,r){var i=V("input");for(var a in t)"signal"!==a&&"element"!==a&&i.setAttribute(a,t[a]);i.setAttribute("name",t.signal),i.setAttribute("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=V("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 A(e,n,t,r){var i=V("select",{name:t.signal});t.options.forEach(function(e){var n={value:e};e===r&&(n.selected=!0),i.appendChild(V("option",n,e))}),n.appendChild(i),i.addEventListener("change",function(){e.update(t.options[i.selectedIndex])}),e.elements=[i],e.set=function(e){i.selectedIndex=t.options.indexOf(e)}}function U(e,n,t,r){var i=V("span",{class:oe});n.appendChild(i),e.elements=t.options.map(function(n){var a=ue+t.signal+"-"+n,s={id:a,type:"radio",name:t.signal,value:n};n===r&&(s.checked=!0);var o=V("input",s);return o.addEventListener("change",function(){e.update(n)}),i.appendChild(o),i.appendChild(V("label",{for:a},n)),o}),e.set=function(n){for(var t=e.elements,r=0,i=t.length;r<i;++r)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=V("input",{type:"range",value:r,name:t.signal,min:a,max:s,step:o}),d=V("label",{},+r);n.appendChild(u),n.appendChild(d),u.addEventListener("input",function(){d.textContent=u.value,e.update(+u.value)}),e.elements=[u],e.set=function(e){u.value=e,d.textContent=e}}function V(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}function G(e,n){var t=new Blob([e],{type:n});return window.URL.createObjectURL(t)}function P(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 j(e,n,t,r,i){this.runAfter(function(a){var s=0;a._autosize=0,a.width()!==t&&(s=1,a.width(t),a._resizeWidth.skip(!0)),a.height()!==r&&(s=1,a.height(r),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]===i[0]&&a._origin[1]===i[1]||(a._resize=1,a._origin=i),s&&a.run("enter")})}function H(e,r){r=r||{},n.Dataflow.call(this),this.loader(r.loader||this._loader),this.logLevel(r.logLevel||0),this._el=null,this._renderType=r.renderer||t.RenderType.Canvas,this._scenegraph=new t.Scenegraph;var i=this._scenegraph.root;this._renderer=null,this._handler=(new t.CanvasHandler).scene(i),this._queue=null,this._eventListeners=[];var a=pe(this,e,r.functions);this._runtime=a,this._signals=a.signals,this._bind=(e.bindings||[]).map(function(e){return{state:null,param:e}}),a.root&&a.root.set(i),i.source=a.data.root.input,this.pulse(a.data.root.input,this.changeset().insert(i.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=P(this,"width"),this._resizeHeight=P(this,"height"),ee(this)}var I=r.inherits(o,n.Transform);I.transform=function(e,n){var r,i=e.mark,a=t.Marks[i.marktype],s=a.bound,o=i.bounds;return i.bounds_prev.clear().union(o),a.nested?u(i,s):e.modified()?(o.clear(),i.items.forEach(function(e){o.union(u(e,s))})):(r=n.changed(n.REM),n.visit(n.ADD,function(e){o.union(u(e,s))}),n.visit(n.MOD,function(e){r=r||o.alignsWith(e.bounds),o.union(u(e,s))}),r&&(o.clear(),i.items.forEach(function(e){o.union(e.bounds)}))),n.modifies("bounds")};var B=r.inherits(d,n.Transform);B.transform=function(e,n){var r,i,a=this.value;a||(a=n.dataflow.scenegraph().mark(e.scenepath,e.markdef),a.source=this,this.value=a,i=e.scenepath.context,r=a.group,r.context=i,i.group||(i.group=r));var s="group"===a.marktype?t.GroupItem:t.Item;return n.visit(n.ADD,function(e){s.call(e,a)}),a.items=n.source,n};var W=r.inherits(h,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 r=n.source&&n.source[0];r&&(r.mark.zdirty=!0)}};var N="fit",F="pad",J="none",K="axis",Q="frame",X="legend",Y="scope",Z=r.inherits(c,n.Transform);Z.transform=function(e,n){var t=n.dataflow;return e.mark.items.forEach(function(n){l(t,n,e)}),n};var $="default",ee=function(e){var n=e._signals.cursor;n||(e._signals.cursor=n=e.add({user:$,item:null})),e.on(e.events("view","mousemove"),n,function(e,t){var i=n.value,a=i?r.isString(i)?i:i.user:$,s=t.item&&t.item.cursor||null;return i&&a===i.user&&s==i.item?i:{user:a,item:s}}),e.add(null,function(e){var n=e.cursor,t=this.value;return r.isString(n)||(t=n.item,n=n.user),p(n&&n!==$?n:t||n),t},{cursor:n})},ne=function(e,n,r){var i,a,s,o=e._renderer.element();return o&&(s=z(e),a=n.changedTouches?n.changedTouches[0]:n,i=t.point(a,o),i[0]-=s[0],i[1]-=s[1]),n.vega=T(e,r,i),n.item=r,n},te=function(e,t,r){var i,a=this,s=new n.EventStream(r),o=function(e,n){s.receive(ne(a,e,n)),a.run()};if("view"===e)return a._handler.on(t,o),s;if("window"===e?"undefined"!=typeof window&&(i=[window]):"undefined"!=typeof document&&(i=document.querySelectorAll(e)),!i)return a.warn("Can not resolve event source: "+e),s;for(var u=0,d=i.length;u<d;++u)i[u].addEventListener(t,o);return a._eventListeners.push({type:t,sources:i,handler:o}),s},re=function(e,n){return this.on(this.events("view","mouseover",E),q,S(e||"hover")),this.on(this.events("view","mouseout",E),q,S(n||"update")),this},ie=function(){for(var e,n,t=this._eventListeners,r=t.length;--r>=0;)for(n=t[r],e=n.sources.length;--e>=0;)n.sources[e].removeEventListener(n.type,n.handler)},ae="vega-bind",se="vega-bind-name",oe="vega-bind-radio",ue="vega-option-",de=function(e,n,t){var i=t.param,a=t.state||(t.state={elements:null,set:null,update:function(n){e.signal(i.signal,n).run()},active:!1});return r.isString(n)&&(n=document.querySelector(n)),L(a,n,i,e.signal(i.signal)),a.active||(e.on(e._signals[i.signal],null,function(){a.set(e.signal(i.signal))}),a.active=!0),a},he=function(e,n,t,r){return n=n||new r(e.loader()),n.initialize(t,w(e),M(e),z(e)).background(e._background)},ce=function(e,n,t,r){var i=(new r).scene(e.scenegraph().root).initialize(t,z(e),e);return n&&n.handlers().forEach(function(e){i.on(e.type,e.handler)}),i},le=function(e){var n,r,i=this,a=i._renderType,s=t.renderModule(a);return e?("string"==typeof e&&"undefined"!=typeof document&&(e=document.querySelector(e)),e.innerHTML="",i._el=e):i._el=null,s||i.error("Unrecognized renderer type: "+a),n=s.handler||t.CanvasHandler,r=i._el?s.renderer:s.headless,i._renderer=r?he(i,i._renderer,e,r):null,i._handler=ce(i,i._handler,e,n),e&&i._bind.forEach(function(n){de(i,n.param.element||e,n)}),i},fe=function(e,n){var r=t.renderModule(n);return r&&r.headless?e.runAsync().then(function(){return he(e,null,null,r.headless).renderAsync(e._scenegraph.root)}):Promise.reject("Unrecognized renderer type: "+n)},ge=function(e){return e!==t.RenderType.Canvas&&e!==t.RenderType.SVG&&e!==t.RenderType.PNG?Promise.reject("Unrecognized image type: "+e):fe(this,e).then(function(n){return e===t.RenderType.SVG?G(n.svg(),"image/svg+xml"):n.canvas().toDataURL("image/png")})},me=function(){return fe(this,t.RenderType.CANVAS).then(function(e){return e.canvas()})},ve=function(){return fe(this,t.RenderType.SVG).then(function(e){return e.svg()})},pe=function(e,t,r){var i=r||a.functionContext;return s.parse(t,s.context(e,n.transforms,i))},_e=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},be=r.inherits(H,n.Dataflow);be.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},be.render=function(e){return this._renderer&&(this._resize&&(this._resize=0,C(this)),this._renderer.render(this._scenegraph.root,e)),this},be.enqueue=function(e){this._queue&&e&&e.length&&(this._queue=this._queue.concat(e))},be.signal=function(e,n,t){var r=this._signals[e];return 1===arguments.length?r?r.value:void 0:this.update(r,n,t)},be.scenegraph=function(){return this._scenegraph},be.background=function(e){return arguments.length?(this._background=e,this._resize=1,this):this._background},be.width=function(e){return arguments.length?this.signal("width",e):this.signal("width")},be.height=function(e){return arguments.length?this.signal("height",e):this.signal("height")},be.padding=function(e){return arguments.length?this.signal("padding",e):this.signal("padding")},be.renderer=function(e){return arguments.length?(t.renderModule(e)||this.error("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._renderer&&(this._renderer=this._queue=null,this.initialize(this._el))),this):this._renderType},be.autosize=j,be.data=b,be.change=y,be.insert=k,be.remove=x,be.initialize=le,be.toImageURL=ge,be.toCanvas=me,be.toSVG=ve,be.events=te,be.finalize=ie,be.hover=re,be.state=_e,n.transform("Bound",o),n.transform("Mark",d),n.transform("Render",h),n.transform("ViewLayout",c),e.View=H,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-view", | ||
"version": "1.0.0-beta.14", | ||
"version": "1.0.0-beta.15", | ||
"description": "View component and transforms for Vega visualizations.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -67,3 +67,3 @@ import {Transform} from 'vega-dataflow'; | ||
flow = {left: 0, right: 0, margin: _.legendMargin || 8}; | ||
axisBounds.union(markBounds); | ||
axisBounds.union(viewBounds); // see vega/vega#694 | ||
@@ -70,0 +70,0 @@ for (i=0, n=legends.length; i<n; ++i) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106781