This commit is contained in:
Knut Sveidqvist
2020-07-21 11:15:42 +02:00
parent a6ec038189
commit 211d6f4005
2 changed files with 27 additions and 6 deletions

View File

@@ -1,13 +1,29 @@
import mermaid from '../../dist/mermaid.core';
const code = `graph LR
let code = `flowchart LR
Power_Supply --> Transmitter_A
Power_Supply --> Transmitter_B
Transmitter_A --> D
Transmitter_B --> D`;
let code2 = `gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d`;
mermaid.initialize({
theme: 'forest',
theme: 'default',
fontFamily: '"Lucida Console", Monaco, monospace',
startOnLoad: false,
flowchart: {

View File

@@ -16,10 +16,15 @@ function intersectPolygon(node, polyPoints, point) {
var minX = Number.POSITIVE_INFINITY;
var minY = Number.POSITIVE_INFINITY;
polyPoints.forEach(function(entry) {
minX = Math.min(minX, entry.x);
minY = Math.min(minY, entry.y);
});
if (typeof polyPoints.forEach === 'function') {
polyPoints.forEach(function(entry) {
minX = Math.min(minX, entry.x);
minY = Math.min(minY, entry.y);
});
} else {
minX = Math.min(minX, polyPoints.x);
minY = Math.min(minY, polyPoints.y);
}
var left = x1 - node.width / 2 - minX;
var top = y1 - node.height / 2 - minY;