Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.9 KiB

  1. sigma.layout.noverlap
  2. ========================
  3. Plugin developed by [Andrew Pitts](https://github.com/apitts) and published under the [MIT](LICENSE) license. Original algorithm by [Mathieu Jacomy](https://github.com/jacomyma) and ported to sigma.js with permission.
  4. ---
  5. This plugin runs an algorithm which distributes nodes in the network, ensuring that they do not overlap and providing a margin where specified.
  6. ## Methods
  7. **configure**
  8. Changes the layout's configuration.
  9. ```js
  10. var listener = s.configNoverlap(config);
  11. ```
  12. **start**
  13. Starts the layout. It is possible to pass a configuration if this is the first time you start the layout.
  14. ```js
  15. s.startNoverlap();
  16. ```
  17. **isRunning**
  18. Returns whether the layout is running.
  19. ```js
  20. s.isNoverlapRunning();
  21. ```
  22. ## Configuration
  23. * **nodes**: *array*: the subset of nodes to apply the layout.
  24. *Algorithm configuration*
  25. * **nodeMargin**: *number* `5.0`: The additional minimum space to apply around each and every node.
  26. * **scaleNodes**: *number* `1.2`: A multiplier to apply to nodes such that larger nodes will have more space around them if this multiplier is greater than zero.
  27. * **gridSize**: *integer* `20`: The number of rows and columns to use when dividing the nodes up into cells which the algorithm is applied to. Use more rows and columns for larger graphs for a more efficient algorithm.
  28. * **permittedExpansion** *number* `1.1`: At every step, this is the maximum ratio to apply to the bounding box, i.e. the maximum by which the network is permitted to expand.
  29. * **rendererIndex** *integer* `0`: The index of the renderer to use to compute overlap and collisions of the nodes.
  30. * **speed** *number* `2`: A larger value increases the speed with which the algorithm will convergence at the cost of precision.
  31. * **maxIterations** *number* `500`: The maximum number of iterations to run the algorithm for before stopping it.
  32. *Easing configuration*
  33. * **easing** *string*: if specified, ease the transition between nodes positions if background is `true`. The duration is specified by the Sigma settings `animationsTime`. See [sigma.utils.easing](../../src/utils/sigma.utils.js#L723) for available values.
  34. * **duration** *number*: duration of the transition for the easing method. Default value is Sigma setting `animationsTime`.
  35. ## Events
  36. The plugin dispatches the following events:
  37. - `start`: on layout start.
  38. - `interpolate`: at the beginning of the layout animation if an *easing* function is specified and the layout is ran on background.
  39. - `stop`: on layout stop, will be dispatched after `interpolate`.
  40. Example:
  41. ```js
  42. s = new sigma({
  43. graph: g,
  44. container: 'graph-container'
  45. });
  46. var config = {
  47. nodeMargin: 3.0,
  48. scaleNodes: 1.3
  49. };
  50. // Configure the algorithm
  51. var listener = s.configNoverlap(config);
  52. // Bind all events:
  53. listener.bind('start stop interpolate', function(event) {
  54. console.log(event.type);
  55. });
  56. // Start the algorithm:
  57. s.startNoverlap();
  58. ```