mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-13 20:39:38 +02:00
Fix for v2 class diagram
This commit is contained in:
@@ -281,7 +281,7 @@ class Class10 {
|
|||||||
// defaultRenderer: 'dagre-d3',
|
// defaultRenderer: 'dagre-d3',
|
||||||
},
|
},
|
||||||
class: {
|
class: {
|
||||||
defaultRenderer: 'dagre-d3',
|
// defaultRenderer: 'dagre-d3',
|
||||||
htmlLabels: true,
|
htmlLabels: true,
|
||||||
},
|
},
|
||||||
// gantt: { axisFormat: '%m/%d/%Y' },
|
// gantt: { axisFormat: '%m/%d/%Y' },
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import dagre from 'dagre';
|
|
||||||
import graphlib from 'graphlib';
|
import graphlib from 'graphlib';
|
||||||
import { log } from '../../logger';
|
import { log } from '../../logger';
|
||||||
import classDb, { lookUpDomId } from './classDb';
|
|
||||||
import { parser } from './parser/classDiagram';
|
|
||||||
import svgDraw from './svgDraw';
|
|
||||||
import { getConfig } from '../../config';
|
import { getConfig } from '../../config';
|
||||||
import { render } from '../../dagre-wrapper/index.js';
|
import { render } from '../../dagre-wrapper/index.js';
|
||||||
// import addHtmlLabel from 'dagre-d3/lib/label/add-html-label.js';
|
// import addHtmlLabel from 'dagre-d3/lib/label/add-html-label.js';
|
||||||
@@ -13,14 +9,12 @@ import { interpolateToCurve, getStylesFromArray, setupGraphViewbox } from '../..
|
|||||||
import common from '../common/common';
|
import common from '../common/common';
|
||||||
import addSVGAccessibilityFields from '../../accessibility';
|
import addSVGAccessibilityFields from '../../accessibility';
|
||||||
|
|
||||||
parser.yy = classDb;
|
|
||||||
|
|
||||||
let idCache = {};
|
let idCache = {};
|
||||||
const padding = 20;
|
const padding = 20;
|
||||||
|
|
||||||
const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
|
const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
|
||||||
|
|
||||||
const conf = {
|
let conf = {
|
||||||
dividerMargin: 10,
|
dividerMargin: 10,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
textHeight: 10,
|
textHeight: 10,
|
||||||
@@ -144,6 +138,7 @@ export const addClasses = function (classes, g) {
|
|||||||
* @param {object} g The graph object
|
* @param {object} g The graph object
|
||||||
*/
|
*/
|
||||||
export const addRelations = function (relations, g) {
|
export const addRelations = function (relations, g) {
|
||||||
|
const conf = getConfig().flowchart;
|
||||||
let cnt = 0;
|
let cnt = 0;
|
||||||
|
|
||||||
let defaultStyle;
|
let defaultStyle;
|
||||||
@@ -269,16 +264,18 @@ export const setConf = function (cnf) {
|
|||||||
*
|
*
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
|
* @param _version
|
||||||
|
* @param diagObj
|
||||||
*/
|
*/
|
||||||
export const draw = function (text, id) {
|
export const draw = function (text, id, _version, diagObj) {
|
||||||
log.info('Drawing class - ', id);
|
log.info('Drawing class - ', id);
|
||||||
classDb.clear();
|
// diagObj.db.clear();
|
||||||
// const parser = classDb.parser;
|
// const parser = diagObj.db.parser;
|
||||||
// parser.yy = classDb;
|
// parser.yy = classDb;
|
||||||
|
|
||||||
// Parse the graph definition
|
// Parse the graph definition
|
||||||
// try {
|
// try {
|
||||||
parser.parse(text);
|
// parser.parse(text);
|
||||||
// } catch (err) {
|
// } catch (err) {
|
||||||
// log.debug('Parsing failed');
|
// log.debug('Parsing failed');
|
||||||
// }
|
// }
|
||||||
@@ -298,7 +295,7 @@ export const draw = function (text, id) {
|
|||||||
compound: true,
|
compound: true,
|
||||||
})
|
})
|
||||||
.setGraph({
|
.setGraph({
|
||||||
rankdir: classDb.getDirection(),
|
rankdir: diagObj.db.getDirection(),
|
||||||
nodesep: nodeSpacing,
|
nodesep: nodeSpacing,
|
||||||
ranksep: rankSpacing,
|
ranksep: rankSpacing,
|
||||||
marginx: 8,
|
marginx: 8,
|
||||||
@@ -318,8 +315,8 @@ export const draw = function (text, id) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// Fetch the vertices/nodes and edges/links from the parsed graph definition
|
// Fetch the vertices/nodes and edges/links from the parsed graph definition
|
||||||
const classes = classDb.getClasses();
|
const classes = diagObj.db.getClasses();
|
||||||
const relations = classDb.getRelations();
|
const relations = diagObj.db.getRelations();
|
||||||
|
|
||||||
log.info(relations);
|
log.info(relations);
|
||||||
addClasses(classes, g, id);
|
addClasses(classes, g, id);
|
||||||
@@ -366,7 +363,7 @@ export const draw = function (text, id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addSVGAccessibilityFields(parser.yy, svg, id);
|
addSVGAccessibilityFields(diagObj.db, svg, id);
|
||||||
// If node has a link, wrap it in an anchor SVG object.
|
// If node has a link, wrap it in an anchor SVG object.
|
||||||
// const keys = Object.keys(classes);
|
// const keys = Object.keys(classes);
|
||||||
// keys.forEach(function(key) {
|
// keys.forEach(function(key) {
|
||||||
|
@@ -149,8 +149,8 @@ const insertMarkers = function (elem) {
|
|||||||
export const draw = function (text, id, _version, diagObj) {
|
export const draw = function (text, id, _version, diagObj) {
|
||||||
const conf = getConfig().class;
|
const conf = getConfig().class;
|
||||||
idCache = {};
|
idCache = {};
|
||||||
diagObj.db.clear();
|
// diagObj.db.clear();
|
||||||
diagObj.parser.parse(text);
|
// diagObj.parser.parse(text);
|
||||||
|
|
||||||
log.info('Rendering diagram ' + text);
|
log.info('Rendering diagram ' + text);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user