Comparing version 2.1.1 to 2.2.0
@@ -39,3 +39,3 @@ (function (global, factory) { | ||
"type": "Contour", | ||
"metadata": {"generates": true, "source": true}, | ||
"metadata": {"generates": true}, | ||
"params": [ | ||
@@ -83,3 +83,4 @@ { "name": "size", "type": "number", "array": true, "length": 2, "required": true }, | ||
if (this.value) out.rem = this.value; | ||
this.value = out.source = out.add = contour(values).map(vegaDataflow.ingest); | ||
values = values && values.length ? contour(values).map(vegaDataflow.ingest) : []; | ||
this.value = out.source = out.add = values; | ||
@@ -201,2 +202,3 @@ return out; | ||
{ "name": "field", "type": "field" }, | ||
{ "name": "pointRadius", "type": "number", "expr": true }, | ||
{ "name": "as", "type": "string", "default": "path" } | ||
@@ -213,3 +215,3 @@ ] | ||
as = _.as || 'path', | ||
mod; | ||
flag = out.SOURCE; | ||
@@ -220,13 +222,26 @@ function set(t) { t[as] = path(field$$1(t)); } | ||
// parameters updated, reset and reflow | ||
this.value = path = vegaProjection.getProjectionPath(_.projection).context(null); | ||
out.materialize().reflow().visit(out.SOURCE, set); | ||
this.value = path = vegaProjection.getProjectionPath(_.projection); | ||
out.materialize().reflow(); | ||
} else { | ||
path.context(null); | ||
mod = field$$1 === vegaUtil.identity || pulse.modified(field$$1.fields); | ||
out.visit(mod ? out.ADD_MOD : out.ADD, set); | ||
flag = field$$1 === vegaUtil.identity || pulse.modified(field$$1.fields) | ||
? out.ADD_MOD | ||
: out.ADD; | ||
} | ||
var prev = initPath(path, _.pointRadius); | ||
out.visit(flag, set); | ||
path.pointRadius(prev); | ||
return out.modifies(as); | ||
}; | ||
function initPath(path, pointRadius) { | ||
var prev = path.pointRadius(); | ||
path.context(null); | ||
if (pointRadius != null) { | ||
path.pointRadius(pointRadius); | ||
} | ||
return prev; | ||
} | ||
/** | ||
@@ -311,2 +326,3 @@ * Geo-code a longitude/latitude point to an x/y coordinate. | ||
{ "name": "field", "type": "field", "default": "datum" }, | ||
{ "name": "pointRadius", "type": "number", "expr": true }, | ||
{ "name": "as", "type": "string", "default": "shape" } | ||
@@ -328,3 +344,6 @@ ] | ||
this.value = shape = shapeGenerator( | ||
vegaProjection.getProjectionPath(_.projection), datum); | ||
vegaProjection.getProjectionPath(_.projection), | ||
datum, | ||
_.pointRadius | ||
); | ||
out.materialize().reflow(); | ||
@@ -339,6 +358,11 @@ flag = out.SOURCE; | ||
function shapeGenerator(path, field$$1) { | ||
var shape = function(_) { | ||
return path(field$$1(_)); | ||
}; | ||
function shapeGenerator(path, field$$1, pointRadius) { | ||
var shape = pointRadius == null | ||
? function(_) { return path(field$$1(_)); } | ||
: function(_) { | ||
var prev = path.pointRadius(), | ||
value = path.pointRadius(pointRadius)(field$$1(_)); | ||
path.pointRadius(prev); | ||
return value; | ||
}; | ||
shape.context = function(_) { | ||
@@ -345,0 +369,0 @@ path.context(_); |
@@ -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("d3-contour"),require("vega-projection"),require("d3-geo")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-array","d3-contour","vega-projection","d3-geo"],t):t((e.vega=e.vega||{},e.vega.transforms=e.vega.transforms||{}),e.vega,e.vega,e.d3,e.d3,e.vega,e.d3)}(this,function(e,t,n,r,i,a,o){"use strict";function s(e){t.Transform.call(this,null,e)}function u(e){return function(t){for(var n=r.extent(t),i=n[0],a=n[1]-i,o=[],s=1;s<=e;++s)o.push(i+a*s/(e+1));return o}}function f(e){t.Transform.call(this,null,e)}function l(e){t.Transform.call(this,null,e)}function d(e){t.Transform.call(this,null,e)}function c(e){t.Transform.call(this,null,e)}function m(e,t){var n=function(n){return e(t(n))};return n.context=function(t){return e.context(t),n},n}function p(e){t.Transform.call(this,[],e),this.generator=o.geoGraticule()}function h(e){t.Transform.call(this,null,e),this.modified(!0)}function y(e,t){var n=j(t.fit);t.extent?e.fitExtent(t.extent,n):t.size&&e.fitSize(t.size,n)}function g(e){var t=a.projection((e||"mercator").toLowerCase());return t||n.error("Unrecognized projection type: "+e),t()}function v(e,t,r){n.isFunction(e[t])&&e[t](r)}function j(e){return 1===(e=n.array(e)).length?e[0]:{type:x,features:e.reduce(function(e,t){return t&&t.type===x?e.push.apply(e,t.features):n.isArray(t)?e.push.apply(e,t):e.push(t),e},[])}}var D=["values","size"],b=["x","y","size","cellSize","bandwidth"];s.Definition={type:"Contour",metadata:{generates:!0,source:!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:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"count",type:"number"},{name:"nice",type:"number",default:!1},{name:"thresholds",type:"number",array:!0}]},n.inherits(s,t.Transform).transform=function(e,n){if(this.value&&!n.changed()&&!e.modified())return n.StopPropagation;var r,a,o,s=n.fork(n.NO_SOURCE|n.NO_FIELDS),f=e.count||10;return e.values?(r=i.contours(),a=D,o=e.values):(r=i.contourDensity(),a=b,o=n.materialize(n.SOURCE).source),r.thresholds(e.thresholds||(e.nice?f:u(f))),a.forEach(function(t){null!=e[t]&&r[t](e[t])}),this.value&&(s.rem=this.value),this.value=s.source=s.add=r(o).map(t.ingest),s};var x="FeatureCollection";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,i=this._features,a=this._points,o=e.fields,s=o&&o[0],u=o&&o[1],f=e.geojson,l=t.ADD;r=e.modified()||t.changed(t.REM)||t.modified(n.accessorFields(f))||s&&t.modified(n.accessorFields(s))||u&&t.modified(n.accessorFields(u)),this.value&&!r||(l=t.SOURCE,this._features=i=[],this._points=a=[]),f&&t.visit(l,function(e){i.push(f(e))}),s&&u&&(t.visit(l,function(e){var t=s(e),n=u(e);null!=t&&null!=n&&(t=+t)===t&&(n=+n)===n&&a.push([t,n])}),i=i.concat({type:"Feature",geometry:{type:"MultiPoint",coordinates:a}})),this.value={type:x,features:i}},l.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"as",type:"string",default:"path"}]},n.inherits(l,t.Transform).transform=function(e,t){function r(e){e[f]=s(u(e))}var i,o=t.fork(t.ALL),s=this.value,u=e.field||n.identity,f=e.as||"path";return!s||e.modified()?(this.value=s=a.getProjectionPath(e.projection).context(null),o.materialize().reflow().visit(o.SOURCE,r)):(s.context(null),i=u===n.identity||t.modified(u.fields),o.visit(i?o.ADD_MOD:o.ADD,r)),o.modifies(f)},d.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(d,t.Transform).transform=function(e,t){function n(e){var t=i([a(e),o(e)]);t?(e[u]=t[0],e[f]=t[1]):(e[u]=void 0,e[f]=void 0)}var r,i=e.projection,a=e.fields[0],o=e.fields[1],s=e.as||["x","y"],u=s[0],f=s[1];return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,n):(r=t.modified(a.fields)||t.modified(o.fields),t.visit(r?t.ADD_MOD:t.ADD,n)),t.modifies(s)},c.Definition={type:"GeoShape",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"as",type:"string",default:"shape"}]},n.inherits(c,t.Transform).transform=function(e,t){var r=t.fork(t.ALL),i=this.value,o=e.field||n.field("datum"),s=e.as||"shape",u=r.ADD_MOD;return i&&!e.modified()||(this.value=i=m(a.getProjectionPath(e.projection),o),r.materialize().reflow(),u=r.SOURCE),r.visit(u,function(e){e[s]=i}),r.modifies(s)},p.Definition={type:"Graticule",metadata:{source:!0,generates:!0,changes:!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(p,t.Transform).transform=function(e,r){var i,a=r.fork(),o=this.value,s=this.generator;if(!o.length||e.modified())for(var u in e)n.isFunction(s[u])&&s[u](e[u]);return i=s(),o.length?a.mod.push(t.replace(o[0],i)):a.add.push(t.ingest(i)),o[0]=i,a.source=o,a},n.inherits(h,t.Transform).transform=function(e,t){var n=this.value;return!n||e.modified("type")?(this.value=n=g(e.type),a.projectionProperties.forEach(function(t){null!=e[t]&&v(n,t,e[t])})):a.projectionProperties.forEach(function(t){e.modified(t)&&v(n,t,e[t])}),null!=e.pointRadius&&n.path.pointRadius(e.pointRadius),e.fit&&y(n,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)},e.contour=s,e.geojson=f,e.geopath=l,e.geopoint=d,e.geoshape=c,e.graticule=p,e.projection=h,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("d3-contour"),require("vega-projection"),require("d3-geo")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-array","d3-contour","vega-projection","d3-geo"],t):t((e.vega=e.vega||{},e.vega.transforms=e.vega.transforms||{}),e.vega,e.vega,e.d3,e.d3,e.vega,e.d3)}(this,function(e,t,n,i,r,a,o){"use strict";function s(e){t.Transform.call(this,null,e)}function u(e){return function(t){for(var n=i.extent(t),r=n[0],a=n[1]-r,o=[],s=1;s<=e;++s)o.push(r+a*s/(e+1));return o}}function f(e){t.Transform.call(this,null,e)}function l(e){t.Transform.call(this,null,e)}function d(e,t){var n=e.pointRadius();return e.context(null),null!=t&&e.pointRadius(t),n}function p(e){t.Transform.call(this,null,e)}function m(e){t.Transform.call(this,null,e)}function c(e,t,n){var i=null==n?function(n){return e(t(n))}:function(i){var r=e.pointRadius(),a=e.pointRadius(n)(t(i));return e.pointRadius(r),a};return i.context=function(t){return e.context(t),i},i}function h(e){t.Transform.call(this,[],e),this.generator=o.geoGraticule()}function y(e){t.Transform.call(this,null,e),this.modified(!0)}function v(e,t){var n=D(t.fit);t.extent?e.fitExtent(t.extent,n):t.size&&e.fitSize(t.size,n)}function g(e){var t=a.projection((e||"mercator").toLowerCase());return t||n.error("Unrecognized projection type: "+e),t()}function j(e,t,i){n.isFunction(e[t])&&e[t](i)}function D(e){return 1===(e=n.array(e)).length?e[0]:{type:x,features:e.reduce(function(e,t){return t&&t.type===x?e.push.apply(e,t.features):n.isArray(t)?e.push.apply(e,t):e.push(t),e},[])}}var R=["values","size"],b=["x","y","size","cellSize","bandwidth"];s.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:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"count",type:"number"},{name:"nice",type:"number",default:!1},{name:"thresholds",type:"number",array:!0}]},n.inherits(s,t.Transform).transform=function(e,n){if(this.value&&!n.changed()&&!e.modified())return n.StopPropagation;var i,a,o,s=n.fork(n.NO_SOURCE|n.NO_FIELDS),f=e.count||10;return e.values?(i=r.contours(),a=R,o=e.values):(i=r.contourDensity(),a=b,o=n.materialize(n.SOURCE).source),i.thresholds(e.thresholds||(e.nice?f:u(f))),a.forEach(function(t){null!=e[t]&&i[t](e[t])}),this.value&&(s.rem=this.value),o=o&&o.length?i(o).map(t.ingest):[],this.value=s.source=s.add=o,s};var x="FeatureCollection";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 i,r=this._features,a=this._points,o=e.fields,s=o&&o[0],u=o&&o[1],f=e.geojson,l=t.ADD;i=e.modified()||t.changed(t.REM)||t.modified(n.accessorFields(f))||s&&t.modified(n.accessorFields(s))||u&&t.modified(n.accessorFields(u)),this.value&&!i||(l=t.SOURCE,this._features=r=[],this._points=a=[]),f&&t.visit(l,function(e){r.push(f(e))}),s&&u&&(t.visit(l,function(e){var t=s(e),n=u(e);null!=t&&null!=n&&(t=+t)===t&&(n=+n)===n&&a.push([t,n])}),r=r.concat({type:"Feature",geometry:{type:"MultiPoint",coordinates:a}})),this.value={type:x,features:r}},l.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(l,t.Transform).transform=function(e,t){var i=t.fork(t.ALL),r=this.value,o=e.field||n.identity,s=e.as||"path",u=i.SOURCE;!r||e.modified()?(this.value=r=a.getProjectionPath(e.projection),i.materialize().reflow()):u=o===n.identity||t.modified(o.fields)?i.ADD_MOD:i.ADD;var f=d(r,e.pointRadius);return i.visit(u,function(e){e[s]=r(o(e))}),r.pointRadius(f),i.modifies(s)},p.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(p,t.Transform).transform=function(e,t){function n(e){var t=r([a(e),o(e)]);t?(e[u]=t[0],e[f]=t[1]):(e[u]=void 0,e[f]=void 0)}var i,r=e.projection,a=e.fields[0],o=e.fields[1],s=e.as||["x","y"],u=s[0],f=s[1];return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,n):(i=t.modified(a.fields)||t.modified(o.fields),t.visit(i?t.ADD_MOD:t.ADD,n)),t.modifies(s)},m.Definition={type:"GeoShape",metadata:{modifies:!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(m,t.Transform).transform=function(e,t){var i=t.fork(t.ALL),r=this.value,o=e.field||n.field("datum"),s=e.as||"shape",u=i.ADD_MOD;return r&&!e.modified()||(this.value=r=c(a.getProjectionPath(e.projection),o,e.pointRadius),i.materialize().reflow(),u=i.SOURCE),i.visit(u,function(e){e[s]=r}),i.modifies(s)},h.Definition={type:"Graticule",metadata:{source:!0,generates:!0,changes:!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(h,t.Transform).transform=function(e,i){var r,a=i.fork(),o=this.value,s=this.generator;if(!o.length||e.modified())for(var u in e)n.isFunction(s[u])&&s[u](e[u]);return r=s(),o.length?a.mod.push(t.replace(o[0],r)):a.add.push(t.ingest(r)),o[0]=r,a.source=o,a},n.inherits(y,t.Transform).transform=function(e,t){var n=this.value;return!n||e.modified("type")?(this.value=n=g(e.type),a.projectionProperties.forEach(function(t){null!=e[t]&&j(n,t,e[t])})):a.projectionProperties.forEach(function(t){e.modified(t)&&j(n,t,e[t])}),null!=e.pointRadius&&n.path.pointRadius(e.pointRadius),e.fit&&v(n,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)},e.contour=s,e.geojson=f,e.geopath=l,e.geopoint=p,e.geoshape=m,e.graticule=h,e.projection=y,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-geo", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Geographic data transforms for Vega dataflows.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -38,3 +38,3 @@ import {ingest, Transform} from 'vega-dataflow'; | ||
"type": "Contour", | ||
"metadata": {"generates": true, "source": true}, | ||
"metadata": {"generates": true}, | ||
"params": [ | ||
@@ -82,3 +82,4 @@ { "name": "size", "type": "number", "array": true, "length": 2, "required": true }, | ||
if (this.value) out.rem = this.value; | ||
this.value = out.source = out.add = contour(values).map(ingest); | ||
values = values && values.length ? contour(values).map(ingest) : []; | ||
this.value = out.source = out.add = values; | ||
@@ -85,0 +86,0 @@ return out; |
@@ -26,2 +26,3 @@ import {Transform} from 'vega-dataflow'; | ||
{ "name": "field", "type": "field" }, | ||
{ "name": "pointRadius", "type": "number", "expr": true }, | ||
{ "name": "as", "type": "string", "default": "path" } | ||
@@ -38,3 +39,3 @@ ] | ||
as = _.as || 'path', | ||
mod; | ||
flag = out.SOURCE; | ||
@@ -45,11 +46,24 @@ function set(t) { t[as] = path(field(t)); } | ||
// parameters updated, reset and reflow | ||
this.value = path = getProjectionPath(_.projection).context(null); | ||
out.materialize().reflow().visit(out.SOURCE, set); | ||
this.value = path = getProjectionPath(_.projection); | ||
out.materialize().reflow(); | ||
} else { | ||
path.context(null); | ||
mod = field === identity || pulse.modified(field.fields); | ||
out.visit(mod ? out.ADD_MOD : out.ADD, set); | ||
flag = field === identity || pulse.modified(field.fields) | ||
? out.ADD_MOD | ||
: out.ADD; | ||
} | ||
var prev = initPath(path, _.pointRadius); | ||
out.visit(flag, set); | ||
path.pointRadius(prev); | ||
return out.modifies(as); | ||
}; | ||
function initPath(path, pointRadius) { | ||
var prev = path.pointRadius(); | ||
path.context(null); | ||
if (pointRadius != null) { | ||
path.pointRadius(pointRadius); | ||
} | ||
return prev; | ||
} |
@@ -26,2 +26,3 @@ import {Transform} from 'vega-dataflow'; | ||
{ "name": "field", "type": "field", "default": "datum" }, | ||
{ "name": "pointRadius", "type": "number", "expr": true }, | ||
{ "name": "as", "type": "string", "default": "shape" } | ||
@@ -43,3 +44,6 @@ ] | ||
this.value = shape = shapeGenerator( | ||
getProjectionPath(_.projection), datum); | ||
getProjectionPath(_.projection), | ||
datum, | ||
_.pointRadius | ||
); | ||
out.materialize().reflow(); | ||
@@ -54,6 +58,11 @@ flag = out.SOURCE; | ||
function shapeGenerator(path, field) { | ||
var shape = function(_) { | ||
return path(field(_)); | ||
}; | ||
function shapeGenerator(path, field, pointRadius) { | ||
var shape = pointRadius == null | ||
? function(_) { return path(field(_)); } | ||
: function(_) { | ||
var prev = path.pointRadius(), | ||
value = path.pointRadius(pointRadius)(field(_)); | ||
path.pointRadius(prev); | ||
return value; | ||
}; | ||
shape.context = function(_) { | ||
@@ -60,0 +69,0 @@ path.context(_); |
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
42364
868
15