Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elkjs

Package Overview
Dependencies
Maintainers
4
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elkjs

Automatic graph layout based on Sugiyama's algorithm. Specialized for data flow diagrams and ports.

  • 0.9.3
  • next
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
617K
decreased by-17.95%
Maintainers
4
Weekly downloads
 
Created

What is elkjs?

elkjs is a JavaScript library for layouting graphs and diagrams. It provides a powerful and flexible way to automatically arrange nodes and edges in a visually appealing manner.

What are elkjs's main functionalities?

Basic Graph Layout

This feature allows you to create a basic graph layout using the 'layered' algorithm. The code sample demonstrates how to define nodes and edges and then apply the layout algorithm to arrange them.

const ELK = require('elkjs');
const elk = new ELK();

const graph = {
  id: 'root',
  layoutOptions: { 'elk.algorithm': 'layered' },
  children: [
    { id: 'n1', width: 30, height: 30 },
    { id: 'n2', width: 30, height: 30 }
  ],
  edges: [
    { id: 'e1', sources: ['n1'], targets: ['n2'] }
  ]
};

elk.layout(graph).then((layout) => {
  console.log(layout);
});

Custom Layout Options

This feature allows you to customize the layout algorithm. The code sample demonstrates how to use the 'force' algorithm to arrange nodes and edges in a graph.

const ELK = require('elkjs');
const elk = new ELK();

const graph = {
  id: 'root',
  layoutOptions: { 'elk.algorithm': 'force' },
  children: [
    { id: 'n1', width: 30, height: 30 },
    { id: 'n2', width: 30, height: 30 },
    { id: 'n3', width: 30, height: 30 }
  ],
  edges: [
    { id: 'e1', sources: ['n1'], targets: ['n2'] },
    { id: 'e2', sources: ['n2'], targets: ['n3'] }
  ]
};

elk.layout(graph).then((layout) => {
  console.log(layout);
});

Hierarchical Layout

This feature allows you to create hierarchical layouts using the 'layered' algorithm. The code sample demonstrates how to arrange nodes and edges in a hierarchical manner.

const ELK = require('elkjs');
const elk = new ELK();

const graph = {
  id: 'root',
  layoutOptions: { 'elk.algorithm': 'layered' },
  children: [
    { id: 'n1', width: 30, height: 30 },
    { id: 'n2', width: 30, height: 30 },
    { id: 'n3', width: 30, height: 30 }
  ],
  edges: [
    { id: 'e1', sources: ['n1'], targets: ['n2'] },
    { id: 'e2', sources: ['n1'], targets: ['n3'] }
  ]
};

elk.layout(graph).then((layout) => {
  console.log(layout);
});

Other packages similar to elkjs

Keywords

FAQs

Package last updated on 16 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc