0.0.6 โ€ข Published 3 months ago

nodeflow-lib v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

NodeFlow GitHub activity Static Badge

A library that aims to provide everything needed for making flowcharts, graphs, diagrams, and other similar things using a simple and intuitive API.\ Currently, NodeFlow is built using SolidJS, but there are plans to make it framework-agnostic in the future.

Features

  • ๐Ÿ” Zooming and panning
  • ๐Ÿคš Dragging, selecting, and connecting nodes
  • ๐ŸŽจ Fully customizable styling for every element (nodes, connectors, connector-sections, etc.)
  • ๐Ÿ“ฆ Customizable node content
  • ๐Ÿ“’ History (undo/redo)
  • โคต๏ธ Connection curves

Installation

npm install nodeflow

Usage

๐Ÿ“š The Wiki page covers most of the features of NodeFlow.

Below is a simple example that covers adding 2 nodes and connecting them:

import { NodeflowLib } from "nodeflow-lib";

// Create a canvas with id "main".
// nodeflowData contains the data of the canvas
// Nodeflow is the canvas element (currently a SolidJS component)
const [nodeflowData, Nodeflow] = NodeflowLib.get().createCanvas("main");

// create the nodes
const sourceNode = nodeflowData.addNode({
  position: { x: 100, y: 100 },
  content: (nodeData) => <div>{nodeData.position}</div>,
});
const destinationNode = nodeflowData.addNode({
  position: { x: 400, y: 400 },
  content: (nodeData) => <div>Node 2!</div>,
});

// add a connector section to the nodes
const outputSection = sourceNode.addConnectorSection({ id: "output" });
const inputSection = node2.addConnectorSection({ id: "input" });

// add a connector to each connector section
outputSection.addConnector({ id: "source-connector" });
connectorSection2.addConnector({ id: "target-connector" });

// connect the connectors
nodeflowData.addConnection({
  sourceNodeId: sourceNode.id,
  sourceConnectorId: "source-connector",
  destinationNodeId: destinationNode.id,
  destinationConnectorId: "target-connector",
});

For rendering the canvas, you just use the Nodeflow component:

<Nodeflow width="800px" height="800px" />

Examples

There are 2 example projects: ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ a FamilyTree App and ๐Ÿ“˜ a Blueprint App.\ You can check them out in action here.

0.0.6

3 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

5 months ago

0.0.1-a12

5 months ago

0.0.1-a13

5 months ago

0.0.1-a10

5 months ago

0.0.1-a11

5 months ago

0.0.1-a16

5 months ago

0.0.1-a14

5 months ago

0.0.1-a15

5 months ago

0.0.1

5 months ago

0.0.2

5 months ago

0.0.1-a9

5 months ago

0.0.1-a2

5 months ago

0.0.1-a4

5 months ago

0.0.1-a3

5 months ago

0.0.1-a6

5 months ago

0.0.1-a5

5 months ago

0.0.1-a8

5 months ago

0.0.1-a7

5 months ago

0.0.1-a1

5 months ago