vega-force
Advanced tools
Comparing version 1.0.0-beta.3 to 1.0.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-dataflow'), require('vega-util'), require('d3-force')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vega-dataflow', 'vega-util', 'd3-force'], factory) : | ||
(factory((global.vega = global.vega || {}),global.vega,global.vega,global.d3)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-dataflow'), require('vega-util'), require('d3-force')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vega-dataflow', 'vega-util', 'd3-force'], factory) : | ||
(factory((global.vega = global.vega || {}),global.vega,global.vega,global.d3)); | ||
}(this, (function (exports,vegaDataflow,vegaUtil,d3Force) { 'use strict'; | ||
@@ -46,6 +46,12 @@ | ||
sim.on('tick', rerun(pulse.dataflow, this)); | ||
if (!_.static) change = true, sim.tick(); // ensure we run on init | ||
if (!_.static) { | ||
change = true; | ||
sim.tick(); // ensure we run on init | ||
} | ||
pulse.modifies('index'); | ||
} else { | ||
if (change) pulse.modifies('index'), sim.nodes(pulse.source); | ||
if (change) { | ||
pulse.modifies('index'); | ||
sim.nodes(pulse.source); | ||
} | ||
if (params) setup(sim, _); | ||
@@ -103,5 +109,13 @@ } | ||
sim.stopped = function() { return stopped; }; | ||
sim.restart = function() { return stopped = false, restart(); }; | ||
sim.stop = function() { return stopped = true, stop(); }; | ||
sim.stopped = function() { | ||
return stopped; | ||
}; | ||
sim.restart = function() { | ||
stopped = false; | ||
return restart(); | ||
}; | ||
sim.stop = function() { | ||
stopped = true; | ||
return stop(); | ||
}; | ||
@@ -128,3 +142,4 @@ return setup(sim, _, true).on('end', function() { stopped = true; }); | ||
return sim.numForces = f.length, sim; | ||
sim.numForces = f.length; | ||
return sim; | ||
} | ||
@@ -134,2 +149,3 @@ | ||
var f, p; | ||
if (!ForceMap.hasOwnProperty(_.force)) { | ||
@@ -139,3 +155,9 @@ vegaUtil.error('Unrecognized force: ' + _.force); | ||
f = ForceMap[_.force](); | ||
for (p in _) if (vegaUtil.isFunction(f[p])) f[p](_[p]); | ||
for (p in _) { | ||
if (vegaUtil.isFunction(f[p])) { | ||
f[p](_[p]); | ||
} | ||
} | ||
return f; | ||
@@ -142,0 +164,0 @@ } |
@@ -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){var n,o,i,f=a.array(t.forces);for(n=0,o=d.length;n<o;++n)i=d[n],i!==m&&t.modified(i)&&e[i](t[i]);for(n=0,o=f.length;n<o;++n)(r||t.modified(m,n))&&e.force(m+n,u(f[n]));for(o=e.numForces||0;n<o;++n)e.force(m+n,null);return e.numForces=f.length,e}function u(e){var t,r;s.hasOwnProperty(e.force)||a.error("Unrecognized force: "+e.force),t=s[e.force]();for(r in e)a.isFunction(t[r])&&t[r](e[r]);return t}var s={center:r.forceCenter,collide:r.forceCollide,nbody:r.forceManyBody,link:r.forceLink,x:r.forceX,y:r.forceY},m="forces",d=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],c=["static","iterations"],l=["x","y","vx","vy"],p=a.inherits(n,t.Transform);p.transform=function(e,t){var a=this.value,r=t.changed(t.ADD_REM),n=e.modified(d),u=e.iterations||300;if(a?(r&&(t.modifies("index"),a.nodes(t.source)),n&&f(a,e)):(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(c)||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)},p.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],a.name===m&&"link"===a.op._argval.force)for(var f,u=a.op._argops,s=0,d=u.length;s<d;++s)if("links"===u[s].name&&(f=u[s].op.source)){r.pulse(f,r.changeset().reflow());break}return t.reflow(e.modified()).modifies(l)};var y={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(y,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,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){var n,o,i,f=a.array(t.forces);for(n=0,o=d.length;n<o;++n)(i=d[n])!==m&&t.modified(i)&&e[i](t[i]);for(n=0,o=f.length;n<o;++n)(r||t.modified(m,n))&&e.force(m+n,u(f[n]));for(o=e.numForces||0;n<o;++n)e.force(m+n,null);return e.numForces=f.length,e}function u(e){var t,r;s.hasOwnProperty(e.force)||a.error("Unrecognized force: "+e.force),t=s[e.force]();for(r in e)a.isFunction(t[r])&&t[r](e[r]);return t}var s={center:r.forceCenter,collide:r.forceCollide,nbody:r.forceManyBody,link:r.forceLink,x:r.forceX,y:r.forceY},m="forces",d=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],c=["static","iterations"],l=["x","y","vx","vy"],p=a.inherits(n,t.Transform);p.transform=function(e,t){var a=this.value,r=t.changed(t.ADD_REM),n=e.modified(d),u=e.iterations||300;if(a?(r&&(t.modifies("index"),a.nodes(t.source)),n&&f(a,e)):(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(c)||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)},p.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===m&&"link"===a.op._argval.force)for(var f,u=a.op._argops,s=0,d=u.length;s<d;++s)if("links"===u[s].name&&(f=u[s].op.source)){r.pulse(f,r.changeset().reflow());break}return t.reflow(e.modified()).modifies(l)};var y={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(y,n),e.transform=t.transform,e.definition=t.definition,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-force", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0", | ||
"description": "Force simulation transform for Vega dataflows.", | ||
@@ -30,11 +30,11 @@ "keywords": [ | ||
"d3-force": "1", | ||
"vega-dataflow": ">=2.0.0-beta.27", | ||
"vega-dataflow": "2", | ||
"vega-util": "1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "2", | ||
"rollup": "0.36", | ||
"eslint": "4", | ||
"rollup": "0.43", | ||
"tape": "4", | ||
"uglify-js": "2" | ||
"uglify-js": "3" | ||
} | ||
} | ||
} |
# vega-force | ||
Force simulation transform for Vega dataflows. | ||
This module provides the following data transform: | ||
- [**Force**](https://vega.github.io/vega/docs/transforms/force/) [<>](https://github.com/vega/vega-force/blob/master/src/Force.js "Source") |
@@ -47,6 +47,12 @@ import {Transform} from 'vega-dataflow'; | ||
sim.on('tick', rerun(pulse.dataflow, this)); | ||
if (!_.static) change = true, sim.tick(); // ensure we run on init | ||
if (!_.static) { | ||
change = true; | ||
sim.tick(); // ensure we run on init | ||
} | ||
pulse.modifies('index'); | ||
} else { | ||
if (change) pulse.modifies('index'), sim.nodes(pulse.source); | ||
if (change) { | ||
pulse.modifies('index'); | ||
sim.nodes(pulse.source); | ||
} | ||
if (params) setup(sim, _); | ||
@@ -104,5 +110,13 @@ } | ||
sim.stopped = function() { return stopped; }; | ||
sim.restart = function() { return stopped = false, restart(); }; | ||
sim.stop = function() { return stopped = true, stop(); }; | ||
sim.stopped = function() { | ||
return stopped; | ||
}; | ||
sim.restart = function() { | ||
stopped = false; | ||
return restart(); | ||
}; | ||
sim.stop = function() { | ||
stopped = true; | ||
return stop(); | ||
}; | ||
@@ -129,3 +143,4 @@ return setup(sim, _, true).on('end', function() { stopped = true; }); | ||
return sim.numForces = f.length, sim; | ||
sim.numForces = f.length; | ||
return sim; | ||
} | ||
@@ -135,2 +150,3 @@ | ||
var f, p; | ||
if (!ForceMap.hasOwnProperty(_.force)) { | ||
@@ -140,4 +156,10 @@ error('Unrecognized force: ' + _.force); | ||
f = ForceMap[_.force](); | ||
for (p in _) if (isFunction(f[p])) f[p](_[p]); | ||
for (p in _) { | ||
if (isFunction(f[p])) { | ||
f[p](_[p]); | ||
} | ||
} | ||
return f; | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19822
416
2
8
+ Addedd3-array@1.2.4(transitive)
+ Addedd3-dsv@1.2.0(transitive)
+ Addedd3-request@1.0.6(transitive)
+ Addedd3-time@1.1.0(transitive)
+ Addedd3-time-format@2.3.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedvega-dataflow@2.2.0(transitive)
+ Addedvega-loader@2.1.0(transitive)
+ Addedvega-statistics@1.9.0(transitive)
+ Addedxmlhttprequest@1.8.0(transitive)
- Removedcommander@7.2.0(transitive)
- Removedd3-dsv@3.0.1(transitive)
- Removedd3-format@3.1.0(transitive)
- Removedd3-time@3.1.0(transitive)
- Removedd3-time-format@4.1.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedvega-dataflow@5.7.6(transitive)
- Removedvega-format@1.1.2(transitive)
- Removedvega-loader@4.5.2(transitive)
- Removedvega-time@2.1.2(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatedvega-dataflow@2