mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
feat #5042: Add flowchart.maxEdges
config.
This commit is contained in:
parent
4499926453
commit
fdf9988af1
@ -1431,6 +1431,11 @@ export interface FlowchartDiagramConfig extends BaseDiagramConfig {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
htmlLabels?: boolean;
|
htmlLabels?: boolean;
|
||||||
|
/**
|
||||||
|
* Defines the maximum number of edges that can be drawn in a graph.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
maxEdges?: number;
|
||||||
/**
|
/**
|
||||||
* Defines the spacing between nodes on the same level
|
* Defines the spacing between nodes on the same level
|
||||||
*
|
*
|
||||||
|
@ -12,7 +12,6 @@ import {
|
|||||||
setDiagramTitle,
|
setDiagramTitle,
|
||||||
getDiagramTitle,
|
getDiagramTitle,
|
||||||
} from '../common/commonDb.js';
|
} from '../common/commonDb.js';
|
||||||
import errorDiagram from '../error/errorDiagram.js';
|
|
||||||
|
|
||||||
const MERMAID_DOM_ID_PREFIX = 'flowchart-';
|
const MERMAID_DOM_ID_PREFIX = 'flowchart-';
|
||||||
let vertexCounter = 0;
|
let vertexCounter = 0;
|
||||||
@ -92,7 +91,6 @@ export const addVertex = function (_id, textObj, type, style, classes, dir, prop
|
|||||||
if (txt[0] === '"' && txt[txt.length - 1] === '"') {
|
if (txt[0] === '"' && txt[txt.length - 1] === '"') {
|
||||||
txt = txt.substring(1, txt.length - 1);
|
txt = txt.substring(1, txt.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
vertices[id].text = txt;
|
vertices[id].text = txt;
|
||||||
} else {
|
} else {
|
||||||
if (vertices[id].text === undefined) {
|
if (vertices[id].text === undefined) {
|
||||||
@ -160,11 +158,11 @@ export const addSingleLink = function (_start, _end, type) {
|
|||||||
if (edge?.length > 10) {
|
if (edge?.length > 10) {
|
||||||
edge.length = 10;
|
edge.length = 10;
|
||||||
}
|
}
|
||||||
if (edges.length < 280) {
|
if (edges.length < (config.flowchart.maxEdges ?? 500)) {
|
||||||
log.info('abc78 pushing edge...');
|
log.info('abc78 pushing edge...');
|
||||||
edges.push(edge);
|
edges.push(edge);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Too many edges');
|
throw new Error(`Edge limit exceeded. Increase config.flowchart.maxEdges to allow more edges.`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const addLink = function (_start, _end, type) {
|
export const addLink = function (_start, _end, type) {
|
||||||
@ -460,6 +458,7 @@ export const clear = function (ver = 'gen-1') {
|
|||||||
tooltips = {};
|
tooltips = {};
|
||||||
firstGraphFlag = true;
|
firstGraphFlag = true;
|
||||||
version = ver;
|
version = ver;
|
||||||
|
config = getConfig();
|
||||||
commonClear();
|
commonClear();
|
||||||
};
|
};
|
||||||
export const setGen = (ver) => {
|
export const setGen = (ver) => {
|
||||||
|
@ -1900,6 +1900,12 @@ $defs: # JSON Schema definition (maybe we should move these to a separate file)
|
|||||||
Flag for setting whether or not a html tag should be used for rendering labels on the edges.
|
Flag for setting whether or not a html tag should be used for rendering labels on the edges.
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: true
|
||||||
|
maxEdges:
|
||||||
|
description: |
|
||||||
|
Defines the maximum number of edges that can be drawn in a graph.
|
||||||
|
type: integer
|
||||||
|
default: 500
|
||||||
|
minimum: 0
|
||||||
nodeSpacing:
|
nodeSpacing:
|
||||||
description: |
|
description: |
|
||||||
Defines the spacing between nodes on the same level
|
Defines the spacing between nodes on the same level
|
||||||
|
Loading…
x
Reference in New Issue
Block a user