vega-encode
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -625,9 +625,13 @@ (function (global, factory) { | ||
} | ||
// calculate full range based on requested step size and padding | ||
// Mirrors https://github.com/d3/d3-scale/blob/master/src/band.js#L23 | ||
// step = span / Math.max(1, n - paddingInner + paddingOuter * 2) | ||
// Mirrors https://github.com/vega/vega-scale/blob/master/src/band.js#L23 | ||
// space = n - paddingInner + paddingOuter * 2; | ||
// step = (stop - start) / (space > 0 ? space : 1); | ||
// with an exception that the formula above replaces space with 1 when space is <= 0 | ||
// to avoid division by zero. Here, we do not have the division by zero problem. | ||
// Thus we can set space = 0 to make range = [0,0] to avoid drawing empty ordinal axis. | ||
var inner = (_.paddingInner != null ? _.paddingInner : _.padding) || 0, | ||
outer = (_.paddingOuter != null ? _.paddingOuter : _.padding) || 0, | ||
space = count ? Math.max(1, count - inner + outer * 2) : 0; | ||
range$$1 = [0, _.rangeStep * space]; | ||
outer = (_.paddingOuter != null ? _.paddingOuter : _.padding) || 0; | ||
range$$1 = [0, _.rangeStep * vegaScale.bandSpace(count, inner, outer)]; | ||
} | ||
@@ -634,0 +638,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-util"),require("d3-format"),require("d3-array"),require("vega-scale"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-format","d3-array","vega-scale","d3-interpolate"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.d3,e.d3,e.vega,e.d3)}(this,function(e,n,r,t,a,i,o){"use strict";function u(e,n){return e.ticks?e.ticks(n):e.domain()}function s(e,n,r){var t=e.tickFormat?e.tickFormat(n,r):String;return"log"===e.type?f(t,l(r)):t}function f(e,n){return function(r){return e(r)?n(r):""}}function l(e){var n=t.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return d(t.format(n),t.format(".1f")(1)[1])}return t.format(n)}function d(e,n){return function(r){var t,a,i=e(r),o=i.indexOf(n);if(o<0)return i;for(t=c(i,o),a=t<i.length?i.slice(t):"";--t>o;)if("0"!==i[t]){++t;break}return i.slice(0,t)+a}}function c(e,n){var r,t=e.lastIndexOf("e");if(t>0)return t;for(t=e.length;--t>n;)if(r=e.charCodeAt(t),r>=48&&r<=57)return t+1}function m(e){n.Transform.call(this,[],e)}function p(e){n.Transform.call(this,null,e)}function h(){return n.ingest({})}function v(e){n.Transform.call(this,null,e)}function g(e){n.Transform.call(this,[],e)}function y(e){return e.source.x}function M(e){return e.source.y}function x(e){return e.target.x}function O(e){return e.target.y}function S(e){n.Transform.call(this,{},e)}function k(e,n,r,t){return"M"+e+","+n+"L"+r+","+t}function A(e,n,r,t){return k(n*Math.cos(e),n*Math.sin(e),t*Math.cos(r),t*Math.sin(r))}function T(e,n,r,t){var a=r-e,i=t-n,o=.2*(a+i),u=.2*(i-a);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(r+u)+","+(t-o)+" "+r+","+t}function D(e,n,r,t){return T(n*Math.cos(e),n*Math.sin(e),t*Math.cos(r),t*Math.sin(r))}function E(e,n,r,t){return"M"+e+","+n+"V"+t+"H"+r}function b(e,n,r,t){return"M"+e+","+n+"H"+r+"V"+t}function z(e,n,r,t){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(r),u=Math.sin(r),s=Math.abs(r-e)>Math.PI?r<=e:r>e;return"M"+n*a+","+n*i+"A"+n+","+n+" 0 0,"+(s?1:0)+" "+n*o+","+n*u+"L"+t*o+","+t*u}function w(e,n,r,t){var a=(e+r)/2;return"M"+e+","+n+"C"+a+","+n+" "+a+","+t+" "+r+","+t}function C(e,n,r,t){var a=(n+t)/2;return"M"+e+","+n+"C"+e+","+a+" "+r+","+a+" "+r+","+t}function L(e,n,r,t){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(r),u=Math.sin(r),s=(n+t)/2;return"M"+n*a+","+n*i+"C"+s*a+","+s*i+" "+s*o+","+s*u+" "+t*o+","+t*u}function R(e){n.Transform.call(this,null,e)}function F(e){n.Transform.call(this,null,e),this.modified(!0)}function _(e,n,r){var t=i.scale((e||"linear").toLowerCase());return t(n&&n.toLowerCase(),r)}function I(e,n){var r,t=n.domain,a=n.zero||void 0===n.zero&&G[e.type];return t?((a||null!=n.domainMin||null!=n.domainMax)&&(r=(t=t.slice()).length-1,a&&(t[0]>0&&(t[0]=0),t[r]<0&&(t[r]=0)),null!=n.domainMin&&(t[0]=n.domainMin),null!=n.domainMax&&(t[r]=n.domainMax)),e.domain(t),n.nice&&e.nice&&e.nice(n.nice!==!0&&+n.nice||null),t.length):0}function P(e,n,t){var a=e.type,i=n.round||!1,u=n.range;if(r.isFunction(e.round)?e.round(i):r.isFunction(e.rangeRound)&&e.interpolate(i?o.interpolateRound:o.interpolate),null!=n.rangeStep){"band"!==a&&"point"!==a&&r.error("Only band and point scales support rangeStep.");var s=(null!=n.paddingInner?n.paddingInner:n.padding)||0,f=(null!=n.paddingOuter?n.paddingOuter:n.padding)||0,l=t?Math.max(1,t-s+2*f):0;u=[0,n.rangeStep*l]}u&&(n.reverse&&(u=u.slice().reverse()),e.range(u))}function N(e){n.Transform.call(this,null,e)}function q(e,n,r,t){var a,i,o,u,s,f,l,d,c,m=[],p=function(e){return e(s)};if(null==n)m.push(e.slice());else for(a={},i=0,o=e.length;i<o;++i)s=e[i],f=n.map(p),l=a[f]||(m.push(a[f]=[]),a[f]),l.push(s);for(f=0,c=0,u=m.length;f<u;++f){for(l=m[f],i=0,d=0,o=l.length;i<o;++i)d+=t(l[i]);l.sum=d,d>c&&(c=d),r&&l.sort(r)}return m.max=c,m}var U=r.inherits(m,n.Transform);U.transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var t=r.fork(r.NO_SOURCE|r.NO_FIELDS),a=this.value,i=e.scale,o=null==e.count?10:e.count,f=e.format||s(i,o,e.formatSpecifier),l=e.values||u(i,o);return a&&(t.rem=a),a=l.map(function(e){return n.ingest({value:e,label:f(e)})}),e.extra&&a.push(n.ingest({extra:{value:a[0].value},label:""})),t.source=t.add=this.value=a,t};var X=function(e,n){return e.hasOwnProperty(n)?e[n]:null},Y=r.inherits(p,n.Transform);Y.transform=function(e,t){var a=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.item||h,o=e.key||n.tupleid,u=this.value||(t=t.addAll(),this.value={});return(e.modified("key")||t.modified(o))&&r.error("DataJoin does not support modified key function or fields."),t.visit(t.ADD,function(e){var n=o(e),r=X(u,n);r?(r.exit?a.add:a.mod).push(r):(u[n]=r=i(e),a.add.push(r)),r.datum=e,r.exit=!1}),t.visit(t.MOD,function(e){var n=o(e),r=X(u,n);r&&a.mod.push(r)}),t.visit(t.REM,function(e){var n=o(e),r=X(u,n);e===r.datum&&(a.rem.push(r),r.exit=!0)}),a};var j=r.inherits(v,n.Transform);j.transform=function(e,n){var t=n.fork(n.ADD_REM),a=n.encode,i="enter"===a,o=e.encoders.update||r.falsy,u=e.encoders.enter||r.falsy,s=e.encoders.exit||r.falsy,f=(a&&!i?e.encoders[a]:o)||r.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){u(n,e),o(n,e),f!==r.falsy&&f!==o&&f(n,e)}),t.modifies(u.output),t.modifies(o.output),f!==r.falsy&&f!==o&&t.modifies(f.output)),n.changed(n.REM)&&s!==r.falsy&&(n.visit(n.REM,function(n){s(n,e)}),t.modifies(s.output)),i||f!==r.falsy){var l=n.MOD|(e.modified()?n.REFLOW:0);i?(n.visit(l,function(n){var r=u(n,e);(f(n,e)||r)&&t.mod.push(n)}),t.mod.length&&t.modifies(u.output)):n.visit(l,function(n){f(n,e)&&t.mod.push(n)}),t.mod.length&&t.modifies(f.output)}return t};var H=r.inherits(g,n.Transform);H.transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var a=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=0,o=this.value,f="gradient"===e.type,l=e.scale,d=null==e.count?5:e.count,c=e.format||s(l,d,e.formatSpecifier),m=e.values||(f?l.domain():u(l,d));if(o&&(a.rem=o),f)var p=e.values?l.domain():m,h=p[0],v=p[p.length-1],g=l.range?l.copy().domain([h,v]).range([0,1]):function(e){return(e-h)/(v-h)};else{var y,M=e.size;r.isFunction(M)?y=m.reduce(function(n,r){return Math.max(n,M(r,e))},0):M=r.constant(y=M||8)}return o=m.map(function(r,t){var a=n.ingest({index:t,label:c(r),value:r});return f?a.perc=g(r):(a.offset=y,a.size=M(r,e),a.total=Math.round(i),i+=a.size),a}),a.source=a.add=this.value=o,a};var J={line:k,"line-radial":A,curve:T,"curve-radial":D,"orthogonal-horizontal":E,"orthogonal-vertical":b,"orthogonal-radial":z,"diagonal-horizontal":w,"diagonal-vertical":C,"diagonal-radial":L},V=r.inherits(S,n.Transform);V.transform=function(e,n){var t=e.sourceX||y,a=e.sourceY||M,i=e.targetX||x,o=e.targetY||O,u=e.as||"path",s=e.orient||"vertical",f=e.shape||"line",l=X(J,f+"-"+s)||X(J,f);return l||r.error("LinkPath unsupported type: "+e.shape+"-"+e.orient),n.visit(n.SOURCE,function(e){e[u]=l(t(e),a(e),i(e),o(e))}),n.reflow(e.modified()).modifies(u)};var W=r.inherits(R,n.Transform);W.transform=function(e,n){var t,i,o,u=e.as||["startAngle","endAngle"],s=u[0],f=u[1],l=e.field||r.one,d=e.startAngle||0,c=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(l),h=p.length,v=d,g=(c-d)/a.sum(p),y=a.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),t=0;t<h;++t)o=p[y[t]],i=m[y[t]],i[s]=v,i[f]=v+=o*g;return this.value=p,n.reflow(e.modified()).modifies(u)};var B={set:1,modified:1,clear:1,type:1,scheme:1,domain:1,domainMin:1,domainMax:1,nice:1,zero:1,range:1,rangeStep:1,round:1,reverse:1},G=r.toSet(["linear","pow","sqrt"]),K=r.inherits(F,n.Transform);K.transform=function(e,n){var t,a=this.value,i=!a||e.modified("type")||e.modified("scheme")||e.scheme&&e.modified("reverse");i&&(this.value=a=_(e.type,e.scheme,e.reverse));for(t in e)B[t]||(r.isFunction(a[t])?a[t](e[t]):n.dataflow.warn("Unsupported scale property: "+t));return P(a,e,I(a,e)),n.fork(n.NO_SOURCE|n.NO_FIELDS)};var Q="center",Z="normalize",$=r.inherits(N,n.Transform);$.transform=function(e,n){var r,t,a,i,o,u,s,f,l,d,c,m,p,h=e.as||["y0","y1"],v=h[0],g=h[1],y=e.field,M=e.offset;for(r=q(n.source,e.groupby,e.sort,y),a=0,o=r.length,s=r.max;a<o;++a)for(t=r[a],f=M===Q?(s-t.sum)/2:0,l=M===Z?1/t.sum:1,m=f,p=0,i=0,u=t.length;i<u;++i)d=t[i],c=m,p+=y(d),m=l*p+f,d[v]=c,d[g]=m;return n.reflow(e.modified()).modifies(h)};var ee={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","curve","diagonal","orthogonal"]},{name:"as",type:"string",default:"path"}]},ne={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},re={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:["y0","y1"]}]};n.register(ee,S),n.register(ne,R),n.register(re,N),n.transform("AxisTicks",m),n.transform("DataJoin",p),n.transform("Encode",v),n.transform("LegendEntries",g),n.transform("Scale",F),e.transform=n.transform,e.definition=n.definition,e.scale=i.scale,e.scheme=i.scheme,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-dataflow"),require("vega-util"),require("d3-format"),require("d3-array"),require("vega-scale"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-format","d3-array","vega-scale","d3-interpolate"],n):n(e.vega=e.vega||{},e.vega,e.vega,e.d3,e.d3,e.vega,e.d3)}(this,function(e,n,r,t,a,i,o){"use strict";function u(e,n){return e.ticks?e.ticks(n):e.domain()}function s(e,n,r){var t=e.tickFormat?e.tickFormat(n,r):String;return"log"===e.type?f(t,l(r)):t}function f(e,n){return function(r){return e(r)?n(r):""}}function l(e){var n=t.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return d(t.format(n),t.format(".1f")(1)[1])}return t.format(n)}function d(e,n){return function(r){var t,a,i=e(r),o=i.indexOf(n);if(o<0)return i;for(t=c(i,o),a=t<i.length?i.slice(t):"";--t>o;)if("0"!==i[t]){++t;break}return i.slice(0,t)+a}}function c(e,n){var r,t=e.lastIndexOf("e");if(t>0)return t;for(t=e.length;--t>n;)if(r=e.charCodeAt(t),r>=48&&r<=57)return t+1}function m(e){n.Transform.call(this,[],e)}function p(e){n.Transform.call(this,null,e)}function h(){return n.ingest({})}function v(e){n.Transform.call(this,null,e)}function g(e){n.Transform.call(this,[],e)}function y(e){return e.source.x}function M(e){return e.source.y}function x(e){return e.target.x}function O(e){return e.target.y}function S(e){n.Transform.call(this,{},e)}function k(e,n,r,t){return"M"+e+","+n+"L"+r+","+t}function A(e,n,r,t){return k(n*Math.cos(e),n*Math.sin(e),t*Math.cos(r),t*Math.sin(r))}function T(e,n,r,t){var a=r-e,i=t-n,o=.2*(a+i),u=.2*(i-a);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(r+u)+","+(t-o)+" "+r+","+t}function b(e,n,r,t){return T(n*Math.cos(e),n*Math.sin(e),t*Math.cos(r),t*Math.sin(r))}function D(e,n,r,t){return"M"+e+","+n+"V"+t+"H"+r}function E(e,n,r,t){return"M"+e+","+n+"H"+r+"V"+t}function z(e,n,r,t){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(r),u=Math.sin(r),s=Math.abs(r-e)>Math.PI?r<=e:r>e;return"M"+n*a+","+n*i+"A"+n+","+n+" 0 0,"+(s?1:0)+" "+n*o+","+n*u+"L"+t*o+","+t*u}function w(e,n,r,t){var a=(e+r)/2;return"M"+e+","+n+"C"+a+","+n+" "+a+","+t+" "+r+","+t}function C(e,n,r,t){var a=(n+t)/2;return"M"+e+","+n+"C"+e+","+a+" "+r+","+a+" "+r+","+t}function L(e,n,r,t){var a=Math.cos(e),i=Math.sin(e),o=Math.cos(r),u=Math.sin(r),s=(n+t)/2;return"M"+n*a+","+n*i+"C"+s*a+","+s*i+" "+s*o+","+s*u+" "+t*o+","+t*u}function R(e){n.Transform.call(this,null,e)}function F(e){n.Transform.call(this,null,e),this.modified(!0)}function _(e,n,r){var t=i.scale((e||"linear").toLowerCase());return t(n&&n.toLowerCase(),r)}function I(e,n){var r,t=n.domain,a=n.zero||void 0===n.zero&&G[e.type];return t?((a||null!=n.domainMin||null!=n.domainMax)&&(r=(t=t.slice()).length-1,a&&(t[0]>0&&(t[0]=0),t[r]<0&&(t[r]=0)),null!=n.domainMin&&(t[0]=n.domainMin),null!=n.domainMax&&(t[r]=n.domainMax)),e.domain(t),n.nice&&e.nice&&e.nice(n.nice!==!0&&+n.nice||null),t.length):0}function P(e,n,t){var a=e.type,u=n.round||!1,s=n.range;if(r.isFunction(e.round)?e.round(u):r.isFunction(e.rangeRound)&&e.interpolate(u?o.interpolateRound:o.interpolate),null!=n.rangeStep){"band"!==a&&"point"!==a&&r.error("Only band and point scales support rangeStep.");var f=(null!=n.paddingInner?n.paddingInner:n.padding)||0,l=(null!=n.paddingOuter?n.paddingOuter:n.padding)||0;s=[0,n.rangeStep*i.bandSpace(t,f,l)]}s&&(n.reverse&&(s=s.slice().reverse()),e.range(s))}function N(e){n.Transform.call(this,null,e)}function q(e,n,r,t){var a,i,o,u,s,f,l,d,c,m=[],p=function(e){return e(s)};if(null==n)m.push(e.slice());else for(a={},i=0,o=e.length;i<o;++i)s=e[i],f=n.map(p),l=a[f]||(m.push(a[f]=[]),a[f]),l.push(s);for(f=0,c=0,u=m.length;f<u;++f){for(l=m[f],i=0,d=0,o=l.length;i<o;++i)d+=t(l[i]);l.sum=d,d>c&&(c=d),r&&l.sort(r)}return m.max=c,m}var U=r.inherits(m,n.Transform);U.transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var t=r.fork(r.NO_SOURCE|r.NO_FIELDS),a=this.value,i=e.scale,o=null==e.count?10:e.count,f=e.format||s(i,o,e.formatSpecifier),l=e.values||u(i,o);return a&&(t.rem=a),a=l.map(function(e){return n.ingest({value:e,label:f(e)})}),e.extra&&a.push(n.ingest({extra:{value:a[0].value},label:""})),t.source=t.add=this.value=a,t};var X=function(e,n){return e.hasOwnProperty(n)?e[n]:null},Y=r.inherits(p,n.Transform);Y.transform=function(e,t){var a=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=e.item||h,o=e.key||n.tupleid,u=this.value||(t=t.addAll(),this.value={});return(e.modified("key")||t.modified(o))&&r.error("DataJoin does not support modified key function or fields."),t.visit(t.ADD,function(e){var n=o(e),r=X(u,n);r?(r.exit?a.add:a.mod).push(r):(u[n]=r=i(e),a.add.push(r)),r.datum=e,r.exit=!1}),t.visit(t.MOD,function(e){var n=o(e),r=X(u,n);r&&a.mod.push(r)}),t.visit(t.REM,function(e){var n=o(e),r=X(u,n);e===r.datum&&(a.rem.push(r),r.exit=!0)}),a};var j=r.inherits(v,n.Transform);j.transform=function(e,n){var t=n.fork(n.ADD_REM),a=n.encode,i="enter"===a,o=e.encoders.update||r.falsy,u=e.encoders.enter||r.falsy,s=e.encoders.exit||r.falsy,f=(a&&!i?e.encoders[a]:o)||r.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){u(n,e),o(n,e),f!==r.falsy&&f!==o&&f(n,e)}),t.modifies(u.output),t.modifies(o.output),f!==r.falsy&&f!==o&&t.modifies(f.output)),n.changed(n.REM)&&s!==r.falsy&&(n.visit(n.REM,function(n){s(n,e)}),t.modifies(s.output)),i||f!==r.falsy){var l=n.MOD|(e.modified()?n.REFLOW:0);i?(n.visit(l,function(n){var r=u(n,e);(f(n,e)||r)&&t.mod.push(n)}),t.mod.length&&t.modifies(u.output)):n.visit(l,function(n){f(n,e)&&t.mod.push(n)}),t.mod.length&&t.modifies(f.output)}return t};var H=r.inherits(g,n.Transform);H.transform=function(e,t){if(null!=this.value&&!e.modified())return t.StopPropagation;var a=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=0,o=this.value,f="gradient"===e.type,l=e.scale,d=null==e.count?5:e.count,c=e.format||s(l,d,e.formatSpecifier),m=e.values||(f?l.domain():u(l,d));if(o&&(a.rem=o),f)var p=e.values?l.domain():m,h=p[0],v=p[p.length-1],g=l.range?l.copy().domain([h,v]).range([0,1]):function(e){return(e-h)/(v-h)};else{var y,M=e.size;r.isFunction(M)?y=m.reduce(function(n,r){return Math.max(n,M(r,e))},0):M=r.constant(y=M||8)}return o=m.map(function(r,t){var a=n.ingest({index:t,label:c(r),value:r});return f?a.perc=g(r):(a.offset=y,a.size=M(r,e),a.total=Math.round(i),i+=a.size),a}),a.source=a.add=this.value=o,a};var J={line:k,"line-radial":A,curve:T,"curve-radial":b,"orthogonal-horizontal":D,"orthogonal-vertical":E,"orthogonal-radial":z,"diagonal-horizontal":w,"diagonal-vertical":C,"diagonal-radial":L},V=r.inherits(S,n.Transform);V.transform=function(e,n){var t=e.sourceX||y,a=e.sourceY||M,i=e.targetX||x,o=e.targetY||O,u=e.as||"path",s=e.orient||"vertical",f=e.shape||"line",l=X(J,f+"-"+s)||X(J,f);return l||r.error("LinkPath unsupported type: "+e.shape+"-"+e.orient),n.visit(n.SOURCE,function(e){e[u]=l(t(e),a(e),i(e),o(e))}),n.reflow(e.modified()).modifies(u)};var W=r.inherits(R,n.Transform);W.transform=function(e,n){var t,i,o,u=e.as||["startAngle","endAngle"],s=u[0],f=u[1],l=e.field||r.one,d=e.startAngle||0,c=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(l),h=p.length,v=d,g=(c-d)/a.sum(p),y=a.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),t=0;t<h;++t)o=p[y[t]],i=m[y[t]],i[s]=v,i[f]=v+=o*g;return this.value=p,n.reflow(e.modified()).modifies(u)};var B={set:1,modified:1,clear:1,type:1,scheme:1,domain:1,domainMin:1,domainMax:1,nice:1,zero:1,range:1,rangeStep:1,round:1,reverse:1},G=r.toSet(["linear","pow","sqrt"]),K=r.inherits(F,n.Transform);K.transform=function(e,n){var t,a=this.value,i=!a||e.modified("type")||e.modified("scheme")||e.scheme&&e.modified("reverse");i&&(this.value=a=_(e.type,e.scheme,e.reverse));for(t in e)B[t]||(r.isFunction(a[t])?a[t](e[t]):n.dataflow.warn("Unsupported scale property: "+t));return P(a,e,I(a,e)),n.fork(n.NO_SOURCE|n.NO_FIELDS)};var Q="center",Z="normalize",$=r.inherits(N,n.Transform);$.transform=function(e,n){var r,t,a,i,o,u,s,f,l,d,c,m,p,h=e.as||["y0","y1"],v=h[0],g=h[1],y=e.field,M=e.offset;for(r=q(n.source,e.groupby,e.sort,y),a=0,o=r.length,s=r.max;a<o;++a)for(t=r[a],f=M===Q?(s-t.sum)/2:0,l=M===Z?1/t.sum:1,m=f,p=0,i=0,u=t.length;i<u;++i)d=t[i],c=m,p+=y(d),m=l*p+f,d[v]=c,d[g]=m;return n.reflow(e.modified()).modifies(h)};var ee={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","curve","diagonal","orthogonal"]},{name:"as",type:"string",default:"path"}]},ne={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},re={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:["y0","y1"]}]};n.register(ee,S),n.register(ne,R),n.register(re,N),n.transform("AxisTicks",m),n.transform("DataJoin",p),n.transform("Encode",v),n.transform("LegendEntries",g),n.transform("Scale",F),e.transform=n.transform,e.definition=n.definition,e.scale=i.scale,e.scheme=i.scheme,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-encode", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"description": "Visual encoding transforms for Vega dataflows.", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"vega-dataflow": ">=2.0.0-beta.4", | ||
"vega-scale": "1", | ||
"vega-scale": ">=1.1", | ||
"vega-util": "1" | ||
@@ -38,0 +38,0 @@ }, |
import {Transform} from 'vega-dataflow'; | ||
import {scale as getScale} from 'vega-scale'; | ||
import {scale as getScale, bandSpace} from 'vega-scale'; | ||
import {error, inherits, isFunction, toSet} from 'vega-util'; | ||
@@ -106,9 +106,13 @@ import {interpolate, interpolateRound} from 'd3-interpolate'; | ||
} | ||
// calculate full range based on requested step size and padding | ||
// Mirrors https://github.com/d3/d3-scale/blob/master/src/band.js#L23 | ||
// step = span / Math.max(1, n - paddingInner + paddingOuter * 2) | ||
// Mirrors https://github.com/vega/vega-scale/blob/master/src/band.js#L23 | ||
// space = n - paddingInner + paddingOuter * 2; | ||
// step = (stop - start) / (space > 0 ? space : 1); | ||
// with an exception that the formula above replaces space with 1 when space is <= 0 | ||
// to avoid division by zero. Here, we do not have the division by zero problem. | ||
// Thus we can set space = 0 to make range = [0,0] to avoid drawing empty ordinal axis. | ||
var inner = (_.paddingInner != null ? _.paddingInner : _.padding) || 0, | ||
outer = (_.paddingOuter != null ? _.paddingOuter : _.padding) || 0, | ||
space = count ? Math.max(1, count - inner + outer * 2) : 0; | ||
range = [0, _.rangeStep * space]; | ||
outer = (_.paddingOuter != null ? _.paddingOuter : _.padding) || 0; | ||
range = [0, _.rangeStep * bandSpace(count, inner, outer)]; | ||
} | ||
@@ -115,0 +119,0 @@ |
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
61493
1366
+ Addedd3-interpolate@3.0.1(transitive)
+ Addedd3-scale@4.0.2(transitive)
+ Addedd3-scale-chromatic@3.1.0(transitive)
+ Addedvega-scale@7.4.1(transitive)
- Removedd3-collection@1.0.7(transitive)
- Removedd3-scale@1.0.7(transitive)
- Removedd3-scale-chromatic@1.5.0(transitive)
- Removedd3-time@1.1.0(transitive)
- Removedd3-time-format@2.3.0(transitive)
- Removedvega-scale@1.1.1(transitive)
Updatedvega-scale@>=1.1