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

dagre-d3-es

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dagre-d3-es

The [dagre-d3](https://github.com/dagrejs) library is not maintained anymore.

  • 7.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
609K
decreased by-14.34%
Maintainers
1
Weekly downloads
 
Created

What is dagre-d3-es?

The dagre-d3-es package is a JavaScript library that provides tools for creating directed graphs and rendering them using D3.js. It is particularly useful for visualizing hierarchical data structures, such as flowcharts, dependency graphs, and organizational charts.

What are dagre-d3-es's main functionalities?

Graph Creation

This feature allows you to create a directed graph, add nodes, and define edges between them. The code sample demonstrates how to create a graph, add nodes 'A' and 'B', and create an edge from 'A' to 'B'.

const dagreD3 = require('dagre-d3-es');
const graphlib = require('graphlib');

// Create a new directed graph
const g = new graphlib.Graph().setGraph({});

// Add nodes to the graph
g.setNode('A', { label: 'Node A' });
g.setNode('B', { label: 'Node B' });

// Add an edge between nodes
g.setEdge('A', 'B');

console.log(g.nodes()); // ['A', 'B']
console.log(g.edges()); // [{ v: 'A', w: 'B' }]

Graph Rendering

This feature allows you to render the graph using D3.js. The code sample demonstrates how to create a graph, add nodes and edges, and render the graph in an SVG element.

const d3 = require('d3');
const dagreD3 = require('dagre-d3-es');

// Create a new directed graph
const g = new dagreD3.graphlib.Graph().setGraph({});

// Add nodes and edges
g.setNode('A', { label: 'Node A' });
g.setNode('B', { label: 'Node B' });
g.setEdge('A', 'B');

// Create the renderer
const render = new dagreD3.render();

// Set up an SVG group so that we can translate the final graph.
const svg = d3.select('svg'),
    svgGroup = svg.append('g');

// Run the renderer. This is what draws the final graph.
render(d3.select('svg g'), g);

Graph Layout

This feature allows you to define the layout of the graph. The code sample demonstrates how to set the layout direction to 'LR' (left-to-right) and apply it to the graph.

const dagreD3 = require('dagre-d3-es');
const graphlib = require('graphlib');

// Create a new directed graph
const g = new graphlib.Graph().setGraph({});

// Add nodes and edges
g.setNode('A', { label: 'Node A' });
g.setNode('B', { label: 'Node B' });
g.setEdge('A', 'B');

// Set layout options
const layout = dagreD3.layout().rankDir('LR');

// Apply the layout to the graph
layout(g);

console.log(g.nodes()); // ['A', 'B']
console.log(g.edges()); // [{ v: 'A', w: 'B' }]

Other packages similar to dagre-d3-es

Keywords

FAQs

Package last updated on 24 Feb 2023

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