vega-force
Advanced tools
Comparing version 1.0.2 to 2.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)); | ||
(factory((global.vega = global.vega || {}, global.vega.transforms = global.vega.transforms || {}),global.vega,global.vega,global.d3)); | ||
}(this, (function (exports,vegaDataflow,vegaUtil,d3Force) { 'use strict'; | ||
@@ -34,2 +34,71 @@ | ||
Force.Definition = { | ||
"type": "Force", | ||
"metadata": {"modifies": true}, | ||
"params": [ | ||
{ "name": "static", "type": "boolean", "default": false }, | ||
{ "name": "restart", "type": "boolean", "default": false }, | ||
{ "name": "iterations", "type": "number", "default": 300 }, | ||
{ "name": "alpha", "type": "number", "default": 1 }, | ||
{ "name": "alphaMin", "type": "number", "default": 0.001 }, | ||
{ "name": "alphaTarget", "type": "number", "default": 0 }, | ||
{ "name": "velocityDecay", "type": "number", "default": 0.4 }, | ||
{ "name": "forces", "type": "param", "array": true, | ||
"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": true }, | ||
{ "name": "strength", "type": "number", "default": 0.7 }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "nbody"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": -30 }, | ||
{ "name": "theta", "type": "number", "default": 0.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": true }, | ||
{ "name": "strength", "type": "number", "expr": true }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "x"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "x", "type": "field" } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "y"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "y", "type": "field" } | ||
] | ||
} | ||
] }, | ||
{ | ||
"name": "as", "type": "string", "array": true, "modify": false, | ||
"default": ForceOutput | ||
} | ||
] | ||
}; | ||
var prototype = vegaUtil.inherits(Force, vegaDataflow.Transform); | ||
@@ -178,78 +247,6 @@ | ||
var ForceDefinition = { | ||
"type": "Force", | ||
"metadata": {"modifies": true}, | ||
"params": [ | ||
{ "name": "static", "type": "boolean", "default": false }, | ||
{ "name": "restart", "type": "boolean", "default": false }, | ||
{ "name": "iterations", "type": "number", "default": 300 }, | ||
{ "name": "alpha", "type": "number", "default": 1 }, | ||
{ "name": "alphaMin", "type": "number", "default": 0.001 }, | ||
{ "name": "alphaTarget", "type": "number", "default": 0 }, | ||
{ "name": "velocityDecay", "type": "number", "default": 0.4 }, | ||
{ "name": "forces", "type": "param", "array": true, | ||
"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": true }, | ||
{ "name": "strength", "type": "number", "default": 0.7 }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "nbody"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": -30 }, | ||
{ "name": "theta", "type": "number", "default": 0.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": true }, | ||
{ "name": "strength", "type": "number", "expr": true }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "x"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "x", "type": "field" } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "y"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "y", "type": "field" } | ||
] | ||
} | ||
] }, | ||
{ | ||
"name": "as", "type": "string", "array": true, "modify": false, | ||
"default": ["x", "y", "vx", "vy"] | ||
} | ||
] | ||
}; | ||
exports.force = Force; | ||
vegaDataflow.register(ForceDefinition, Force); | ||
exports.transform = vegaDataflow.transform; | ||
exports.definition = vegaDataflow.definition; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); |
@@ -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,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})}); | ||
!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.transforms=e.vega.transforms||{}),e.vega,e.vega,e.d3)}(this,function(e,t,a,n){"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 a=n.forceSimulation(e),r=!1,o=a.stop,i=a.restart;return a.stopped=function(){return r},a.restart=function(){return r=!1,i()},a.stop=function(){return r=!0,o()},f(a,t,!0).on("end",function(){r=!0})}function f(e,t,n,r){var o,i,f,c,m=a.array(t.forces);for(o=0,i=l.length;o<i;++o)(f=l[o])!==d&&t.modified(f)&&e[f](t[f]);for(o=0,i=m.length;o<i;++o)c=d+o,(f=n||t.modified(d,o)?s(m[o]):r&&u(m[o],r)?e.force(c):null)&&e.force(c,f);for(i=e.numForces||0;o<i;++o)e.force(d+o,null);return e.numForces=m.length,e}function u(e,t){var n,r;for(n in e)if(a.isFunction(r=e[n])&&t.modified(a.accessorFields(r)))return 1;return 0}function s(e){var t,n;m.hasOwnProperty(e.force)||a.error("Unrecognized force: "+e.force),t=m[e.force]();for(n in e)a.isFunction(t[n])&&c(t[n],e[n],e);return t}function c(e,t,n){e(a.isFunction(t)?function(e){return t(e,n)}:t)}var m={center:n.forceCenter,collide:n.forceCollide,nbody:n.forceManyBody,link:n.forceLink,x:n.forceX,y:n.forceY},d="forces",l=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],p=["static","iterations"],y=["x","y","vx","vy"];r.Definition={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:y}]};var h=a.inherits(r,t.Transform);h.transform=function(e,t){var a=this.value,n=t.changed(t.ADD_REM),r=e.modified(l),u=e.iterations||300;if(a?(n&&(t.modifies("index"),a.nodes(t.source)),(r||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||(n=!0,a.tick()),t.modifies("index")),r||n||e.modified(p)||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(),!n)return t.StopPropagation;return this.finish(e,t)},h.finish=function(e,t){for(var a,n=t.dataflow,r=this._argops,o=0,i=r.length;o<i;++o)if((a=r[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)){n.pulse(f,n.changeset().reflow());break}return t.reflow(e.modified()).modifies(y)},e.force=r,Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -1,7 +0,1 @@ | ||
import {register} from 'vega-dataflow'; | ||
import Force from './src/Force'; | ||
import ForceDefinition from './definitions/Force'; | ||
register(ForceDefinition, Force); | ||
export {transform, definition} from 'vega-dataflow'; | ||
export {default as force} from './src/Force'; |
{ | ||
"name": "vega-force", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "Force simulation transform for Vega dataflows.", | ||
@@ -23,3 +23,3 @@ "keywords": [ | ||
"build": "npm run test && uglifyjs build/vega-force.js -c -m -o build/vega-force.min.js", | ||
"pretest": "rm -rf build && mkdir build && rollup -g d3-force:d3,vega-dataflow:vega,vega-util:vega -f umd -n vega -o build/vega-force.js -- index.js", | ||
"pretest": "rm -rf build && mkdir build && rollup -g d3-force:d3,vega-dataflow:vega,vega-util:vega -f umd -n vega.transforms -o build/vega-force.js -- index.js", | ||
"test": "tape 'test/**/*-test.js' && eslint index.js src test", | ||
@@ -31,3 +31,3 @@ "prepublish": "npm run build", | ||
"d3-force": "1", | ||
"vega-dataflow": "2", | ||
"vega-dataflow": "3", | ||
"vega-util": "1" | ||
@@ -34,0 +34,0 @@ }, |
@@ -5,4 +5,4 @@ # vega-force | ||
This module provides the following data transform: | ||
This module provides the following Vega data transform: | ||
- [**Force**](https://vega.github.io/vega/docs/transforms/force/) [<>](https://github.com/vega/vega-force/blob/master/src/Force.js "Source") |
@@ -35,2 +35,71 @@ import {Transform} from 'vega-dataflow'; | ||
Force.Definition = { | ||
"type": "Force", | ||
"metadata": {"modifies": true}, | ||
"params": [ | ||
{ "name": "static", "type": "boolean", "default": false }, | ||
{ "name": "restart", "type": "boolean", "default": false }, | ||
{ "name": "iterations", "type": "number", "default": 300 }, | ||
{ "name": "alpha", "type": "number", "default": 1 }, | ||
{ "name": "alphaMin", "type": "number", "default": 0.001 }, | ||
{ "name": "alphaTarget", "type": "number", "default": 0 }, | ||
{ "name": "velocityDecay", "type": "number", "default": 0.4 }, | ||
{ "name": "forces", "type": "param", "array": true, | ||
"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": true }, | ||
{ "name": "strength", "type": "number", "default": 0.7 }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "nbody"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": -30 }, | ||
{ "name": "theta", "type": "number", "default": 0.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": true }, | ||
{ "name": "strength", "type": "number", "expr": true }, | ||
{ "name": "iterations", "type": "number", "default": 1 } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "x"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "x", "type": "field" } | ||
] | ||
}, | ||
{ | ||
"key": {"force": "y"}, | ||
"params": [ | ||
{ "name": "strength", "type": "number", "default": 0.1 }, | ||
{ "name": "y", "type": "field" } | ||
] | ||
} | ||
] }, | ||
{ | ||
"name": "as", "type": "string", "array": true, "modify": false, | ||
"default": ForceOutput | ||
} | ||
] | ||
}; | ||
var prototype = inherits(Force, Transform); | ||
@@ -37,0 +106,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
20687
9
437
+ Addedvega-dataflow@3.1.0(transitive)
- Removedd3-array@1.2.43.2.4(transitive)
- Removedinternmap@2.0.3(transitive)
- Removedvega-dataflow@2.2.0(transitive)
- Removedvega-statistics@1.9.0(transitive)
Updatedvega-dataflow@3