Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
antirek committed Mar 1, 2020
1 parent 53d6ab4 commit 3e9078b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
1. Добавьте в ваш html загрузку скрипта

`````javascript
<script src="https://unpkg.com/@antirek/network-diagram@0.1.3/dist/code-full.min.js"></script>
<script src="https://unpkg.com/@antirek/network-diagram@0.1.4/dist/code-full.min.js"></script>

`````
2. Добавьте div для схемы, задав ширину и высоту
Expand Down Expand Up @@ -66,7 +66,7 @@

Весь этот код в одном файле [example.html](examples/example.html)

## Опции
## Позиционирование nodes

Для отрисовки схемы используется [cytoscape.js](https://js.cytoscape.org/). Схема отрисовывается в двух режимах: auto и grid. Для grid режима необходимо указать positions. Positions - это список элементов с указанием строки и колонки их расположения. Явное указание positions позволяет точно зафиксировать вид схемы.

Expand All @@ -78,6 +78,7 @@
{ id: 'server', row: 2, col: 4, },
{ id: 'db1', row: 1, col: 5, },
{ id: 'db2', row: 3, col: 5, },
{ id: 'db2', p: 'b7', }, // указываем позицию а-ля Морской бой
]
`````

Expand All @@ -88,8 +89,8 @@
nodes: [
{ id: 'client', type: 'smartphone', label: 'Mobile App'},
{ id: 'server', type: 'server', label: 'Main Server'},
{ id: 'db1', type: 'database', group: 'db cluster', label: 'DB 1'},
{ id: 'db2', type: 'database', group: 'db cluster', label: 'DB 2'},
{ id: 'db1', type: 'database', label: 'DB 1'},
{ id: 'db2', type: 'database', label: 'DB 2'},
],
edges: [
{ source: 'client', target: 'server', label: 'request' },
Expand Down Expand Up @@ -162,7 +163,6 @@

![](examples/example2.png)


## Онлайн редактор

https://antirek.github.io/network-diagram-editor/
Expand Down
3 changes: 2 additions & 1 deletion code.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const Diagram = function(id, elements, options) {
// version 0.1.3
// version 0.1.4
let edges;
let nodes;
let groups;
Expand Down Expand Up @@ -71,6 +71,7 @@ const Diagram = function(id, elements, options) {
};

const addNodes = function(nodesIn) {
if (!nodesIn) return;
nodes = nodesIn.map((item)=> {
return {data: {
id: item.id,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antirek/network-diagram",
"version": "0.1.3",
"version": "0.1.4",
"description": "simple network diagram so fast as write two lines of code ;)",
"main": "dist/code-full.min.js",
"scripts": {
Expand Down

0 comments on commit 3e9078b

Please sign in to comment.