#1295 Arrow head start

This commit is contained in:
Knut Sveidqvist
2020-03-14 18:13:34 +01:00
parent 9266eaef16
commit 5b74d75011
5 changed files with 59 additions and 5 deletions

View File

@@ -87,7 +87,7 @@
end end
b-->id1 b-->id1
</div> </div>
<div class="mermaid" style="width: 100%; height: 100%"> <div class="mermaid2" style="width: 100%; height: 100%">
flowchart RL flowchart RL
subgraph id1 [Test1] subgraph id1 [Test1]
@@ -101,6 +101,10 @@
b-->id1 b-->id1
id1 --> id2 id1 --> id2
</div> </div>
<div class="mermaid" style="width: 100%; height: 100%">
flowchart LR
a o--o b
</div>
</div> </div>
<script src="./mermaid.js"></script> <script src="./mermaid.js"></script>

View File

@@ -36,3 +36,8 @@ This is set by the renderer of the diagram and insert the data that the wrapper
| id | id of the shape | | id | id of the shape |
| type | if set to group then this node indicates a cluster. | | type | if set to group then this node indicates a cluster. |
| padding | Padding. Passed from the renderr as this might differ between react for different diagrams. Maybe obsolete. | | padding | Padding. Passed from the renderr as this might differ between react for different diagrams. Maybe obsolete. |
#edge
arrowType sets the type of arrows to use

View File

@@ -169,7 +169,7 @@ export const insertEdge = function(elem, edge, clusterDb) {
points = updatedPoints; points = updatedPoints;
} }
logger.info('Points', points); logger.info('Edge', edge);
// The data for our line // The data for our line
const lineData = points.filter(p => !Number.isNaN(p.y)); const lineData = points.filter(p => !Number.isNaN(p.y));
@@ -212,7 +212,13 @@ export const insertEdge = function(elem, edge, clusterDb) {
url = url.replace(/\(/g, '\\('); url = url.replace(/\(/g, '\\(');
url = url.replace(/\)/g, '\\)'); url = url.replace(/\)/g, '\\)');
} }
switch (edge.arrowType) {
svgPath.attr('marker-end', 'url(' + url + '#' + 'normalEnd' + ')'); case 'double_arrow_circle':
// svgPath.attr('marker-start', 'url(' + url + '#' + 'normalStart' + ')'); svgPath.attr('marker-end', 'url(' + url + '#' + 'circleEnd' + ')');
svgPath.attr('marker-start', 'url(' + url + '#' + 'circleStart' + ')');
break;
case 'arrow_circle':
svgPath.attr('marker-end', 'url(' + url + '#' + 'circleEnd' + ')');
break;
}
}; };

View File

@@ -132,6 +132,43 @@ const insertMarkers = elem => {
.attr('class', 'arrowheadPath') .attr('class', 'arrowheadPath')
.style('stroke-width', 1) .style('stroke-width', 1)
.style('stroke-dasharray', '1,0'); .style('stroke-dasharray', '1,0');
elem
.append('marker')
.attr('id', 'circleEnd')
.attr('viewBox', '0 0 10 10')
.attr('refX', 10)
.attr('refY', 5)
.attr('markerUnits', 'strokeWidth')
.attr('markerWidth', 7)
.attr('markerHeight', 7)
.attr('orient', 'auto')
.append('circle')
.attr('cx', '5')
.attr('cy', '5')
.attr('r', '5')
.attr('fill', 'red')
.attr('class', 'arrowheadPath')
.style('stroke-width', 1)
.style('stroke-dasharray', '1,0');
elem
.append('marker')
.attr('id', 'circleStart')
.attr('viewBox', '0 0 10 10')
.attr('refX', 0)
.attr('refY', 5)
.attr('markerUnits', 'strokeWidth')
.attr('markerWidth', 7)
.attr('markerHeight', 7)
.attr('orient', 'auto')
.append('circle')
.attr('cx', '5')
.attr('cy', '5')
.attr('r', '5')
.attr('fill', 'red')
.attr('class', 'arrowheadPath')
.style('stroke-width', 1)
.style('stroke-dasharray', '1,0');
}; };
export default insertMarkers; export default insertMarkers;

View File

@@ -174,6 +174,7 @@ export const addEdges = function(edges, g) {
} else { } else {
edgeData.arrowhead = 'normal'; edgeData.arrowhead = 'normal';
} }
edgeData.arrowType = edge.type;
let style = ''; let style = '';
let labelStyle = ''; let labelStyle = '';
@@ -311,6 +312,7 @@ export const draw = function(text, id) {
const edges = flowDb.getEdges(); const edges = flowDb.getEdges();
logger.info(edges);
let i = 0; let i = 0;
for (i = subGraphs.length - 1; i >= 0; i--) { for (i = subGraphs.length - 1; i >= 0; i--) {
subG = subGraphs[i]; subG = subGraphs[i];