Coder Social home page Coder Social logo

anvaka / ngraph.remove-overlaps Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 1.0 53 KB

Removes overlaps between nodes in ngraph.forcelayout

Home Page: https://anvaka.github.io/ngraph.remove-overlaps/demo/rect/index.html

License: MIT License

JavaScript 99.66% HTML 0.34%

ngraph.remove-overlaps's Introduction

ngraph.remove-overlaps

Removes overlaps between nodes in ngraph.forcelayout. Demo

Usage

There are two ways how you can use ngraph.remove-overlaps. One option is "fire-and-forget". In this mode remove overlaps will take whatever current state of the system is, and will remove all overlaps between boxes:

var createLayout = require('ngraph.forcelayout')
var layout = createLayout(graph)

// let's say your layout ran for several iterations:
while(iterationsCount++ < MAX_ITERTIONS) {
  layout.step()
}

// If you want to remove overlaps just once:
var removeOverlaps = require('ngraph.remove-overlaps')
removeOverlaps(layout)

Alternatively, you may want to remove overlaps after every single layout iteration:

var removeOverlaps = require('ngraph.remove-overlaps')
var createLayout = require('ngraph.forcelayout')
var layout = createLayout(graph)

// run layout and overlap removal for several iterations:
while(iterationsCount++ < MAX_ITERTIONS) {
  layout.step()
  removeOverlaps(layout);
}

Or you can write the code more concisely like so:

var removeOverlaps = require('ngraph.remove-overlaps')
var createLayout = require('ngraph.forcelayout')
var layout = createLayout(graph)

// Thanks to {active: true} option, whever layout is changed,
// the overlaps will be removed automatically:
removeOverlaps(layout, {active: true})

// let's say your layout ran for several iterations:
while(iterationsCount++ < MAX_ITERTIONS) {
  layout.step()
}

license

MIT

ngraph.remove-overlaps's People

Contributors

anvaka avatar

Stargazers

Liam Byrne avatar Joe Wood avatar Luigi avatar

Watchers

 avatar Luigi avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.