Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Smetannikov committed Dec 12, 2019
1 parent 22d4f9a commit 188e496
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
# JBZoo Mermaid-PHP [![Build Status](https://travis-ci.org/JBZoo/mermaid-php.svg?branch=master)](https://travis-ci.org/JBZoo/mermaid-php) [![Coverage Status](https://coveralls.io/repos/github/JBZoo/Mermaid-PHP/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/Mermaid-PHP?branch=master)

Example
### Usage

```php
<?php

use JBZoo\MermaidPHP\Graph;
use JBZoo\MermaidPHP\Link;
use JBZoo\MermaidPHP\Node;

$graph = new Graph();
$graph->addNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE));
$graph->addNode($nodeB = new Node('B', 'Round edge', Node::ROUND));
$graph->addNode($nodeC = new Node('C', 'Decision', Node::RHOMBUS));
$graph->addNode($nodeD = new Node('D', 'Result one', Node::SQUARE));
$graph->addNode($nodeE = new Node('E', 'Result two', Node::SQUARE));
$graph = (new Graph())
->addNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE))
->addNode($nodeB = new Node('B', 'Round edge', Node::ROUND))
->addNode($nodeC = new Node('C', 'Decision', Node::RHOMBUS))
->addNode($nodeD = new Node('D', 'Result one', Node::SQUARE))
->addNode($nodeE = new Node('E', 'Result two', Node::SQUARE))
->addLink(new Link($nodeA, $nodeB, 'Link text'))
->addLink(new Link($nodeB, $nodeC))
->addLink(new Link($nodeC, $nodeD, 'One'))
->addLink(new Link($nodeC, $nodeE, 'Two'))
->addStyle('linkStyle default interpolate basis');

echo $graph; // Get result as string
$graph->renderHtml(true, '8.4.3'); // Get result as HTML code for debugging
```

$graph->addLink(new Link($nodeA, $nodeB, 'Link text'));
$graph->addLink(new Link($nodeB, $nodeC));
$graph->addLink(new Link($nodeC, $nodeD, 'One'));
$graph->addLink(new Link($nodeC, $nodeE, 'Two'));
### Result

echo $graph;
```
[Mermaid Live Editor](https://mermaidjs.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggTFI7XG4gICAgQVtcIkhhcmQgZWRnZVwiXTtcbiAgICBCKFwiUm91bmQgZWRnZVwiKTtcbiAgICBDe1wiRGVjaXNpb25cIn07XG4gICAgRFtcIlJlc3VsdCBvbmVcIl07XG4gICAgRVtcIlJlc3VsdCB0d29cIl07XG4gICAgQS0tPnxMaW5rIHRleHR8QjtcbiAgICBCLS0-QztcbiAgICBDLS0-fE9uZXxEO1xuICAgIEMtLT58VHdvfEU7XG5saW5rU3R5bGUgZGVmYXVsdCBpbnRlcnBvbGF0ZSBiYXNpczsiLCJtZXJtYWlkIjp7InRoZW1lIjoiZm9yZXN0In19)

Result
```
graph LR;
A["Hard edge"];
Expand All @@ -34,8 +40,12 @@ graph LR;
B-->C;
C-->|One|D;
C-->|Two|E;
linkStyle default interpolate basis
```

### See also
- [Mermaid on GitHub](https://github.com/knsv/mermaid)
- [Mermaid Documentation](https://mermaidjs.github.io/)

## Unit tests and check code style
```sh
Expand Down
23 changes: 11 additions & 12 deletions tests/FlowchartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,17 @@ public function testSimpleGraph()

public function testComplexGraph()
{
$graph = new Graph();
$graph->addNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE));
$graph->addNode($nodeB = new Node('B', 'Round edge', Node::ROUND));
$graph->addNode($nodeC = new Node('C', 'Decision', Node::RHOMBUS));
$graph->addNode($nodeD = new Node('D', 'Result one', Node::SQUARE));
$graph->addNode($nodeE = new Node('E', 'Result two', Node::SQUARE));

$graph->addLink(new Link($nodeA, $nodeB, 'Link text'));
$graph->addLink(new Link($nodeB, $nodeC));
$graph->addLink(new Link($nodeC, $nodeD, 'One'));
$graph->addLink(new Link($nodeC, $nodeE, 'Two'));
$graph->addStyle('linkStyle default interpolate basis');
$graph = (new Graph())
->addNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE))
->addNode($nodeB = new Node('B', 'Round edge', Node::ROUND))
->addNode($nodeC = new Node('C', 'Decision', Node::RHOMBUS))
->addNode($nodeD = new Node('D', 'Result one', Node::SQUARE))
->addNode($nodeE = new Node('E', 'Result two', Node::SQUARE))
->addLink(new Link($nodeA, $nodeB, 'Link text'))
->addLink(new Link($nodeB, $nodeC))
->addLink(new Link($nodeC, $nodeD, 'One'))
->addLink(new Link($nodeC, $nodeE, 'Two'))
->addStyle('linkStyle default interpolate basis');

$this->dumpHtml($graph);

Expand Down

0 comments on commit 188e496

Please sign in to comment.