Bug fixes in new functionality, intersections not taken into account in nodes used by new graph engine. Graph flowchart not usable when integrating using mermaid.core. Incorrect flwochart docs

This commit is contained in:
Knut Sveidqvist
2020-05-16 19:58:22 +02:00
parent 0ac48a431a
commit c21b61bbd2
6 changed files with 70 additions and 54 deletions

View File

@@ -39,7 +39,7 @@
G-->H G-->H
G-->c G-->c
</div> </div>
<div class="mermaid" style="width: 50%; height: 20%;"> <div class="mermaid2" style="width: 50%; height: 20%;">
flowchart LR flowchart LR
A{{A}}-->B{{B}}; A{{A}}-->B{{B}};
click A callback "Tooltip" click A callback "Tooltip"
@@ -47,8 +47,12 @@ flowchart LR
</div> </div>
<div class="mermaid" style="width: 50%; height: 20%;"> <div class="mermaid" style="width: 50%; height: 20%;">
flowchart LR flowchart TD
A{{A}}-->B{{B}}; A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
</div> </div>
<div class="mermaid2" style="width: 50%; height: 20%;"> <div class="mermaid2" style="width: 50%; height: 20%;">

View File

@@ -65,7 +65,7 @@ graph LR
id1[This is the text in the box] id1[This is the text in the box]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1[This is the text in the box] id1[This is the text in the box]
``` ```
@@ -73,66 +73,66 @@ flowchart LR
### A node with round edges ### A node with round edges
``` ```
flowchart LR graph LR
id1(This is the text in the box) id1(This is the text in the box)
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1(This is the text in the box) id1(This is the text in the box)
``` ```
### A stadium-shaped node ### A stadium-shaped node
``` ```
flowchart LR graph LR
id1([This is the text in the box]) id1([This is the text in the box])
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1([This is the text in the box]) id1([This is the text in the box])
``` ```
### A node in a subroutine shape ### A node in a subroutine shape
``` ```
flowchart LR graph LR
id1[[This is the text in the box]] id1[[This is the text in the box]]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1[[This is the text in the box]] id1[[This is the text in the box]]
``` ```
### A node in a cylindrical shape ### A node in a cylindrical shape
``` ```
flowchart LR graph LR
id1[(Database)] id1[(Database)]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1[(Database)] id1[(Database)]
``` ```
### A node in the form of a circle ### A node in the form of a circle
``` ```
flowchart LR graph LR
id1((This is the text in the circle)) id1((This is the text in the circle))
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1((This is the text in the circle)) id1((This is the text in the circle))
``` ```
### A node in an asymetric shape ### A node in an asymetric shape
``` ```
flowchart LR graph LR
id1>This is the text in the box] id1>This is the text in the box]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1>This is the text in the box] id1>This is the text in the box]
``` ```
Currently only the shape above is possible and not its mirror. *This might change with future releases.* Currently only the shape above is possible and not its mirror. *This might change with future releases.*
@@ -140,22 +140,22 @@ Currently only the shape above is possible and not its mirror. *This might chang
### A node (rhombus) ### A node (rhombus)
``` ```
flowchart LR graph LR
id1{This is the text in the box} id1{This is the text in the box}
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1{This is the text in the box} id1{This is the text in the box}
``` ```
### A hexagon node ### A hexagon node
``` ```
flowchart LR graph LR
id1{{This is the text in the box}} id1{{This is the text in the box}}
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1{{This is the text in the box}} id1{{This is the text in the box}}
``` ```
@@ -209,22 +209,22 @@ Nodes can be connected with links/edges. It is possible to have different types
### A link with arrow head ### A link with arrow head
``` ```
flowchart LR graph LR
A-->B A-->B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A-->B A-->B
``` ```
### An open link ### An open link
``` ```
flowchart LR graph LR
A --- B A --- B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A --- B A --- B
``` ```
@@ -235,84 +235,84 @@ graph LR
A-- This is the text! ---B A-- This is the text! ---B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A-- This is the text ---B A-- This is the text ---B
``` ```
or or
``` ```
flowchart LR graph LR
A---|This is the text|B A---|This is the text|B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A---|This is the text|B A---|This is the text|B
``` ```
### A link with arrow head and text ### A link with arrow head and text
``` ```
flowchart LR graph LR
A-->|text|B A-->|text|B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A-->|text|B A-->|text|B
``` ```
or or
``` ```
flowchart LR graph LR
A-- text -->B A-- text -->B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A-- text -->B A-- text -->B
``` ```
### Dotted link ### Dotted link
``` ```
flowchart LR; graph LR;
A-.->B; A-.->B;
``` ```
```mermaid ```mermaid
flowchart LR; graph LR;
A-.->B; A-.->B;
``` ```
### Dotted link with text ### Dotted link with text
``` ```
flowchart LR graph LR
A-. text .-> B A-. text .-> B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A-. text .-> B A-. text .-> B
``` ```
### Thick link ### Thick link
``` ```
flowchart LR graph LR
A ==> B A ==> B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A ==> B A ==> B
``` ```
### Thick link with text ### Thick link with text
``` ```
flowchart LR graph LR
A == text ==> B A == text ==> B
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A == text ==> B A == text ==> B
``` ```
@@ -320,21 +320,21 @@ flowchart LR
It is possible declare many links in the same line as per below: It is possible declare many links in the same line as per below:
``` ```
flowchart LR graph LR
A -- text --> B -- text2 --> C A -- text --> B -- text2 --> C
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A -- text --> B -- text2 --> C A -- text --> B -- text2 --> C
``` ```
It is also possible to declare multiple nodes links in the same line as per below: It is also possible to declare multiple nodes links in the same line as per below:
``` ```
flowchart LR graph LR
a --> b & c--> d a --> b & c--> d
``` ```
```mermaid ```mermaid
flowchart LR graph LR
a --> b & c--> d a --> b & c--> d
``` ```
@@ -399,11 +399,11 @@ flowchart LR
It is possible to put text within quotes in order to render more troublesome characters. As in the example below: It is possible to put text within quotes in order to render more troublesome characters. As in the example below:
``` ```
flowchart LR graph LR
id1["This is the (text) in the box"] id1["This is the (text) in the box"]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
id1["This is the (text) in the box"] id1["This is the (text) in the box"]
``` ```
@@ -412,11 +412,11 @@ flowchart LR
It is possible to escape characters using the syntax examplified here. It is possible to escape characters using the syntax examplified here.
``` ```
flowchart LR graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"] A["A double quote:#quot;"] -->B["A dec char:#9829;"]
``` ```
```mermaid ```mermaid
flowchart LR graph LR
A["A double quote:#quot;"] -->B["A dec char:#9829;"] A["A double quote:#quot;"] -->B["A dec char:#9829;"]
``` ```
@@ -534,7 +534,7 @@ Examples of tooltip usage below:
``` ```
``` ```
flowchart LR; graph LR;
A-->B; A-->B;
click A callback "Tooltip for a callback" click A callback "Tooltip for a callback"
click B "http://www.github.com" "This is a tooltip for a link" click B "http://www.github.com" "This is a tooltip for a link"

View File

@@ -1,6 +1,6 @@
import { logger } from '../logger'; // eslint-disable-line import { logger } from '../logger'; // eslint-disable-line
import createLabel from './createLabel'; import createLabel from './createLabel';
import { line, curveBasis } from 'd3'; import { line, svg, curveBasis } from 'd3';
import { getConfig } from '../config'; import { getConfig } from '../config';
let edgeLabels = {}; let edgeLabels = {};
@@ -100,8 +100,19 @@ const intersection = (node, outsidePoint, insidePoint) => {
} }
}; };
export const insertEdge = function(elem, edge, clusterDb, diagramType) { //(edgePaths, e, edge, clusterDb, diagramtype, graph)
export const insertEdge = function(elem, e, edge, clusterDb, diagramType, graph) {
let points = edge.points; let points = edge.points;
const tail = graph.node(e.v);
var head = graph.node(e.w);
if (head.intersect && tail.intersect) {
points = points.slice(1, edge.points.length - 1);
points.unshift(tail.intersect(points[0]));
points.push(head.intersect(points[points.length - 1]));
}
if (edge.toCluster) { if (edge.toCluster) {
logger.trace('edge', edge); logger.trace('edge', edge);
logger.trace('to cluster', clusterDb[edge.toCluster]); logger.trace('to cluster', clusterDb[edge.toCluster]);

View File

@@ -124,7 +124,7 @@ const recursiveRender = (_elem, graph, diagramtype, parentCluster) => {
const edge = graph.edge(e); const edge = graph.edge(e);
log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(edge), edge); log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(edge), edge);
insertEdge(edgePaths, edge, clusterDb, diagramtype); insertEdge(edgePaths, e, edge, clusterDb, diagramtype, graph);
positionEdgeLabel(edge); positionEdgeLabel(edge);
}); });

View File

@@ -10,7 +10,7 @@ const question = (parent, node) => {
const w = bbox.width + node.padding; const w = bbox.width + node.padding;
const h = bbox.height + node.padding; const h = bbox.height + node.padding;
const s = (w + h) * 0.9; const s = w + h;
const points = [ const points = [
{ x: s / 2, y: 0 }, { x: s / 2, y: 0 },
{ x: s, y: -s / 2 }, { x: s, y: -s / 2 },
@@ -21,7 +21,8 @@ const question = (parent, node) => {
const questionElem = insertPolygonShape(shapeSvg, s, s, points); const questionElem = insertPolygonShape(shapeSvg, s, s, points);
updateNodeBounds(node, questionElem); updateNodeBounds(node, questionElem);
node.intersect = function(point) { node.intersect = function(point) {
return intersect.polugon(node, points, point); logger.warn('Intersect called');
return intersect.polygon(node, points, point);
}; };
return shapeSvg; return shapeSvg;

View File

@@ -551,7 +551,7 @@ function parse(text) {
break; break;
case 'flowchart-v2': case 'flowchart-v2':
flowDb.clear(); flowDb.clear();
parser = flowRendererV2; parser = flowParser;
parser.parser.yy = flowDb; parser.parser.yy = flowDb;
break; break;
case 'sequence': case 'sequence':