cytoscape-euler
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "cytoscape-euler", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A fast, high-quality force-directed (physics simulation) layout for Cytoscape.js", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-euler.js", |
# cytoscape-euler | ||
[![Join the chat at https://gitter.im/cytoscape-js-euler/Lobby](https://badges.gitter.im/cytoscape-js-euler/Lobby.svg)](https://gitter.im/cytoscape-js-euler/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![Join the chat at https://gitter.im/cytoscape-js-euler/Lobby](https://badges.gitter.im/cytoscape-js-euler/Lobby.svg)](https://gitter.im/cytoscape-js-euler/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![DOI](https://zenodo.org/badge/91359702.svg)](https://zenodo.org/badge/latestdoi/91359702) | ||
## Description | ||
@@ -59,3 +60,3 @@ | ||
// The ideal legth of a spring | ||
// The ideal length of a spring | ||
// - This acts as a hint for the edge length | ||
@@ -80,2 +81,6 @@ // - The edge length can be longer or shorter if the forces are set to extreme values | ||
// A force that pulls nodes towards the origin (0, 0) | ||
// Higher values keep the components less spread out | ||
pull: 0.001, | ||
// Theta coefficient from Barnes-Hut simulation | ||
@@ -172,1 +177,2 @@ // - Value ranges on [0, 1] | ||
1. If publishing to bower for the first time, you'll need to run `bower register cytoscape-euler https://github.com/cytoscape/cytoscape.js-euler.git` | ||
1. Make a release on GitHub to automatically register a new Zenodo DOI |
@@ -22,2 +22,6 @@ const defaults = Object.freeze({ | ||
// A force that pulls nodes towards the origin (0, 0) | ||
// Higher values keep the components less spread out | ||
pull: 0.001, | ||
// Theta coefficient from Barnes-Hut simulation | ||
@@ -24,0 +28,0 @@ // - Value ranges on [0, 1] |
@@ -45,3 +45,3 @@ // impl of barnes hut | ||
function update( sourceBody, gravity, theta ) { | ||
function update( sourceBody, gravity, theta, pull ) { | ||
let queue = updateQueue, | ||
@@ -61,2 +61,10 @@ v, | ||
let px = -sourceBody.pos.x; | ||
let py = -sourceBody.pos.y; | ||
let pr = Math.sqrt(px * px + py * py); | ||
let pv = sourceBody.mass * pull / pr; | ||
fx += pv * px; | ||
fy += pv * py; | ||
while (queueLength) { | ||
@@ -146,2 +154,4 @@ let node = queue[shiftIdx], | ||
function insertBodies(bodies) { | ||
if( bodies.length === 0 ){ return; } | ||
let x1 = Number.MAX_VALUE, | ||
@@ -148,0 +158,0 @@ y1 = Number.MAX_VALUE, |
@@ -5,3 +5,3 @@ const { integrate } = require('./integrate'); | ||
function tick({ bodies, springs, quadtree, timeStep, gravity, theta, dragCoeff }){ | ||
function tick({ bodies, springs, quadtree, timeStep, gravity, theta, dragCoeff, pull }){ | ||
// update body from scratch in case of any changes | ||
@@ -13,6 +13,2 @@ bodies.forEach( body => { | ||
if( p.grabbed ){ | ||
console.log( 'grabbed' ); | ||
} | ||
body.locked = p.locked; | ||
@@ -29,3 +25,3 @@ body.grabbed = p.grabbed; | ||
quadtree.updateBodyForce( body, gravity, theta ); | ||
quadtree.updateBodyForce( body, gravity, theta, pull ); | ||
applyDrag( body, dragCoeff ); | ||
@@ -32,0 +28,0 @@ } |
@@ -33,3 +33,3 @@ /** | ||
s.firstUpdate = true; | ||
s.startTime = Date.now(); | ||
s.running = true; | ||
@@ -126,4 +126,2 @@ | ||
s.startTime = Date.now(); | ||
l.emit('layoutstart'); | ||
@@ -138,4 +136,10 @@ | ||
} else { | ||
multitick( s ); | ||
let done = false; | ||
let onNotDone = () => {}; | ||
let onDone = () => done = true; | ||
while( !done ){ | ||
multitick( s, onNotDone, onDone ); | ||
} | ||
s.eles.layoutPositions( this, s, node => getNodePositionData( node, s ) ); | ||
@@ -142,0 +146,0 @@ } |
@@ -18,3 +18,3 @@ const nop = function(){}; | ||
let duration = s.startTime - Date.now(); | ||
let duration = Date.now() - s.startTime; | ||
@@ -28,3 +28,3 @@ return !s.infinite && ( tickIndicatesDone || s.tickIndex >= s.maxIterations || duration >= s.maxSimulationTime ); | ||
for( let i = 0; i < s.maxIterations; i++ ){ | ||
for( let i = 0; i < s.refresh; i++ ){ | ||
done = !s.running || tick( s ); | ||
@@ -31,0 +31,0 @@ |
Sorry, the diff of this file is too big to display
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
712908
19504
176