Convert Figma logo to code with AI

jsplumb logojsplumb

Visual connectivity for webapps

7,735
1,450
7,735
0

Top Related Projects

11,199

A JavaScript library aimed at visualizing graphs of thousands of nodes and edges

7,849

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs

Graph theory (network) library for visualisation and analysis

4,593

Directed graph layout for JavaScript

:dizzy: Display dynamic, automatically organised, customizable network views.

11,025

♾ A Graph Visualization Framework in JavaScript.

Quick Overview

jsPlumb is a JavaScript library that provides a means to visually connect elements on web pages. It allows developers to create interactive diagrams, flowcharts, and network visualizations by drawing SVG or Canvas connections between DOM elements. jsPlumb is highly customizable and supports various types of connectors, endpoints, and overlays.

Pros

  • Highly flexible and customizable, allowing for a wide range of visual styles and behaviors
  • Supports both SVG and Canvas rendering for broad browser compatibility
  • Extensive documentation and active community support
  • Offers a toolkit edition with additional features for enterprise applications

Cons

  • Learning curve can be steep for complex implementations
  • Performance may degrade with a large number of connections
  • Some users report occasional positioning issues with dynamically added elements
  • Limited built-in layout algorithms for automatic arrangement of elements

Code Examples

  1. Creating a simple connection:
jsPlumb.ready(function() {
    jsPlumb.connect({
        source: "element1",
        target: "element2",
        anchor: ["Left", "Right"]
    });
});
  1. Adding draggable elements:
jsPlumb.ready(function() {
    jsPlumb.draggable("element1");
    jsPlumb.draggable("element2");
});
  1. Customizing connection appearance:
jsPlumb.ready(function() {
    jsPlumb.connect({
        source: "element1",
        target: "element2",
        paintStyle: { stroke: "#456", strokeWidth: 3 },
        endpointStyle: { fill: "#456", outlineStroke: "black", outlineWidth: 1 }
    });
});
  1. Adding connection labels:
jsPlumb.ready(function() {
    jsPlumb.connect({
        source: "element1",
        target: "element2",
        overlays: [
            ["Label", { label: "Connection Label", location: 0.5 }]
        ]
    });
});

Getting Started

To get started with jsPlumb, follow these steps:

  1. Include the jsPlumb library in your HTML file:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jsplumb/2.15.6/js/jsplumb.min.js"></script>
    
  2. Create DOM elements to connect:

    <div id="element1">Element 1</div>
    <div id="element2">Element 2</div>
    
  3. Initialize jsPlumb and create a connection:

    jsPlumb.ready(function() {
        jsPlumb.connect({
            source: "element1",
            target: "element2"
        });
    });
    

This basic setup will create a simple connection between two elements. You can then customize the appearance and behavior of the connection using jsPlumb's extensive API.

Competitor Comparisons

11,199

A JavaScript library aimed at visualizing graphs of thousands of nodes and edges

Pros of sigma.js

  • Specialized for graph and network visualization
  • Highly performant for rendering large-scale graphs
  • Extensive customization options for node and edge styling

Cons of sigma.js

  • Limited to graph-based visualizations
  • Steeper learning curve for non-graph-specific use cases
  • Less suitable for general-purpose diagramming

Code Comparison

sigma.js:

var s = new sigma({
  graph: {
    nodes: [
      { id: "n1", label: "Node 1" },
      { id: "n2", label: "Node 2" }
    ],
    edges: [
      { id: "e1", source: "n1", target: "n2" }
    ]
  },
  container: 'graph-container'
});

jsPlumb:

jsPlumb.ready(function() {
  jsPlumb.connect({
    source: "element1",
    target: "element2",
    anchor: ["Top", "Bottom"]
  });
});

sigma.js is focused on graph rendering, with nodes and edges defined in a data structure. jsPlumb, on the other hand, connects DOM elements directly, making it more suitable for general diagramming and UI-based connections. sigma.js excels in large-scale graph visualization, while jsPlumb offers more flexibility for diverse diagramming needs.

7,849

⚠️ This project is not maintained anymore! Please go to https://github.com/visjs

Pros of vis

  • More comprehensive data visualization capabilities, including networks, timelines, and graphs
  • Larger and more active community, with frequent updates and contributions
  • Extensive documentation and examples for various use cases

Cons of vis

  • Steeper learning curve due to its broader feature set
  • Larger file size, which may impact page load times for simpler projects
  • Less focused on connection-based visualizations compared to jsPlumb

Code Comparison

vis:

var nodes = new vis.DataSet([
  {id: 1, label: 'Node 1'},
  {id: 2, label: 'Node 2'}
]);
var edges = new vis.DataSet([
  {from: 1, to: 2}
]);
var network = new vis.Network(container, {nodes: nodes, edges: edges}, options);

jsPlumb:

jsPlumb.ready(function() {
  var instance = jsPlumb.getInstance();
  instance.connect({
    source: "element1",
    target: "element2",
    anchor: ["Top", "Bottom"]
  });
});

Both libraries offer ways to create connections between elements, but vis provides a more data-driven approach with its DataSet objects, while jsPlumb focuses on DOM-based connections with a more straightforward API for basic connection scenarios.

Graph theory (network) library for visualisation and analysis

Pros of Cytoscape.js

  • More powerful graph theory algorithms and analysis capabilities
  • Better performance for large-scale networks and complex visualizations
  • Extensive documentation and active community support

Cons of Cytoscape.js

  • Steeper learning curve for basic usage compared to jsPlumb
  • Less intuitive for simple drag-and-drop diagramming tasks
  • May be overkill for projects that don't require advanced graph features

Code Comparison

jsPlumb:

jsPlumb.ready(function() {
  jsPlumb.connect({
    source: "element1",
    target: "element2",
    anchor: ["Top", "Bottom"]
  });
});

Cytoscape.js:

var cy = cytoscape({
  container: document.getElementById('cy'),
  elements: [
    { data: { id: 'element1' } },
    { data: { id: 'element2' } },
    { data: { source: 'element1', target: 'element2' } }
  ]
});

Both libraries allow for creating connections between elements, but Cytoscape.js uses a more data-driven approach, defining nodes and edges as part of the graph structure. jsPlumb focuses on DOM elements and provides a simpler API for basic connection tasks, while Cytoscape.js offers more flexibility and power for complex graph visualizations and analysis.

4,593

Directed graph layout for JavaScript

Pros of dagre

  • Specialized in directed graph layouts, offering efficient algorithms for complex graph structures
  • Lightweight and focused on graph layout, making it easier to integrate with other visualization libraries
  • Better performance for large graphs with many nodes and edges

Cons of dagre

  • Limited to graph layout calculations, requiring additional libraries for rendering and interactivity
  • Less out-of-the-box functionality for connecting and manipulating elements compared to jsPlumb
  • Steeper learning curve for users not familiar with graph theory concepts

Code Comparison

dagre:

var g = new dagre.graphlib.Graph();
g.setNode("A", { label: "Node A" });
g.setNode("B", { label: "Node B" });
g.setEdge("A", "B");
dagre.layout(g);

jsPlumb:

jsPlumb.ready(function() {
  jsPlumb.connect({
    source: "elementA",
    target: "elementB",
    anchor: "AutoDefault"
  });
});

Summary

dagre excels in graph layout calculations, offering better performance for complex graphs. However, it requires additional libraries for rendering and interaction. jsPlumb provides a more comprehensive solution for connecting and manipulating DOM elements but may be less efficient for large-scale graph layouts.

:dizzy: Display dynamic, automatically organised, customizable network views.

Pros of vis-network

  • More focused on network visualization and graph layouts
  • Offers a wider range of graph algorithms and analysis tools
  • Better performance for large-scale networks with thousands of nodes

Cons of vis-network

  • Steeper learning curve due to more complex API
  • Less flexible for general-purpose diagramming and flowcharting
  • Limited built-in support for custom node and edge styles

Code Comparison

vis-network:

var nodes = new vis.DataSet([
  {id: 1, label: 'Node 1'},
  {id: 2, label: 'Node 2'}
]);
var edges = new vis.DataSet([
  {from: 1, to: 2}
]);
var network = new vis.Network(container, {nodes: nodes, edges: edges}, options);

jsPlumb:

jsPlumb.ready(function() {
  var instance = jsPlumb.getInstance();
  instance.connect({
    source: "element1",
    target: "element2",
    anchor: ["Top", "Bottom"]
  });
});

vis-network is better suited for complex network visualizations and graph analysis, while jsPlumb excels in creating interactive, drag-and-drop diagramming interfaces with more customization options for connections. The code examples demonstrate the different approaches: vis-network uses datasets and a network object, while jsPlumb focuses on connecting DOM elements directly.

11,025

♾ A Graph Visualization Framework in JavaScript.

Pros of G6

  • More comprehensive graph visualization capabilities, including various layouts and graph algorithms
  • Better performance for large-scale graph rendering
  • Extensive documentation and examples for different use cases

Cons of G6

  • Steeper learning curve due to its extensive feature set
  • Less focused on connection-based diagrams compared to jsPlumb

Code Comparison

G6 example:

const graph = new G6.Graph({
  container: 'mountNode',
  width: 800,
  height: 600,
});

graph.data(data);
graph.render();

jsPlumb example:

const instance = jsPlumb.getInstance();
instance.connect({
  source: 'element1',
  target: 'element2',
  anchor: ['Left', 'Right'],
});

G6 is more suited for complex graph visualizations with various layouts and algorithms, while jsPlumb excels in creating connection-based diagrams with a simpler API. G6 offers better performance for large-scale graphs but may require more time to learn. jsPlumb is easier to get started with for basic connection diagrams but may have limitations for more advanced graph visualizations.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

jsPlumb

As of October 2023, the Community Edition of jsPlumb has a new home: https://github.com/jsplumb/community-edition.

We've transferred all open and closed issues to that repository. The issue tracker on this repository is now closed. Any new issues should be opened in the new repository.

https://jsplumbtoolkit.com

NPM DownloadsLast 30 Days