@html-graph/html-graph 3.21.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,85 +8,10 @@
8
8
  <img width="100%" src="https://raw.githubusercontent.com/html-graph/html-graph/master/media/full-demo.gif"/>
9
9
  </a>
10
10
 
11
- Visit the <a target="_blank" href="https://html-graph.github.io">DOCUMENTATION</a> for more details.
12
-
13
11
  ## Getting started:
14
12
 
15
13
  ```
16
14
  npm i @html-graph/html-graph
17
15
  ```
18
16
 
19
- ```javascript
20
- import { CanvasBuilder } from "@html-graph/html-graph";
21
-
22
- class Application {
23
- constructor(element) {
24
- this.canvas = new CanvasBuilder(element)
25
- .setDefaults({
26
- edges: {
27
- shape: {
28
- hasTargetArrow: true,
29
- },
30
- },
31
- })
32
- .enableUserDraggableNodes()
33
- .enableUserTransformableViewport()
34
- .enableBackground()
35
- .build();
36
- }
37
-
38
- initGraph() {
39
- this.canvas
40
- .addNode(
41
- this.createNode({
42
- name: "Node 1",
43
- x: 200,
44
- y: 400,
45
- frontPortId: "node-1-in",
46
- backPortId: "node-1-out",
47
- }),
48
- )
49
- .addNode(
50
- this.createNode({
51
- name: "Node 2",
52
- x: 600,
53
- y: 500,
54
- frontPortId: "node-2-in",
55
- backPortId: "node-2-out",
56
- }),
57
- )
58
- .addEdge({ from: "node-1-out", to: "node-2-in" });
59
- }
60
-
61
- createNode({ name, x, y, frontPortId, backPortId }) {
62
- const nodeElement = document.createElement("div");
63
- const text = document.createElement("div");
64
- const frontPortElement = document.createElement("div");
65
- const backPortElement = document.createElement("div");
66
-
67
- nodeElement.classList.add("node");
68
- frontPortElement.classList.add("port");
69
- backPortElement.classList.add("port");
70
- text.innerText = name;
71
-
72
- nodeElement.appendChild(frontPortElement);
73
- nodeElement.appendChild(text);
74
- nodeElement.appendChild(backPortElement);
75
-
76
- return {
77
- element: nodeElement,
78
- x: x,
79
- y: y,
80
- ports: [
81
- { id: frontPortId, element: frontPortElement },
82
- { id: backPortId, element: backPortElement },
83
- ],
84
- };
85
- }
86
- }
87
-
88
- const element = document.getElementById("canvas");
89
- const app = new Application(element);
90
-
91
- app.initGraph();
92
- ```
17
+ Visit the <a target="_blank" href="https://html-graph.github.io">DOCUMENTATION</a> for examples and API reference.