mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-19 16:26:43 +02:00
MC-5237 Updates from review
This commit is contained in:
@@ -464,6 +464,13 @@ export const render = async (data4Layout: LayoutData, svg, element, algorithm) =
|
|||||||
'elk.layered.mergeEdges': data4Layout.config['elk.mergeEdges'],
|
'elk.layered.mergeEdges': data4Layout.config['elk.mergeEdges'],
|
||||||
'elk.direction': 'DOWN',
|
'elk.direction': 'DOWN',
|
||||||
'spacing.baseValue': 30,
|
'spacing.baseValue': 30,
|
||||||
|
// 'spacing.nodeNode': 40,
|
||||||
|
// 'spacing.nodeNodeBetweenLayers': 45,
|
||||||
|
// 'spacing.edgeNode': 40,
|
||||||
|
// 'spacing.edgeNodeBetweenLayers': 30,
|
||||||
|
// 'spacing.edgeEdge': 30,
|
||||||
|
// 'spacing.edgeEdgeBetweenLayers': 40,
|
||||||
|
// 'spacing.nodeSelfLoop': 50,
|
||||||
},
|
},
|
||||||
children: [],
|
children: [],
|
||||||
edges: [],
|
edges: [],
|
||||||
|
@@ -37,10 +37,11 @@ export const draw = async function (text: string, id: string, _version: string,
|
|||||||
log.debug('Data: ', data4Layout);
|
log.debug('Data: ', data4Layout);
|
||||||
// Create the root SVG - the element is the div containing the SVG element
|
// Create the root SVG - the element is the div containing the SVG element
|
||||||
const { element, svg } = getDiagramElements(id, securityLevel);
|
const { element, svg } = getDiagramElements(id, securityLevel);
|
||||||
|
const direction = getDirection();
|
||||||
|
|
||||||
data4Layout.type = diag.type;
|
data4Layout.type = diag.type;
|
||||||
data4Layout.layoutAlgorithm = layout;
|
data4Layout.layoutAlgorithm = layout;
|
||||||
data4Layout.direction = getDirection();
|
data4Layout.direction = direction;
|
||||||
data4Layout.nodeSpacing = conf?.nodeSpacing || 50;
|
data4Layout.nodeSpacing = conf?.nodeSpacing || 50;
|
||||||
data4Layout.rankSpacing = conf?.rankSpacing || 50;
|
data4Layout.rankSpacing = conf?.rankSpacing || 50;
|
||||||
data4Layout.markers = ['point', 'circle', 'cross'];
|
data4Layout.markers = ['point', 'circle', 'cross'];
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
|
import { insertNode } from '../dagre-wrapper/nodes.js';
|
||||||
|
|
||||||
export const getDiagramElements = (id, securityLevel) => {
|
export const getDiagramElements = (id, securityLevel) => {
|
||||||
let sandboxElement;
|
let sandboxElement;
|
||||||
@@ -18,3 +19,36 @@ export const getDiagramElements = (id, securityLevel) => {
|
|||||||
const element = root.select('#' + id + ' g');
|
const element = root.select('#' + id + ' g');
|
||||||
return { svg, element };
|
return { svg, element };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function insertElementsForSize(el, data) {
|
||||||
|
const nodesElem = el.insert('g').attr('class', 'nodes');
|
||||||
|
el.insert('g').attr('class', 'edges');
|
||||||
|
data.nodes.forEach(async (item) => {
|
||||||
|
item.shape = 'rect';
|
||||||
|
await insertNode(nodesElem, {
|
||||||
|
...item,
|
||||||
|
class: 'default flowchart-label',
|
||||||
|
labelStyle: '',
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
width: 100,
|
||||||
|
rx: 0,
|
||||||
|
ry: 0,
|
||||||
|
height: 100,
|
||||||
|
shape: 'rect',
|
||||||
|
padding: 8,
|
||||||
|
});
|
||||||
|
// Create a new DOM element
|
||||||
|
// const element = document.createElement('div');
|
||||||
|
|
||||||
|
// // Set the content of the element to the name of the item
|
||||||
|
// element.textContent = item.name;
|
||||||
|
|
||||||
|
// // Set the size of the element to the size of the item
|
||||||
|
// element.style.width = `${item.size}px`;
|
||||||
|
// element.style.height = `${item.size}px`;
|
||||||
|
|
||||||
|
// Append the element to the body of the document
|
||||||
|
// document.body.appendChild(element);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@@ -520,6 +520,15 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
|
|||||||
}
|
}
|
||||||
// This is the accessor function we talked about above
|
// This is the accessor function we talked about above
|
||||||
let curve = curveBasis;
|
let curve = curveBasis;
|
||||||
|
// curve = curveCardinal;
|
||||||
|
// curve = curveLinear;
|
||||||
|
// curve = curveNatural;
|
||||||
|
// curve = curveCatmullRom.alpha(0.5);
|
||||||
|
// curve = curveCatmullRom;
|
||||||
|
// curve = curveCardinal.tension(0.7);
|
||||||
|
// curve = curveMonotoneY;
|
||||||
|
// let curve = interpolateToCurve([5], curveNatural, 0.01, 10);
|
||||||
|
|
||||||
// Currently only flowcharts get the curve from the settings, perhaps this should
|
// Currently only flowcharts get the curve from the settings, perhaps this should
|
||||||
// be expanded to a common setting? Restricting it for now in order not to cause side-effects that
|
// be expanded to a common setting? Restricting it for now in order not to cause side-effects that
|
||||||
// have not been thought through
|
// have not been thought through
|
||||||
@@ -528,6 +537,7 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { x, y } = getLineFunctionsWithOffset(edge);
|
const { x, y } = getLineFunctionsWithOffset(edge);
|
||||||
|
// const lineFunction = edge.curve ? line().x(x).y(y).curve(curve) : roundedCornersLine;
|
||||||
const lineFunction = line().x(x).y(y).curve(curve);
|
const lineFunction = line().x(x).y(y).curve(curve);
|
||||||
|
|
||||||
// Construct stroke classes based on properties
|
// Construct stroke classes based on properties
|
||||||
@@ -563,6 +573,11 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
|
|||||||
if (edge.look === 'handdrawn') {
|
if (edge.look === 'handdrawn') {
|
||||||
const rc = rough.svg(elem);
|
const rc = rough.svg(elem);
|
||||||
Object.assign([], lineData);
|
Object.assign([], lineData);
|
||||||
|
// const svgPathNode = rc.path(lineFunction(ld.splice(0, ld.length-1)), {
|
||||||
|
// const svgPathNode = rc.path(lineFunction(ld), {
|
||||||
|
// roughness: 0.3,
|
||||||
|
// seed: handdrawnSeed,
|
||||||
|
// });
|
||||||
const svgPathNode = rc.path(linePath, {
|
const svgPathNode = rc.path(linePath, {
|
||||||
roughness: 0.3,
|
roughness: 0.3,
|
||||||
seed: handdrawnSeed,
|
seed: handdrawnSeed,
|
||||||
@@ -572,6 +587,7 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod
|
|||||||
|
|
||||||
svgPath = select(svgPathNode)
|
svgPath = select(svgPathNode)
|
||||||
.select('path')
|
.select('path')
|
||||||
|
// .attr('d', lineFunction(lineData))
|
||||||
.attr('id', edge.id)
|
.attr('id', edge.id)
|
||||||
.attr('class', ' ' + strokeClasses + (edge.classes ? ' ' + edge.classes : ''))
|
.attr('class', ' ' + strokeClasses + (edge.classes ? ' ' + edge.classes : ''))
|
||||||
.attr('style', edge.style);
|
.attr('style', edge.style);
|
||||||
|
Reference in New Issue
Block a user