Comparing version 4.3.1 to 4.3.2
@@ -176,4 +176,4 @@ (function (global, factory) { | ||
if (!arguments.length) return [dx, dy]; | ||
var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]); | ||
if (!(_0 > 0) || !(_1 > 0)) vegaUtil.error('invalid size'); | ||
var _0 = Math.floor(_[0]), _1 = Math.floor(_[1]); | ||
if (!(_0 >= 0 && _1 >= 0)) vegaUtil.error('invalid size'); | ||
return dx = _0, dy = _1, contours; | ||
@@ -460,4 +460,4 @@ }; | ||
if (!arguments.length) return [dx, dy]; | ||
var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]); | ||
if (!(_0 >= 0) && !(_1 >= 0)) vegaUtil.error('invalid size'); | ||
var _0 = +_[0], _1 = +_[1]; | ||
if (!(_0 >= 0 && _1 >= 0)) vegaUtil.error('invalid size'); | ||
return dx = _0, dy = _1, density; | ||
@@ -464,0 +464,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util"),require("d3-array"),require("vega-statistics"),require("vega-projection"),require("d3-geo"),require("d3-color"),require("vega-canvas")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-array","vega-statistics","vega-projection","d3-geo","d3-color","vega-canvas"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.d3,e.vega,e.vega,e.d3,e.d3,e.vega)}(this,(function(e,t,n,r,a,i,o,u,s){"use strict";function l(){}const f=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function c(){var e=1,t=1,r=u;function a(e,t){return t.map(t=>i(e,t))}function i(n,a){var i=[],u=[];return function(n,r,a){var i,u,s,l,c,d,m=new Array,p=new Array;i=u=-1,l=n[0]>=r,f[l<<1].forEach(h);for(;++i<e-1;)s=l,l=n[i+1]>=r,f[s|l<<1].forEach(h);f[l<<0].forEach(h);for(;++u<t-1;){for(i=-1,l=n[u*e+e]>=r,c=n[u*e]>=r,f[l<<1|c<<2].forEach(h);++i<e-1;)s=l,l=n[u*e+e+i+1]>=r,d=c,c=n[u*e+i+1]>=r,f[s|l<<1|c<<2|d<<3].forEach(h);f[l|c<<3].forEach(h)}i=-1,c=n[u*e]>=r,f[c<<2].forEach(h);for(;++i<e-1;)d=c,c=n[u*e+i+1]>=r,f[c<<2|d<<3].forEach(h);function h(e){var t,n,r=[e[0][0]+i,e[0][1]+u],s=[e[1][0]+i,e[1][1]+u],l=o(r),f=o(s);(t=p[l])?(n=m[f])?(delete p[t.end],delete m[n.start],t===n?(t.ring.push(s),a(t.ring)):m[t.start]=p[n.end]={start:t.start,end:n.end,ring:t.ring.concat(n.ring)}):(delete p[t.end],t.ring.push(s),p[t.end=f]=t):(t=m[f])?(n=p[l])?(delete m[t.start],delete p[n.end],t===n?(t.ring.push(s),a(t.ring)):m[n.start]=p[t.end]={start:n.start,end:t.end,ring:n.ring.concat(t.ring)}):(delete m[t.start],t.ring.unshift(r),m[t.start=l]=t):m[l]=p[f]={start:l,end:f,ring:[r,s]}}f[c<<3].forEach(h)}(n,a,(function(e){r(e,n,a),function(e){var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];for(;++t<n;)r+=e[t-1][1]*e[t][0]-e[t-1][0]*e[t][1];return r}(e)>0?i.push([e]):u.push(e)})),u.forEach((function(e){for(var t,n=0,r=i.length;n<r;++n)if(-1!==d((t=i[n])[0],e))return void t.push(e)})),{type:"MultiPolygon",value:a,coordinates:i}}function o(t){return 2*t[0]+t[1]*(e+1)*4}function u(n,r,a){n.forEach((function(n){var i,o=n[0],u=n[1],s=0|o,l=0|u,f=r[l*e+s];o>0&&o<e&&s===o&&(i=r[l*e+s-1],n[0]=o+(a-i)/(f-i)-.5),u>0&&u<t&&l===u&&(i=r[(l-1)*e+s],n[1]=u+(a-i)/(f-i)-.5)}))}return a.contour=i,a.size=function(r){if(!arguments.length)return[e,t];var i=Math.ceil(r[0]),o=Math.ceil(r[1]);return i>0&&o>0||n.error("invalid size"),e=i,t=o,a},a.smooth=function(e){return arguments.length?(r=e?u:l,a):r===u},a}function d(e,t){for(var n,r=-1,a=t.length;++r<a;)if(n=m(e,t[r]))return n;return 0}function m(e,t){for(var n=t[0],r=t[1],a=-1,i=0,o=e.length,u=o-1;i<o;u=i++){var s=e[i],l=s[0],f=s[1],c=e[u],d=c[0],m=c[1];if(p(s,c,t))return 0;f>r!=m>r&&n<(d-l)*(r-f)/(m-f)+l&&(a=-a)}return a}function p(e,t,n){var r,a,i,o;return function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])==(n[0]-e[0])*(t[1]-e[1])}(e,t,n)&&(a=e[r=+(e[0]===t[0])],i=n[r],o=t[r],a<=i&&i<=o||o<=i&&i<=a)}function h(e,t,a){return function(i){var o=n.extent(i),u=a?Math.min(o[0],0):o[0],s=o[1],l=s-u,f=t?r.tickStep(u,s,e):l/(e+1);return r.range(f,s,f)}}function y(e){t.Transform.call(this,null,e)}function g(e,t,n,r,a){const i=e.x1||0,o=e.y1||0,u=t*n<0;function s(e){e.forEach(l)}function l(e){u&&e.reverse(),e.forEach(f)}function f(e){e[0]=(e[0]-i)*t+r,e[1]=(e[1]-o)*n+a}return function(e){return e.coordinates.forEach(s),e}}function v(e,t,n){const r=e>=0?e:a.bandwidthNRD(t,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2)}function b(e){return n.isFunction(e)?e:n.constant(+e)}function x(){var e=e=>e[0],t=e=>e[1],a=n.one,i=[-1,-1],o=960,u=500,s=2;function l(n,l){const f=v(i[0],n,e)>>s,c=v(i[1],n,t)>>s,d=f?f+2:0,m=c?c+2:0,p=2*d+(o>>s),h=2*m+(u>>s),y=new Float32Array(p*h),g=new Float32Array(p*h);let b=y;n.forEach(n=>{const r=d+(+e(n)>>s),i=m+(+t(n)>>s);r>=0&&r<p&&i>=0&&i<h&&(y[r+i*p]+=+a(n))}),f>0&&c>0?(E(p,h,y,g,f),D(p,h,g,y,c),E(p,h,y,g,f),D(p,h,g,y,c),E(p,h,y,g,f),D(p,h,g,y,c)):f>0?(E(p,h,y,g,f),E(p,h,g,y,f),E(p,h,y,g,f),b=g):c>0&&(D(p,h,y,g,c),D(p,h,g,y,c),D(p,h,y,g,c),b=g);let x=l?Math.pow(2,-2*s):1/r.sum(b);for(let e=0,t=p*h;e<t;++e)b[e]*=x;return{values:b,scale:1<<s,width:p,height:h,x1:d,y1:m,x2:d+(o>>s),y2:m+(u>>s)}}return l.x=function(t){return arguments.length?(e=b(t),l):e},l.y=function(e){return arguments.length?(t=b(e),l):t},l.weight=function(e){return arguments.length?(a=b(e),l):a},l.size=function(e){if(!arguments.length)return[o,u];var t=Math.ceil(e[0]),r=Math.ceil(e[1]);return t>=0||r>=0||n.error("invalid size"),o=t,u=r,l},l.cellSize=function(e){return arguments.length?((e=+e)>=1||n.error("invalid cell size"),s=Math.floor(Math.log(e)/Math.LN2),l):1<<s},l.bandwidth=function(e){return arguments.length?(1===(e=n.array(e)).length&&(e=[+e[0],+e[0]]),2!==e.length&&n.error("invalid bandwidth"),i=e,l):i},l}function E(e,t,n,r,a){const i=1+(a<<1);for(let o=0;o<t;++o)for(let t=0,u=0;t<e+a;++t)t<e&&(u+=n[t+o*e]),t>=a&&(t>=i&&(u-=n[t-i+o*e]),r[t-a+o*e]=u/Math.min(t+1,e-1+i-t,i))}function D(e,t,n,r,a){const i=1+(a<<1);for(let o=0;o<e;++o)for(let u=0,s=0;u<t+a;++u)u<t&&(s+=n[o+u*e]),u>=a&&(u>=i&&(s-=n[o+(u-i)*e]),r[o+(u-a)*e]=s/Math.min(u+1,t-1+i-u,i))}function z(e){t.Transform.call(this,null,e)}y.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]},n.inherits(y,t.Transform).transform=function(e,a){if(this.value&&!a.changed()&&!e.modified())return a.StopPropagation;var i=a.fork(a.NO_SOURCE|a.NO_FIELDS),o=a.materialize(a.SOURCE).source,u=e.field||n.identity,s=c().smooth(!1!==e.smooth),l=e.thresholds||function(e,t,n){const a=h(n.levels||10,n.nice,!1!==n.zero);return"shared"!==n.resolve?a:a(e.map(e=>r.max(t(e).values)))}(o,u,e),f=null===e.as?null:e.as||"contour",d=[];return o.forEach(r=>{const a=u(r),i=s.size([a.width,a.height])(a.values,n.isArray(l)?l:l(a.values));!function(e,t,r,a){let i=a.scale||t.scale,o=a.translate||t.translate;n.isFunction(i)&&(i=i(r,a));n.isFunction(o)&&(o=o(r,a));if((1===i||null==i)&&!o)return;const u=(n.isNumber(i)?i:i[0])||1,s=(n.isNumber(i)?i:i[1])||1,l=o&&o[0]||0,f=o&&o[1]||0;e.forEach(g(t,u,s,l,f))}(i,a,r,e),i.forEach(e=>{d.push(t.rederive(r,t.ingest(null!=f?{[f]:e}:e)))})}),this.value&&(i.rem=this.value),this.value=i.source=i.add=d,i},z.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};var S=n.inherits(z,t.Transform);const R=["x","y","weight","size","cellSize","bandwidth"];function w(e,t){return R.forEach(n=>null!=t[n]?e[n](t[n]):0),e}function j(e){t.Transform.call(this,null,e)}S.transform=function(e,r){if(this.value&&!r.changed()&&!e.modified())return r.StopPropagation;var a,i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=function(e,t){var n,r,a,i,o,u,s=[],l=e=>e(i);if(null==t)s.push(e);else for(n={},r=0,a=e.length;r<a;++r)i=e[r],o=t.map(l),(u=n[o])||(n[o]=u=[],u.dims=o,s.push(u)),u.push(i);return s}(r.materialize(r.SOURCE).source,e.groupby),u=(e.groupby||[]).map(n.accessorName),s=w(x(),e),l=e.as||"grid";return a=o.map(n=>t.ingest(function(e,t){for(let n=0;n<u.length;++n)e[u[n]]=t[n];return e}({[l]:s(n,e.counts)},n.dims))),this.value&&(i.rem=this.value),this.value=i.source=i.add=a,i},j.Definition={type:"Contour",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"values",type:"number",array:!0},{name:"x",type:"field"},{name:"y",type:"field"},{name:"weight",type:"field"},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"count",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"thresholds",type:"number",array:!0},{name:"smooth",type:"boolean",default:!0}]},n.inherits(j,t.Transform).transform=function(e,r){if(this.value&&!r.changed()&&!e.modified())return r.StopPropagation;var a,i,o=r.fork(r.NO_SOURCE|r.NO_FIELDS),u=c().smooth(!1!==e.smooth),s=e.values,l=e.thresholds||h(e.count||10,e.nice,!!s),f=e.size;return s||(s=r.materialize(r.SOURCE).source,i=g(a=w(x(),e)(s,!0),a.scale||1,a.scale||1,0,0),f=[a.width,a.height],s=a.values),l=n.isArray(l)?l:l(s),s=u.size(f)(s,l),i&&s.forEach(i),this.value&&(o.rem=this.value),this.value=o.source=o.add=(s||[]).map(t.ingest),o};function F(e){t.Transform.call(this,null,e)}function O(e){t.Transform.call(this,null,e)}function M(e){t.Transform.call(this,null,e)}function T(e){t.Transform.call(this,null,e)}function C(e){t.Transform.call(this,[],e),this.generator=o.geoGraticule()}function _(e){t.Transform.call(this,null,e)}function q(e){if(!n.isFunction(e))return!1;const t=n.toSet(n.accessorFields(e));return t.$x||t.$y||t.$value||t.$max}function P(e){t.Transform.call(this,null,e),this.modified(!0)}function A(e,t,r){n.isFunction(e[t])&&e[t](r)}F.Definition={type:"GeoJSON",metadata:{},params:[{name:"fields",type:"field",array:!0,length:2},{name:"geojson",type:"field"}]},n.inherits(F,t.Transform).transform=function(e,t){var r,a=this._features,i=this._points,o=e.fields,u=o&&o[0],s=o&&o[1],l=e.geojson||!o&&n.identity,f=t.ADD;r=e.modified()||t.changed(t.REM)||t.modified(n.accessorFields(l))||u&&t.modified(n.accessorFields(u))||s&&t.modified(n.accessorFields(s)),this.value&&!r||(f=t.SOURCE,this._features=a=[],this._points=i=[]),l&&t.visit(f,(function(e){a.push(l(e))})),u&&s&&(t.visit(f,(function(e){var t=u(e),n=s(e);null!=t&&null!=n&&(t=+t)===t&&(n=+n)===n&&i.push([t,n])})),a=a.concat({type:"Feature",geometry:{type:"MultiPoint",coordinates:i}})),this.value={type:"FeatureCollection",features:a}},O.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]},n.inherits(O,t.Transform).transform=function(e,t){var r=t.fork(t.ALL),a=this.value,o=e.field||n.identity,u=e.as||"path",s=r.SOURCE;!a||e.modified()?(this.value=a=i.getProjectionPath(e.projection),r.materialize().reflow()):s=o===n.identity||t.modified(o.fields)?r.ADD_MOD:r.ADD;var l=function(e,t){var n=e.pointRadius();e.context(null),null!=t&&e.pointRadius(t);return n}(a,e.pointRadius);return r.visit(s,(function(e){e[u]=a(o(e))})),a.pointRadius(l),r.modifies(u)},M.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]},n.inherits(M,t.Transform).transform=function(e,t){var n,r=e.projection,a=e.fields[0],i=e.fields[1],o=e.as||["x","y"],u=o[0],s=o[1];function l(e){var t=r([a(e),i(e)]);t?(e[u]=t[0],e[s]=t[1]):(e[u]=void 0,e[s]=void 0)}return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,l):(n=t.modified(a.fields)||t.modified(i.fields),t.visit(n?t.ADD_MOD:t.ADD,l)),t.modifies(o)},T.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]},n.inherits(T,t.Transform).transform=function(e,t){var r=t.fork(t.ALL),a=this.value,o=e.as||"shape",u=r.ADD;return a&&!e.modified()||(this.value=a=function(e,t,n){var r=null==n?function(n){return e(t(n))}:function(r){var a=e.pointRadius(),i=e.pointRadius(n)(t(r));return e.pointRadius(a),i};return r.context=function(t){return e.context(t),r},r}(i.getProjectionPath(e.projection),e.field||n.field("datum"),e.pointRadius),r.materialize().reflow(),u=r.SOURCE),r.visit(u,(function(e){e[o]=a})),r.modifies(o)},C.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]},n.inherits(C,t.Transform).transform=function(e,r){var a,i=this.value,o=this.generator;if(!i.length||e.modified())for(var u in e)n.isFunction(o[u])&&o[u](e[u]);return a=o(),i.length?r.mod.push(t.replace(i[0],a)):r.add.push(t.ingest(a)),i[0]=a,r},_.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]},n.inherits(_,t.Transform).transform=function(e,t){if(!t.changed()&&!e.modified())return t.StopPropagation;var a=t.materialize(t.SOURCE).source,i="shared"===e.resolve,o=e.field||n.identity,l=function(e,t){let r;n.isFunction(e)?(r=n=>e(n,t),r.dep=q(e)):e?r=n.constant(e):(r=e=>e.$value/e.$max||0,r.dep=!0);return r}(e.opacity,e),f=function(e,t){let r;n.isFunction(e)?(r=n=>u.rgb(e(n,t)),r.dep=q(e)):r=n.constant(u.rgb(e||"#888"));return r}(e.color,e),c=e.as||"image",d={$x:0,$y:0,$value:0,$max:i?r.max(a.map(e=>r.max(o(e).values))):0};return a.forEach(e=>{const t=o(e),a=n.extend({},e,d);i||(a.$max=r.max(t.values||[])),e[c]=function(e,t,r,a){const i=e.width,o=e.height,u=e.x1||0,l=e.y1||0,f=e.x2||i,c=e.y2||o,d=e.values,m=d?e=>d[e]:n.zero,p=s.canvas(f-u,c-l),h=p.getContext("2d"),y=h.getImageData(0,0,f-u,c-l),g=y.data;for(let e=l,n=0;e<c;++e){t.$y=e-l;for(let o=u,s=e*i;o<f;++o,n+=4){t.$x=o-u,t.$value=m(o+s);const e=r(t);g[n+0]=e.r,g[n+1]=e.g,g[n+2]=e.b,g[n+3]=~~(255*a(t))}}return h.putImageData(y,0,0),p}(t,a,f.dep?f:n.constant(f(a)),l.dep?l:n.constant(l(a)))}),t.reflow(!0).modifies(c)},n.inherits(P,t.Transform).transform=function(e,t){var r=this.value;return!r||e.modified("type")?(this.value=r=function(e){var t=i.projection((e||"mercator").toLowerCase());t||n.error("Unrecognized projection type: "+e);return t()}(e.type),i.projectionProperties.forEach((function(t){null!=e[t]&&A(r,t,e[t])}))):i.projectionProperties.forEach((function(t){e.modified(t)&&A(r,t,e[t])})),null!=e.pointRadius&&r.path.pointRadius(e.pointRadius),e.fit&&function(e,t){var r=function(e){return 1===(e=n.array(e)).length?e[0]:{type:"FeatureCollection",features:e.reduce((e,t)=>e.concat(function(e){return"FeatureCollection"===e.type?e.features:n.array(e).filter(e=>null!=e).map(e=>"Feature"===e.type?e:{type:"Feature",geometry:e})}(t)),[])}}(t.fit);t.extent?e.fitExtent(t.extent,r):t.size&&e.fitSize(t.size,r)}(r,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)},e.contour=j,e.geojson=F,e.geopath=O,e.geopoint=M,e.geoshape=T,e.graticule=C,e.heatmap=_,e.isocontour=y,e.kde2d=z,e.projection=P,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util"),require("d3-array"),require("vega-statistics"),require("vega-projection"),require("d3-geo"),require("d3-color"),require("vega-canvas")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-array","vega-statistics","vega-projection","d3-geo","d3-color","vega-canvas"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.d3,e.vega,e.vega,e.d3,e.d3,e.vega)}(this,(function(e,t,n,r,a,i,o,u,s){"use strict";function l(){}const f=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function c(){var e=1,t=1,r=u;function a(e,t){return t.map(t=>i(e,t))}function i(n,a){var i=[],u=[];return function(n,r,a){var i,u,s,l,c,d,m=new Array,p=new Array;i=u=-1,l=n[0]>=r,f[l<<1].forEach(h);for(;++i<e-1;)s=l,l=n[i+1]>=r,f[s|l<<1].forEach(h);f[l<<0].forEach(h);for(;++u<t-1;){for(i=-1,l=n[u*e+e]>=r,c=n[u*e]>=r,f[l<<1|c<<2].forEach(h);++i<e-1;)s=l,l=n[u*e+e+i+1]>=r,d=c,c=n[u*e+i+1]>=r,f[s|l<<1|c<<2|d<<3].forEach(h);f[l|c<<3].forEach(h)}i=-1,c=n[u*e]>=r,f[c<<2].forEach(h);for(;++i<e-1;)d=c,c=n[u*e+i+1]>=r,f[c<<2|d<<3].forEach(h);function h(e){var t,n,r=[e[0][0]+i,e[0][1]+u],s=[e[1][0]+i,e[1][1]+u],l=o(r),f=o(s);(t=p[l])?(n=m[f])?(delete p[t.end],delete m[n.start],t===n?(t.ring.push(s),a(t.ring)):m[t.start]=p[n.end]={start:t.start,end:n.end,ring:t.ring.concat(n.ring)}):(delete p[t.end],t.ring.push(s),p[t.end=f]=t):(t=m[f])?(n=p[l])?(delete m[t.start],delete p[n.end],t===n?(t.ring.push(s),a(t.ring)):m[n.start]=p[t.end]={start:n.start,end:t.end,ring:n.ring.concat(t.ring)}):(delete m[t.start],t.ring.unshift(r),m[t.start=l]=t):m[l]=p[f]={start:l,end:f,ring:[r,s]}}f[c<<3].forEach(h)}(n,a,(function(e){r(e,n,a),function(e){var t=0,n=e.length,r=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];for(;++t<n;)r+=e[t-1][1]*e[t][0]-e[t-1][0]*e[t][1];return r}(e)>0?i.push([e]):u.push(e)})),u.forEach((function(e){for(var t,n=0,r=i.length;n<r;++n)if(-1!==d((t=i[n])[0],e))return void t.push(e)})),{type:"MultiPolygon",value:a,coordinates:i}}function o(t){return 2*t[0]+t[1]*(e+1)*4}function u(n,r,a){n.forEach((function(n){var i,o=n[0],u=n[1],s=0|o,l=0|u,f=r[l*e+s];o>0&&o<e&&s===o&&(i=r[l*e+s-1],n[0]=o+(a-i)/(f-i)-.5),u>0&&u<t&&l===u&&(i=r[(l-1)*e+s],n[1]=u+(a-i)/(f-i)-.5)}))}return a.contour=i,a.size=function(r){if(!arguments.length)return[e,t];var i=Math.floor(r[0]),o=Math.floor(r[1]);return i>=0&&o>=0||n.error("invalid size"),e=i,t=o,a},a.smooth=function(e){return arguments.length?(r=e?u:l,a):r===u},a}function d(e,t){for(var n,r=-1,a=t.length;++r<a;)if(n=m(e,t[r]))return n;return 0}function m(e,t){for(var n=t[0],r=t[1],a=-1,i=0,o=e.length,u=o-1;i<o;u=i++){var s=e[i],l=s[0],f=s[1],c=e[u],d=c[0],m=c[1];if(p(s,c,t))return 0;f>r!=m>r&&n<(d-l)*(r-f)/(m-f)+l&&(a=-a)}return a}function p(e,t,n){var r,a,i,o;return function(e,t,n){return(t[0]-e[0])*(n[1]-e[1])==(n[0]-e[0])*(t[1]-e[1])}(e,t,n)&&(a=e[r=+(e[0]===t[0])],i=n[r],o=t[r],a<=i&&i<=o||o<=i&&i<=a)}function h(e,t,a){return function(i){var o=n.extent(i),u=a?Math.min(o[0],0):o[0],s=o[1],l=s-u,f=t?r.tickStep(u,s,e):l/(e+1);return r.range(f,s,f)}}function y(e){t.Transform.call(this,null,e)}function g(e,t,n,r,a){const i=e.x1||0,o=e.y1||0,u=t*n<0;function s(e){e.forEach(l)}function l(e){u&&e.reverse(),e.forEach(f)}function f(e){e[0]=(e[0]-i)*t+r,e[1]=(e[1]-o)*n+a}return function(e){return e.coordinates.forEach(s),e}}function v(e,t,n){const r=e>=0?e:a.bandwidthNRD(t,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2)}function b(e){return n.isFunction(e)?e:n.constant(+e)}function x(){var e=e=>e[0],t=e=>e[1],a=n.one,i=[-1,-1],o=960,u=500,s=2;function l(n,l){const f=v(i[0],n,e)>>s,c=v(i[1],n,t)>>s,d=f?f+2:0,m=c?c+2:0,p=2*d+(o>>s),h=2*m+(u>>s),y=new Float32Array(p*h),g=new Float32Array(p*h);let b=y;n.forEach(n=>{const r=d+(+e(n)>>s),i=m+(+t(n)>>s);r>=0&&r<p&&i>=0&&i<h&&(y[r+i*p]+=+a(n))}),f>0&&c>0?(E(p,h,y,g,f),D(p,h,g,y,c),E(p,h,y,g,f),D(p,h,g,y,c),E(p,h,y,g,f),D(p,h,g,y,c)):f>0?(E(p,h,y,g,f),E(p,h,g,y,f),E(p,h,y,g,f),b=g):c>0&&(D(p,h,y,g,c),D(p,h,g,y,c),D(p,h,y,g,c),b=g);let x=l?Math.pow(2,-2*s):1/r.sum(b);for(let e=0,t=p*h;e<t;++e)b[e]*=x;return{values:b,scale:1<<s,width:p,height:h,x1:d,y1:m,x2:d+(o>>s),y2:m+(u>>s)}}return l.x=function(t){return arguments.length?(e=b(t),l):e},l.y=function(e){return arguments.length?(t=b(e),l):t},l.weight=function(e){return arguments.length?(a=b(e),l):a},l.size=function(e){if(!arguments.length)return[o,u];var t=+e[0],r=+e[1];return t>=0&&r>=0||n.error("invalid size"),o=t,u=r,l},l.cellSize=function(e){return arguments.length?((e=+e)>=1||n.error("invalid cell size"),s=Math.floor(Math.log(e)/Math.LN2),l):1<<s},l.bandwidth=function(e){return arguments.length?(1===(e=n.array(e)).length&&(e=[+e[0],+e[0]]),2!==e.length&&n.error("invalid bandwidth"),i=e,l):i},l}function E(e,t,n,r,a){const i=1+(a<<1);for(let o=0;o<t;++o)for(let t=0,u=0;t<e+a;++t)t<e&&(u+=n[t+o*e]),t>=a&&(t>=i&&(u-=n[t-i+o*e]),r[t-a+o*e]=u/Math.min(t+1,e-1+i-t,i))}function D(e,t,n,r,a){const i=1+(a<<1);for(let o=0;o<e;++o)for(let u=0,s=0;u<t+a;++u)u<t&&(s+=n[o+u*e]),u>=a&&(u>=i&&(s-=n[o+(u-i)*e]),r[o+(u-a)*e]=s/Math.min(u+1,t-1+i-u,i))}function z(e){t.Transform.call(this,null,e)}y.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]},n.inherits(y,t.Transform).transform=function(e,a){if(this.value&&!a.changed()&&!e.modified())return a.StopPropagation;var i=a.fork(a.NO_SOURCE|a.NO_FIELDS),o=a.materialize(a.SOURCE).source,u=e.field||n.identity,s=c().smooth(!1!==e.smooth),l=e.thresholds||function(e,t,n){const a=h(n.levels||10,n.nice,!1!==n.zero);return"shared"!==n.resolve?a:a(e.map(e=>r.max(t(e).values)))}(o,u,e),f=null===e.as?null:e.as||"contour",d=[];return o.forEach(r=>{const a=u(r),i=s.size([a.width,a.height])(a.values,n.isArray(l)?l:l(a.values));!function(e,t,r,a){let i=a.scale||t.scale,o=a.translate||t.translate;n.isFunction(i)&&(i=i(r,a));n.isFunction(o)&&(o=o(r,a));if((1===i||null==i)&&!o)return;const u=(n.isNumber(i)?i:i[0])||1,s=(n.isNumber(i)?i:i[1])||1,l=o&&o[0]||0,f=o&&o[1]||0;e.forEach(g(t,u,s,l,f))}(i,a,r,e),i.forEach(e=>{d.push(t.rederive(r,t.ingest(null!=f?{[f]:e}:e)))})}),this.value&&(i.rem=this.value),this.value=i.source=i.add=d,i},z.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};var S=n.inherits(z,t.Transform);const R=["x","y","weight","size","cellSize","bandwidth"];function w(e,t){return R.forEach(n=>null!=t[n]?e[n](t[n]):0),e}function j(e){t.Transform.call(this,null,e)}S.transform=function(e,r){if(this.value&&!r.changed()&&!e.modified())return r.StopPropagation;var a,i=r.fork(r.NO_SOURCE|r.NO_FIELDS),o=function(e,t){var n,r,a,i,o,u,s=[],l=e=>e(i);if(null==t)s.push(e);else for(n={},r=0,a=e.length;r<a;++r)i=e[r],o=t.map(l),(u=n[o])||(n[o]=u=[],u.dims=o,s.push(u)),u.push(i);return s}(r.materialize(r.SOURCE).source,e.groupby),u=(e.groupby||[]).map(n.accessorName),s=w(x(),e),l=e.as||"grid";return a=o.map(n=>t.ingest(function(e,t){for(let n=0;n<u.length;++n)e[u[n]]=t[n];return e}({[l]:s(n,e.counts)},n.dims))),this.value&&(i.rem=this.value),this.value=i.source=i.add=a,i},j.Definition={type:"Contour",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"values",type:"number",array:!0},{name:"x",type:"field"},{name:"y",type:"field"},{name:"weight",type:"field"},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"count",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"thresholds",type:"number",array:!0},{name:"smooth",type:"boolean",default:!0}]},n.inherits(j,t.Transform).transform=function(e,r){if(this.value&&!r.changed()&&!e.modified())return r.StopPropagation;var a,i,o=r.fork(r.NO_SOURCE|r.NO_FIELDS),u=c().smooth(!1!==e.smooth),s=e.values,l=e.thresholds||h(e.count||10,e.nice,!!s),f=e.size;return s||(s=r.materialize(r.SOURCE).source,i=g(a=w(x(),e)(s,!0),a.scale||1,a.scale||1,0,0),f=[a.width,a.height],s=a.values),l=n.isArray(l)?l:l(s),s=u.size(f)(s,l),i&&s.forEach(i),this.value&&(o.rem=this.value),this.value=o.source=o.add=(s||[]).map(t.ingest),o};function F(e){t.Transform.call(this,null,e)}function O(e){t.Transform.call(this,null,e)}function M(e){t.Transform.call(this,null,e)}function T(e){t.Transform.call(this,null,e)}function C(e){t.Transform.call(this,[],e),this.generator=o.geoGraticule()}function _(e){t.Transform.call(this,null,e)}function q(e){if(!n.isFunction(e))return!1;const t=n.toSet(n.accessorFields(e));return t.$x||t.$y||t.$value||t.$max}function P(e){t.Transform.call(this,null,e),this.modified(!0)}function A(e,t,r){n.isFunction(e[t])&&e[t](r)}F.Definition={type:"GeoJSON",metadata:{},params:[{name:"fields",type:"field",array:!0,length:2},{name:"geojson",type:"field"}]},n.inherits(F,t.Transform).transform=function(e,t){var r,a=this._features,i=this._points,o=e.fields,u=o&&o[0],s=o&&o[1],l=e.geojson||!o&&n.identity,f=t.ADD;r=e.modified()||t.changed(t.REM)||t.modified(n.accessorFields(l))||u&&t.modified(n.accessorFields(u))||s&&t.modified(n.accessorFields(s)),this.value&&!r||(f=t.SOURCE,this._features=a=[],this._points=i=[]),l&&t.visit(f,(function(e){a.push(l(e))})),u&&s&&(t.visit(f,(function(e){var t=u(e),n=s(e);null!=t&&null!=n&&(t=+t)===t&&(n=+n)===n&&i.push([t,n])})),a=a.concat({type:"Feature",geometry:{type:"MultiPoint",coordinates:i}})),this.value={type:"FeatureCollection",features:a}},O.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]},n.inherits(O,t.Transform).transform=function(e,t){var r=t.fork(t.ALL),a=this.value,o=e.field||n.identity,u=e.as||"path",s=r.SOURCE;!a||e.modified()?(this.value=a=i.getProjectionPath(e.projection),r.materialize().reflow()):s=o===n.identity||t.modified(o.fields)?r.ADD_MOD:r.ADD;var l=function(e,t){var n=e.pointRadius();e.context(null),null!=t&&e.pointRadius(t);return n}(a,e.pointRadius);return r.visit(s,(function(e){e[u]=a(o(e))})),a.pointRadius(l),r.modifies(u)},M.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]},n.inherits(M,t.Transform).transform=function(e,t){var n,r=e.projection,a=e.fields[0],i=e.fields[1],o=e.as||["x","y"],u=o[0],s=o[1];function l(e){var t=r([a(e),i(e)]);t?(e[u]=t[0],e[s]=t[1]):(e[u]=void 0,e[s]=void 0)}return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,l):(n=t.modified(a.fields)||t.modified(i.fields),t.visit(n?t.ADD_MOD:t.ADD,l)),t.modifies(o)},T.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]},n.inherits(T,t.Transform).transform=function(e,t){var r=t.fork(t.ALL),a=this.value,o=e.as||"shape",u=r.ADD;return a&&!e.modified()||(this.value=a=function(e,t,n){var r=null==n?function(n){return e(t(n))}:function(r){var a=e.pointRadius(),i=e.pointRadius(n)(t(r));return e.pointRadius(a),i};return r.context=function(t){return e.context(t),r},r}(i.getProjectionPath(e.projection),e.field||n.field("datum"),e.pointRadius),r.materialize().reflow(),u=r.SOURCE),r.visit(u,(function(e){e[o]=a})),r.modifies(o)},C.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]},n.inherits(C,t.Transform).transform=function(e,r){var a,i=this.value,o=this.generator;if(!i.length||e.modified())for(var u in e)n.isFunction(o[u])&&o[u](e[u]);return a=o(),i.length?r.mod.push(t.replace(i[0],a)):r.add.push(t.ingest(a)),i[0]=a,r},_.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]},n.inherits(_,t.Transform).transform=function(e,t){if(!t.changed()&&!e.modified())return t.StopPropagation;var a=t.materialize(t.SOURCE).source,i="shared"===e.resolve,o=e.field||n.identity,l=function(e,t){let r;n.isFunction(e)?(r=n=>e(n,t),r.dep=q(e)):e?r=n.constant(e):(r=e=>e.$value/e.$max||0,r.dep=!0);return r}(e.opacity,e),f=function(e,t){let r;n.isFunction(e)?(r=n=>u.rgb(e(n,t)),r.dep=q(e)):r=n.constant(u.rgb(e||"#888"));return r}(e.color,e),c=e.as||"image",d={$x:0,$y:0,$value:0,$max:i?r.max(a.map(e=>r.max(o(e).values))):0};return a.forEach(e=>{const t=o(e),a=n.extend({},e,d);i||(a.$max=r.max(t.values||[])),e[c]=function(e,t,r,a){const i=e.width,o=e.height,u=e.x1||0,l=e.y1||0,f=e.x2||i,c=e.y2||o,d=e.values,m=d?e=>d[e]:n.zero,p=s.canvas(f-u,c-l),h=p.getContext("2d"),y=h.getImageData(0,0,f-u,c-l),g=y.data;for(let e=l,n=0;e<c;++e){t.$y=e-l;for(let o=u,s=e*i;o<f;++o,n+=4){t.$x=o-u,t.$value=m(o+s);const e=r(t);g[n+0]=e.r,g[n+1]=e.g,g[n+2]=e.b,g[n+3]=~~(255*a(t))}}return h.putImageData(y,0,0),p}(t,a,f.dep?f:n.constant(f(a)),l.dep?l:n.constant(l(a)))}),t.reflow(!0).modifies(c)},n.inherits(P,t.Transform).transform=function(e,t){var r=this.value;return!r||e.modified("type")?(this.value=r=function(e){var t=i.projection((e||"mercator").toLowerCase());t||n.error("Unrecognized projection type: "+e);return t()}(e.type),i.projectionProperties.forEach((function(t){null!=e[t]&&A(r,t,e[t])}))):i.projectionProperties.forEach((function(t){e.modified(t)&&A(r,t,e[t])})),null!=e.pointRadius&&r.path.pointRadius(e.pointRadius),e.fit&&function(e,t){var r=function(e){return 1===(e=n.array(e)).length?e[0]:{type:"FeatureCollection",features:e.reduce((e,t)=>e.concat(function(e){return"FeatureCollection"===e.type?e.features:n.array(e).filter(e=>null!=e).map(e=>"Feature"===e.type?e:{type:"Feature",geometry:e})}(t)),[])}}(t.fit);t.extent?e.fitExtent(t.extent,r):t.size&&e.fitSize(t.size,r)}(r,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)},e.contour=j,e.geojson=F,e.geopath=O,e.geopoint=M,e.geoshape=T,e.graticule=C,e.heatmap=_,e.isocontour=y,e.kde2d=z,e.projection=P,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "vega-geo", | ||
"version": "4.3.1", | ||
"version": "4.3.2", | ||
"description": "Geographic data transforms for Vega dataflows.", | ||
@@ -31,6 +31,6 @@ "keywords": [ | ||
"vega-canvas": "^1.2.2", | ||
"vega-dataflow": "^5.5.1", | ||
"vega-dataflow": "^5.6.0", | ||
"vega-projection": "^1.4.1", | ||
"vega-statistics": "^1.7.4", | ||
"vega-util": "^1.13.2" | ||
"vega-statistics": "^1.7.5", | ||
"vega-util": "^1.14.0" | ||
}, | ||
@@ -40,3 +40,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "35e31c5c6b54db9dc3a577b5adad8d15ec274d32" | ||
"gitHead": "48c85218f2202242171aa569f2dca0f53cf2b51f" | ||
} |
@@ -172,4 +172,4 @@ import {error} from 'vega-util'; | ||
if (!arguments.length) return [dx, dy]; | ||
var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]); | ||
if (!(_0 > 0) || !(_1 > 0)) error('invalid size'); | ||
var _0 = Math.floor(_[0]), _1 = Math.floor(_[1]); | ||
if (!(_0 >= 0 && _1 >= 0)) error('invalid size'); | ||
return dx = _0, dy = _1, contours; | ||
@@ -176,0 +176,0 @@ }; |
@@ -95,4 +95,4 @@ import {bandwidthNRD} from 'vega-statistics'; | ||
if (!arguments.length) return [dx, dy]; | ||
var _0 = Math.ceil(_[0]), _1 = Math.ceil(_[1]); | ||
if (!(_0 >= 0) && !(_1 >= 0)) error('invalid size'); | ||
var _0 = +_[0], _1 = +_[1]; | ||
if (!(_0 >= 0 && _1 >= 0)) error('invalid size'); | ||
return dx = _0, dy = _1, density; | ||
@@ -99,0 +99,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
103618
Updatedvega-dataflow@^5.6.0
Updatedvega-statistics@^1.7.5
Updatedvega-util@^1.14.0