vega-force
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -167,5 +167,3 @@ (function (global, factory) { | ||
for (p in _) { | ||
if (vegaUtil.isFunction(f[p])) { | ||
f[p](_[p]); | ||
} | ||
if (vegaUtil.isFunction(f[p])) setForceParam(f[p], _[p], _); | ||
} | ||
@@ -176,2 +174,6 @@ | ||
function setForceParam(f, v, _) { | ||
f(vegaUtil.isFunction(v) ? function(d) { return v(d, _); } : v); | ||
} | ||
var ForceDefinition = { | ||
@@ -178,0 +180,0 @@ "type": "Force", |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util"),require("d3-force")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-force"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.d3)}(this,function(e,t,a,r){"use strict";function n(e){t.Transform.call(this,null,e)}function o(e,t){return function(){e.touch(t).run()}}function i(e,t){var a=r.forceSimulation(e),n=!1,o=a.stop,i=a.restart;return a.stopped=function(){return n},a.restart=function(){return n=!1,i()},a.stop=function(){return n=!0,o()},f(a,t,!0).on("end",function(){n=!0})}function f(e,t,r,n){var o,i,f,c,l=a.array(t.forces);for(o=0,i=m.length;o<i;++o)(f=m[o])!==d&&t.modified(f)&&e[f](t[f]);for(o=0,i=l.length;o<i;++o)c=d+o,(f=r||t.modified(d,o)?s(l[o]):n&&u(l[o],n)?e.force(c):null)&&e.force(c,f);for(i=e.numForces||0;o<i;++o)e.force(d+o,null);return e.numForces=l.length,e}function u(e,t){var r,n;for(r in e)if(a.isFunction(n=e[r])&&t.modified(a.accessorFields(n)))return 1;return 0}function s(e){var t,r;c.hasOwnProperty(e.force)||a.error("Unrecognized force: "+e.force),t=c[e.force]();for(r in e)a.isFunction(t[r])&&t[r](e[r]);return t}var c={center:r.forceCenter,collide:r.forceCollide,nbody:r.forceManyBody,link:r.forceLink,x:r.forceX,y:r.forceY},d="forces",m=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],l=["static","iterations"],p=["x","y","vx","vy"],y=a.inherits(n,t.Transform);y.transform=function(e,t){var a=this.value,r=t.changed(t.ADD_REM),n=e.modified(m),u=e.iterations||300;if(a?(r&&(t.modifies("index"),a.nodes(t.source)),(n||t.changed(t.MOD))&&f(a,e,0,t)):(this.value=a=i(t.source,e),a.on("tick",o(t.dataflow,this)),e.static||(r=!0,a.tick()),t.modifies("index")),n||r||e.modified(l)||t.changed()&&e.restart)if(a.alpha(Math.max(a.alpha(),e.alpha||1)).alphaDecay(1-Math.pow(a.alphaMin(),1/u)),e.static)for(a.stop();--u>=0;)a.tick();else if(a.stopped()&&a.restart(),!r)return t.StopPropagation;return this.finish(e,t)},y.finish=function(e,t){for(var a,r=t.dataflow,n=this._argops,o=0,i=n.length;o<i;++o)if((a=n[o]).name===d&&"link"===a.op._argval.force)for(var f,u=a.op._argops,s=0,c=u.length;s<c;++s)if("links"===u[s].name&&(f=u[s].op.source)){r.pulse(f,r.changeset().reflow());break}return t.reflow(e.modified()).modifies(p)};var h={type:"Force",metadata:{modifies:!0},params:[{name:"static",type:"boolean",default:!1},{name:"restart",type:"boolean",default:!1},{name:"iterations",type:"number",default:300},{name:"alpha",type:"number",default:1},{name:"alphaMin",type:"number",default:.001},{name:"alphaTarget",type:"number",default:0},{name:"velocityDecay",type:"number",default:.4},{name:"forces",type:"param",array:!0,params:[{key:{force:"center"},params:[{name:"x",type:"number",default:0},{name:"y",type:"number",default:0}]},{key:{force:"collide"},params:[{name:"radius",type:"number",expr:!0},{name:"strength",type:"number",default:.7},{name:"iterations",type:"number",default:1}]},{key:{force:"nbody"},params:[{name:"strength",type:"number",default:-30},{name:"theta",type:"number",default:.9},{name:"distanceMin",type:"number",default:1},{name:"distanceMax",type:"number"}]},{key:{force:"link"},params:[{name:"links",type:"data"},{name:"id",type:"field"},{name:"distance",type:"number",default:30,expr:!0},{name:"strength",type:"number",expr:!0},{name:"iterations",type:"number",default:1}]},{key:{force:"x"},params:[{name:"strength",type:"number",default:.1},{name:"x",type:"field"}]},{key:{force:"y"},params:[{name:"strength",type:"number",default:.1},{name:"y",type:"field"}]}]},{name:"as",type:"string",array:!0,modify:!1,default:["x","y","vx","vy"]}]};t.register(h,n),e.transform=t.transform,e.definition=t.definition,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-force")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-force"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.d3)}(this,function(e,t,n,a){"use strict";function r(e){t.Transform.call(this,null,e)}function o(e,t){return function(){e.touch(t).run()}}function i(e,t){var n=a.forceSimulation(e),r=!1,o=n.stop,i=n.restart;return n.stopped=function(){return r},n.restart=function(){return r=!1,i()},n.stop=function(){return r=!0,o()},f(n,t,!0).on("end",function(){r=!0})}function f(e,t,a,r){var o,i,f,c,d=n.array(t.forces);for(o=0,i=l.length;o<i;++o)(f=l[o])!==m&&t.modified(f)&&e[f](t[f]);for(o=0,i=d.length;o<i;++o)c=m+o,(f=a||t.modified(m,o)?s(d[o]):r&&u(d[o],r)?e.force(c):null)&&e.force(c,f);for(i=e.numForces||0;o<i;++o)e.force(m+o,null);return e.numForces=d.length,e}function u(e,t){var a,r;for(a in e)if(n.isFunction(r=e[a])&&t.modified(n.accessorFields(r)))return 1;return 0}function s(e){var t,a;d.hasOwnProperty(e.force)||n.error("Unrecognized force: "+e.force),t=d[e.force]();for(a in e)n.isFunction(t[a])&&c(t[a],e[a],e);return t}function c(e,t,a){e(n.isFunction(t)?function(e){return t(e,a)}:t)}var d={center:a.forceCenter,collide:a.forceCollide,nbody:a.forceManyBody,link:a.forceLink,x:a.forceX,y:a.forceY},m="forces",l=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],p=["static","iterations"],y=["x","y","vx","vy"],h=n.inherits(r,t.Transform);h.transform=function(e,t){var n=this.value,a=t.changed(t.ADD_REM),r=e.modified(l),u=e.iterations||300;if(n?(a&&(t.modifies("index"),n.nodes(t.source)),(r||t.changed(t.MOD))&&f(n,e,0,t)):(this.value=n=i(t.source,e),n.on("tick",o(t.dataflow,this)),e.static||(a=!0,n.tick()),t.modifies("index")),r||a||e.modified(p)||t.changed()&&e.restart)if(n.alpha(Math.max(n.alpha(),e.alpha||1)).alphaDecay(1-Math.pow(n.alphaMin(),1/u)),e.static)for(n.stop();--u>=0;)n.tick();else if(n.stopped()&&n.restart(),!a)return t.StopPropagation;return this.finish(e,t)},h.finish=function(e,t){for(var n,a=t.dataflow,r=this._argops,o=0,i=r.length;o<i;++o)if((n=r[o]).name===m&&"link"===n.op._argval.force)for(var f,u=n.op._argops,s=0,c=u.length;s<c;++s)if("links"===u[s].name&&(f=u[s].op.source)){a.pulse(f,a.changeset().reflow());break}return t.reflow(e.modified()).modifies(y)};var g={type:"Force",metadata:{modifies:!0},params:[{name:"static",type:"boolean",default:!1},{name:"restart",type:"boolean",default:!1},{name:"iterations",type:"number",default:300},{name:"alpha",type:"number",default:1},{name:"alphaMin",type:"number",default:.001},{name:"alphaTarget",type:"number",default:0},{name:"velocityDecay",type:"number",default:.4},{name:"forces",type:"param",array:!0,params:[{key:{force:"center"},params:[{name:"x",type:"number",default:0},{name:"y",type:"number",default:0}]},{key:{force:"collide"},params:[{name:"radius",type:"number",expr:!0},{name:"strength",type:"number",default:.7},{name:"iterations",type:"number",default:1}]},{key:{force:"nbody"},params:[{name:"strength",type:"number",default:-30},{name:"theta",type:"number",default:.9},{name:"distanceMin",type:"number",default:1},{name:"distanceMax",type:"number"}]},{key:{force:"link"},params:[{name:"links",type:"data"},{name:"id",type:"field"},{name:"distance",type:"number",default:30,expr:!0},{name:"strength",type:"number",expr:!0},{name:"iterations",type:"number",default:1}]},{key:{force:"x"},params:[{name:"strength",type:"number",default:.1},{name:"x",type:"field"}]},{key:{force:"y"},params:[{name:"strength",type:"number",default:.1},{name:"y",type:"field"}]}]},{name:"as",type:"string",array:!0,modify:!1,default:["x","y","vx","vy"]}]};t.register(g,r),e.transform=t.transform,e.definition=t.definition,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-force", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Force simulation transform for Vega dataflows.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -168,5 +168,3 @@ import {Transform} from 'vega-dataflow'; | ||
for (p in _) { | ||
if (isFunction(f[p])) { | ||
f[p](_[p]); | ||
} | ||
if (isFunction(f[p])) setForceParam(f[p], _[p], _); | ||
} | ||
@@ -176,1 +174,5 @@ | ||
} | ||
function setForceParam(f, v, _) { | ||
f(isFunction(v) ? function(d) { return v(d, _); } : v); | ||
} |
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
20938
442