mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
Different hanlding of icons for circles
This commit is contained in:
@@ -92,9 +92,11 @@ mindmap
|
|||||||
GrandChild1
|
GrandChild1
|
||||||
GrandChild2
|
GrandChild2
|
||||||
Child3(Child 3 has a long wrapped text as well)
|
Child3(Child 3 has a long wrapped text as well)
|
||||||
|
::icon(mdi mdi-alarm)
|
||||||
GrandChild3
|
GrandChild3
|
||||||
GrandChild4
|
GrandChild4
|
||||||
Child4((Child Num 4<br>with<br>wrap text))
|
Child4((Child Num 4<br>with<br>wrap text))
|
||||||
|
::icon(mdi mdi-alarm)
|
||||||
GrandChild5[With<br>icon<br>one<br>two<br>three]
|
GrandChild5[With<br>icon<br>one<br>two<br>three]
|
||||||
::icon(mdi mdi-numeric-8-circle)
|
::icon(mdi mdi-numeric-8-circle)
|
||||||
GrandChild6sakdjhfkla jhklasjfh klj
|
GrandChild6sakdjhfkla jhklasjfh klj
|
||||||
@@ -372,7 +374,7 @@ flowchart TD
|
|||||||
};
|
};
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
// theme: 'dark',
|
// theme: 'dark',
|
||||||
// theme: 'base',
|
theme: 'base',
|
||||||
// arrowMarkerAbsolute: true,
|
// arrowMarkerAbsolute: true,
|
||||||
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
|
// themeCSS: '.edgePath .path {stroke: red;} .arrowheadPath {fill: red;}',
|
||||||
flowchart: {
|
flowchart: {
|
||||||
|
@@ -129,6 +129,30 @@ export const drawNode = function (elem, node, section, conf) {
|
|||||||
node.height = bbox.height + conf.fontSize * 1.1 * 0.5 + node.padding;
|
node.height = bbox.height + conf.fontSize * 1.1 * 0.5 + node.padding;
|
||||||
node.width = bbox.width + 2 * node.padding;
|
node.width = bbox.width + 2 * node.padding;
|
||||||
if (node.icon) {
|
if (node.icon) {
|
||||||
|
if (node.type === db.nodeType.CIRCLE) {
|
||||||
|
node.height += 50;
|
||||||
|
const orgWidth = node.width;
|
||||||
|
node.width += 50;
|
||||||
|
// node.width = Math.max(orgWidth, 100);
|
||||||
|
const widthDiff = Math.abs(node.width - orgWidth);
|
||||||
|
const icon = nodeElem
|
||||||
|
.append('foreignObject')
|
||||||
|
.attr('height', '50px')
|
||||||
|
.attr('width', node.width)
|
||||||
|
.attr('style', 'text-align: center;');
|
||||||
|
// .attr('x', 0)
|
||||||
|
// .attr('y', 0)
|
||||||
|
// .attr('class', 'node-icon ' + node.icon);
|
||||||
|
icon
|
||||||
|
.append('div')
|
||||||
|
.attr('class', 'icon-container')
|
||||||
|
.append('i')
|
||||||
|
.attr('class', 'node-icon-' + section + ' ' + node.icon);
|
||||||
|
textElem.attr(
|
||||||
|
'transform',
|
||||||
|
'translate(' + node.width / 2 + ', ' + (node.height / 2 - 1.5 * node.padding) + ')'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
node.width += 50;
|
node.width += 50;
|
||||||
const orgHeight = node.height;
|
const orgHeight = node.height;
|
||||||
node.height = Math.max(orgHeight, 60);
|
node.height = Math.max(orgHeight, 60);
|
||||||
@@ -150,6 +174,7 @@ export const drawNode = function (elem, node, section, conf) {
|
|||||||
'transform',
|
'transform',
|
||||||
'translate(' + (25 + node.width / 2) + ', ' + (heightDiff / 2 + node.padding / 2) + ')'
|
'translate(' + (25 + node.width / 2) + ', ' + (heightDiff / 2 + node.padding / 2) + ')'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
textElem.attr('transform', 'translate(' + node.width / 2 + ', ' + node.padding / 2 + ')');
|
textElem.attr('transform', 'translate(' + node.width / 2 + ', ' + node.padding / 2 + ')');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user