mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-15 13:29:40 +02:00
#1044 fix: Multiple class diagrams are not rendered correctly
This commit is contained in:
@@ -8,7 +8,7 @@ import { parser } from './parser/classDiagram';
|
|||||||
|
|
||||||
parser.yy = classDb;
|
parser.yy = classDb;
|
||||||
|
|
||||||
const idCache = {};
|
let idCache = {};
|
||||||
|
|
||||||
let classCnt = 0;
|
let classCnt = 0;
|
||||||
const conf = {
|
const conf = {
|
||||||
@@ -136,7 +136,6 @@ const insertMarkers = function(elem) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let edgeCount = 0;
|
let edgeCount = 0;
|
||||||
let total = 0;
|
|
||||||
const drawEdge = function(elem, path, relation) {
|
const drawEdge = function(elem, path, relation) {
|
||||||
const getRelationType = function(type) {
|
const getRelationType = function(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -291,7 +290,7 @@ const drawClass = function(elem, classDef) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const id = 'classId' + (classCnt % total);
|
const id = 'classId' + classCnt;
|
||||||
const classInfo = {
|
const classInfo = {
|
||||||
id: id,
|
id: id,
|
||||||
label: classDef.id,
|
label: classDef.id,
|
||||||
@@ -411,6 +410,7 @@ export const setConf = function(cnf) {
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
export const draw = function(text, id) {
|
export const draw = function(text, id) {
|
||||||
|
idCache = {};
|
||||||
parser.yy.clear();
|
parser.yy.clear();
|
||||||
parser.parse(text);
|
parser.parse(text);
|
||||||
|
|
||||||
@@ -437,7 +437,6 @@ export const draw = function(text, id) {
|
|||||||
|
|
||||||
const classes = classDb.getClasses();
|
const classes = classDb.getClasses();
|
||||||
const keys = Object.keys(classes);
|
const keys = Object.keys(classes);
|
||||||
total = keys.length;
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
const classDef = classes[keys[i]];
|
const classDef = classes[keys[i]];
|
||||||
const node = drawClass(diagram, classDef);
|
const node = drawClass(diagram, classDef);
|
||||||
|
Reference in New Issue
Block a user